comparison arogue7/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 9c4e50b5825c
children a307ff9cd95e
comparison
equal deleted inserted replaced
144:708bb2dea17c 145:aac28331e71d
48 get_abil(), 48 get_abil(),
49 get_quest(), 49 get_quest(),
50 put_quest(); 50 put_quest();
51 51
52 int get_str_prot(char *opt, WINDOW *win); 52 int get_str_prot(char *opt, WINDOW *win);
53 int get_score(char *opt, WINDOW *win);
53 bool allowchange(OPTION *op); 54 bool allowchange(OPTION *op);
54 55
55 OPTION optlist[] = { 56 OPTION optlist[] = {
56 {"terse", "Terse output: ", 57 {"terse", "Terse output: ",
57 (int *) &terse, put_bool, get_bool }, 58 (int *) &terse, put_bool, get_bool },
70 {"name", "Name: ", 71 {"name", "Name: ",
71 (int *) whoami, put_str, get_str_prot }, 72 (int *) whoami, put_str, get_str_prot },
72 {"file", "Save file: ", 73 {"file", "Save file: ",
73 (int *) file_name, put_str, get_str_prot }, 74 (int *) file_name, put_str, get_str_prot },
74 {"score", "Score file: ", 75 {"score", "Score file: ",
75 (int *) score_file, put_str, get_str_prot }, 76 (int *) score_file, put_str, get_score },
76 {"class", "Character class: ", 77 {"class", "Character class: ",
77 (int *)&char_type, put_abil, get_abil }, 78 (int *)&char_type, put_abil, get_abil },
78 {"quest", "Quest item: ", 79 {"quest", "Quest item: ",
79 (int *) &quest_item, put_quest, get_quest } 80 (int *) &quest_item, put_quest, get_quest }
80 }; 81 };
484 else { 485 else {
485 return get_str(opt, win); 486 return get_str(opt, win);
486 } 487 }
487 } 488 }
488 489
490 /* When getting the scorefile, the new file must be opened. */
491 int
492 get_score(char *optstr, WINDOW *win)
493 {
494 char old_score_file[LINELEN];
495 int status;
496
497 if (use_savedir)
498 return get_str_prot(optstr, win);
499
500 strcpy(old_score_file, optstr);
501 status = get_str(optstr, win);
502 if (status == NORM && strcmp(old_score_file, optstr))
503 {
504 md_reopen_score();
505 }
506 return status;
507 }
508
489 bool 509 bool
490 allowchange(OPTION *op) 510 allowchange(OPTION *op)
491 { 511 {
492 if (!use_savedir) 512 if (!use_savedir)
493 return TRUE; 513 return TRUE;