Mercurial > hg > early-roguelike
diff xrogue/options.c @ 145:aac28331e71d
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.
author | John "Elwin" Edwards |
---|---|
date | Wed, 20 May 2015 08:42:17 -0400 |
parents | 443c8bd3e290 |
children | f54901b9c39b |
line wrap: on
line diff
--- a/xrogue/options.c Mon May 18 10:53:22 2015 -0400 +++ b/xrogue/options.c Wed May 20 08:42:17 2015 -0400 @@ -52,6 +52,7 @@ 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 @@ {"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 @@ } } +/* 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) {