symbols file feedback (trunk only)

Pat Rankin wrote:
> When 'symbols' is missing from the playground, or is an empty
> file, picking either the symset or roguesymset option via the
> 'O' command just goes right back to the game display (or next
> pending compound option) without giving any feedback.
>
This commit is contained in:
nethack.allison
2006-09-23 18:32:21 +00:00
parent f713038a88
commit 7fce69157e
2 changed files with 23 additions and 10 deletions
+4 -4
View File
@@ -376,18 +376,18 @@ int nondefault;
for (i = 0; i < MAXOCLASSES; i++) for (i = 0; i < MAXOCLASSES; i++)
oc_syms[i] = l_oc_syms[i]; oc_syms[i] = l_oc_syms[i];
#ifdef PC9800 # ifdef PC9800
if (SYMHANDLING(H_IBM) if (SYMHANDLING(H_IBM)
&& ibmgraphics_mode_callback) && ibmgraphics_mode_callback)
(*ibmgraphics_mode_callback)(); (*ibmgraphics_mode_callback)();
else if (!symset[currentgraphics] && ascgraphics_mode_callback) else if (!symset[currentgraphics] && ascgraphics_mode_callback)
(*ascgraphics_mode_callback)(); (*ascgraphics_mode_callback)();
#endif # endif
#ifdef TERMLIB # ifdef TERMLIB
if (SYMHANDLING(H_DEC) if (SYMHANDLING(H_DEC)
&& decgraphics_mode_callback) && decgraphics_mode_callback)
(*decgraphics_mode_callback)(); (*decgraphics_mode_callback)();
#endif # endif
} else } else
#endif #endif
init_symbols(); init_symbols();
+19 -6
View File
@@ -1304,9 +1304,11 @@ boolean tinitial, tfrom_file;
symset[ROGUESET] = (char *)alloc(strlen(op) + 1); symset[ROGUESET] = (char *)alloc(strlen(op) + 1);
Strcpy(symset[ROGUESET], op); Strcpy(symset[ROGUESET], op);
if (!read_sym_file(ROGUESET)) { if (!read_sym_file(ROGUESET)) {
badoption(opts);
free((char *)symset[ROGUESET]); free((char *)symset[ROGUESET]);
symset[ROGUESET] = (char *)0; symset[ROGUESET] = (char *)0;
raw_printf("Unable to load symbol set \"%s\" from \"%s\".",
op, SYMBOLS);
wait_synch();
} else { } else {
if (!initial && Is_rogue_level(&u.uz)) if (!initial && Is_rogue_level(&u.uz))
assign_graphics(ROGUESET); assign_graphics(ROGUESET);
@@ -1326,9 +1328,11 @@ boolean tinitial, tfrom_file;
symset[PRIMARY] = (char *)alloc(strlen(op) + 1); symset[PRIMARY] = (char *)alloc(strlen(op) + 1);
Strcpy(symset[PRIMARY], op); Strcpy(symset[PRIMARY], op);
if (!read_sym_file(PRIMARY)) { if (!read_sym_file(PRIMARY)) {
badoption(opts);
free((char *)symset[PRIMARY]); free((char *)symset[PRIMARY]);
symset[PRIMARY] = (char *)0; symset[PRIMARY] = (char *)0;
raw_printf("Unable to load symbol set \"%s\" from \"%s\".",
op, SYMBOLS);
wait_synch();
} else { } else {
switch_symbols(TRUE); switch_symbols(TRUE);
need_redraw = TRUE; need_redraw = TRUE;
@@ -3146,7 +3150,7 @@ boolean setinitial,setfromfile;
menu_item *symset_pick = (menu_item *)0; menu_item *symset_pick = (menu_item *)0;
boolean rogueflag = (*optname == 'r'); boolean rogueflag = (*optname == 'r');
char *symset_name; char *symset_name;
int chosen = -2, which_set = int chosen = -2, res, which_set =
#ifdef REINCARNATION #ifdef REINCARNATION
rogueflag ? ROGUESET : rogueflag ? ROGUESET :
#endif #endif
@@ -3159,7 +3163,8 @@ boolean setinitial,setfromfile;
symset_name = symset[which_set]; symset_name = symset[which_set];
symset[which_set] = (char *)0; symset[which_set] = (char *)0;
if (read_sym_file(which_set) && symset_list) { res = read_sym_file(which_set);
if (res && symset_list) {
int let = 'a'; int let = 'a';
struct textlist *sl; struct textlist *sl;
tmpwin = create_nhwindow(NHW_MENU); tmpwin = create_nhwindow(NHW_MENU);
@@ -3210,8 +3215,16 @@ boolean setinitial,setfromfile;
symset_list = sl->next; symset_list = sl->next;
} }
symset_list = (struct textlist *)0; symset_list = (struct textlist *)0;
} else if (!res) {
/* The symbols file could not be accessed */
pline("Unable to access \"%s\" file.", SYMBOLS);
return TRUE;
} else if (!symset_list) {
/* The symbols file was empty */
pline("There were no symbol sets found in \"%s\".",
SYMBOLS);
return TRUE;
} }
/* these set default symbols and clear the handling value */ /* these set default symbols and clear the handling value */
# ifdef REINCARNATION # ifdef REINCARNATION
if(rogueflag) init_r_symbols(); if(rogueflag) init_r_symbols();
@@ -3228,7 +3241,7 @@ boolean setinitial,setfromfile;
else { else {
free((genericptr_t)symset[which_set]); free((genericptr_t)symset[which_set]);
symset[which_set] = (char *)0; symset[which_set] = (char *)0;
return 0; return TRUE;
} }
} }