Advanced Rogue family: fix the "score" option.
Changing the score file (when permitted) now works again, closing the old score file and opening the new one.
This commit is contained in:
parent
ea4244de91
commit
e3620a3781
14 changed files with 105 additions and 14 deletions
|
|
@ -26,8 +26,6 @@
|
|||
#include "network.h"
|
||||
#include "rogue.h"
|
||||
|
||||
FILE *scorefi = NULL;
|
||||
FILE *logfile = NULL;
|
||||
void open_records(void);
|
||||
|
||||
main(argc, argv, envp)
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ int put_bool(),
|
|||
get_default();
|
||||
|
||||
int get_str_prot(char *opt, WINDOW *win);
|
||||
int get_score(char *opt, WINDOW *win);
|
||||
bool allowchange(OPTION *op);
|
||||
|
||||
OPTION optlist[] = {
|
||||
|
|
@ -74,7 +75,7 @@ OPTION optlist[] = {
|
|||
{"file", "Save file: ",
|
||||
(int *) file_name, put_str, get_str_prot },
|
||||
{"score", "Score file: ",
|
||||
(int *) score_file, put_str, get_str_prot },
|
||||
(int *) score_file, put_str, get_score },
|
||||
{"class", "Character type: ",
|
||||
(int *) &char_type, put_abil, get_abil },
|
||||
{"quest", "Quest item: ",
|
||||
|
|
@ -521,6 +522,29 @@ get_str_prot(char *opt, WINDOW *win)
|
|||
}
|
||||
}
|
||||
|
||||
/* When getting the scorefile, the new file must be opened. */
|
||||
int
|
||||
get_score(char *optstr, WINDOW *win)
|
||||
{
|
||||
char old_score_file[LINELEN];
|
||||
int status;
|
||||
|
||||
if (use_savedir)
|
||||
return get_str_prot(optstr, win);
|
||||
|
||||
strcpy(old_score_file, optstr);
|
||||
status = get_str(optstr, win);
|
||||
if (status == NORM && strcmp(old_score_file, optstr))
|
||||
{
|
||||
if (scorefi != NULL)
|
||||
fclose(scorefi);
|
||||
scorefi = fopen(score_file, "rb+");
|
||||
if (scorefi == NULL)
|
||||
scorefi = fopen(score_file, "wb+");
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
bool
|
||||
allowchange(OPTION *op)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -126,6 +126,9 @@ bool in_shell = FALSE;
|
|||
bool daytime = TRUE;
|
||||
bool funfont = FALSE;
|
||||
|
||||
FILE *scorefi = NULL;
|
||||
FILE *logfile = NULL;
|
||||
|
||||
LEVTYPE levtype; /* what type of level am i'm on? */
|
||||
|
||||
char *nothing = "Nothing seems to happen. ";
|
||||
|
|
|
|||
|
|
@ -1398,6 +1398,8 @@ extern char *nothing; /* "Nothing seems to happen." */
|
|||
extern char *spacemsg;
|
||||
extern char *morestr;
|
||||
extern char *retstr;
|
||||
extern FILE *scorefi;
|
||||
extern FILE *logfile;
|
||||
extern LEVTYPE levtype;
|
||||
extern int (*add_abil[NUMABILITIES])(); /* Functions to change abilities */
|
||||
extern int (*res_abil[NUMABILITIES])(); /* Functions to change abilities */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue