# HG changeset patch # User John "Elwin" Edwards # Date 1514587088 18000 # Node ID 9dcf3344d3fd9581ba16008d3dbd2fc90eea6c47 # Parent ebf49a933e51e0b9e79e91154c74e189ce63d4e2 UltraRogue: fix changing the score option. Changing the score file now works again, if use_savedir is not set. If it is, an error message is shown. diff -r ebf49a933e51 -r 9dcf3344d3fd urogue/options.c --- a/urogue/options.c Fri Dec 29 14:16:24 2017 -0500 +++ b/urogue/options.c Fri Dec 29 17:38:08 2017 -0500 @@ -24,6 +24,7 @@ #define EQSTR(a, b, c) (strncmp(a, b, c) == 0) int get_restr(opt_arg *opt, WINDOW *win); +int get_score(opt_arg *opt, WINDOW *win); /* description of an option and what to do with it */ static OPTION optlist[] = @@ -35,7 +36,7 @@ {"name", "Name (name): ", &whoami, put_str, get_restr}, {"fruit", "Fruit (fruit): ", &fruit, put_str, get_str}, {"file", "Save file (file): ", &file_name, put_str, get_restr}, -{"score", "Score file (score): ", &score_file, put_str, get_restr}, +{"score", "Score file (score): ", &score_file, put_str, get_score}, {"class", "Character class (class): ",&char_type, put_abil, get_abil} }; @@ -583,3 +584,24 @@ return(NORM); } + +int +get_score(opt_arg *opt, WINDOW *win) +{ + char old_score_file[2*LINELEN]; + int status; + + if (use_savedir) + return get_restr(opt, win); + + strncpy(old_score_file, opt->str, 2*LINELEN); + old_score_file[2*LINELEN - 1] = '\0'; + status = get_str(opt, win); + if (status == NORM && strcmp(old_score_file, opt->str)) { + fclose(fd_score); + fd_score = fopen(score_file, "r+"); + if (fd_score == NULL) + fd_score = fopen(score_file, "a+"); + } + return status; +}