diff arogue5/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 d4bf99f82ea0
children 56e748983fa8
line wrap: on
line diff
--- a/arogue5/options.c	Mon May 18 10:53:22 2015 -0400
+++ b/arogue5/options.c	Wed May 20 08:42:17 2015 -0400
@@ -40,6 +40,7 @@
 	put_str(),
 	get_str(),
 	get_restr(),
+	get_score(),
 	put_abil(),
 	get_abil(),
 	get_quest(),
@@ -65,7 +66,7 @@
     {"file",	 "Save file: ",
 		(int *) file_name,	put_str,	get_restr	},
     {"score",	 "Score file: ",
-		(int *) score_file,	put_str,	get_restr	},
+		(int *) score_file,	put_str,	get_score	},
     {"class",	"Character class: ",
 		(int *)&char_type,	put_abil,	get_abil	},
     {"quest",	"Quest item: ",
@@ -87,6 +88,26 @@
         return get_str(optstr, win);
 }
 
+/* For the score file, which must be opened. */
+int get_score(char *optstr, WINDOW *win)
+{
+    char old_score_file[LINELEN];
+    int status;
+
+    if (use_savedir)
+        return get_restr(optstr, win);
+
+    strcpy(old_score_file, optstr);
+    status = get_str(optstr, win);
+    if (status != NORM)
+        return status;
+    if (strcmp(old_score_file, optstr))
+    {
+        md_reopen_score();
+    }
+    return status;
+}
+
 /*
  * The ability field is read-only
  */