diff --git a/include/extern.h b/include/extern.h index cb20ca78d..692bf294e 100644 --- a/include/extern.h +++ b/include/extern.h @@ -491,9 +491,9 @@ E boolean FDECL(hurtle_step, (genericptr_t, int, int)); E int FDECL(def_char_to_objclass, (CHAR_P)); E int FDECL(def_char_to_monclass, (CHAR_P)); #if !defined(MAKEDEFS_C) && !defined(LEV_LEX_C) -E void FDECL(switch_graphics, (int)); +E void FDECL(switch_symbols, (int)); +E void FDECL(assign_graphics, (int)); #ifdef REINCARNATION -E void FDECL(assign_rogue_graphics, (BOOLEAN_P)); E void NDECL(init_r_symbols); #endif E void NDECL(init_symbols); @@ -502,7 +502,6 @@ E void NDECL(init_l_symbols); #ifdef ASCIIGRAPH E void FDECL(update_l_symset, (struct symparse *,int)); E void FDECL(update_r_symset, (struct symparse *,int)); -E void FDECL(switch_graphics, (int)); #endif #ifdef BARGETHROUGH E boolean FDECL(cursed_object_at, (int, int)); @@ -719,8 +718,8 @@ E void FDECL(check_recordfile, (const char *)); E void NDECL(read_wizkit); #endif #ifdef ASCIIGRAPH -E int FDECL(read_sym_file, (BOOLEAN_P)); -E int FDECL(parse_sym_line, (char *,BOOLEAN_P)); +E int FDECL(read_sym_file, (int)); +E int FDECL(parse_sym_line, (char *,int)); #endif E void FDECL(paniclog, (const char *, const char *)); E int FDECL(validate_prefix_locations, (char *)); @@ -1537,7 +1536,7 @@ E int FDECL(add_autopickup_exception, (const char *)); E void NDECL(free_autopickup_exceptions); #endif /* AUTOPICKUP_EXCEPTIONS */ #ifdef ASCIIGRAPH -E int FDECL(load_symset, (const char *,BOOLEAN_P)); +E int FDECL(load_symset, (const char *,int)); E void FDECL(parsesymbols, (char *)); E struct symparse *FDECL(match_sym, (char *)); E int FDECL(sym_val, (char *)); diff --git a/include/rm.h b/include/rm.h index 3ec39dd61..16173cbd1 100644 --- a/include/rm.h +++ b/include/rm.h @@ -242,7 +242,15 @@ struct textlist { }; /* - * special symbol set handling types (callbacks, etc.) + * Graphics sets for display symbols + */ +#define DEFAULT_GRAPHICS 0 /* regular characters: '-', '+', &c */ +#define PRIMARY 0 /* primary graphics */ +#define ROGUESET 1 /* rogue graphics */ +#define NUM_GRAPHICS 2 + +/* + * special symbol set handling types ( for invoking callbacks, etc.) * Must match the order of the known_handlers strings * in drawing.c */ @@ -250,29 +258,13 @@ struct textlist { #define H_IBM 1 #define H_DEC 2 -#ifdef REINCARNATION -#define ROGUEHANDLING(ht) (Is_rogue_level(&u.uz) && \ - rogue_level.dlevel != 0 && roguehandling == (ht)) -#define SYMHANDLING(ht) \ - (ROGUEHANDLING(ht) || \ - ((!Is_rogue_level(&u.uz) || rogue_level.dlevel == 0) && \ - symhandling == (ht))) -#else -#define SYMHANDLING(ht) (symhandling == (ht)) -#endif - extern const struct symdef defsyms[MAXPCHARS]; /* defaults */ extern uchar showsyms[MAXPCHARS]; extern const struct symdef def_warnsyms[WARNCOUNT]; -extern char *symset, *roguesymset; /* from drawing.c */ -extern int symhandling, roguehandling; /* from drawing.c */ +extern char *symset[NUM_GRAPHICS]; /* from drawing.c */ +extern int symhandling[NUM_GRAPHICS], currentgraphics; /* from drawing.c */ -/* - * Graphics sets for display symbols - */ -#define DEFAULT_GRAPHICS 0 /* regular characters: '-', '+', &c */ -#define ROGUESET 1 /* useful for load_symset() */ -#define PRIMARY 0 +#define SYMHANDLING(ht) (symhandling[currentgraphics] == (ht)) /* * The 5 possible states of doors diff --git a/src/do.c b/src/do.c index 7e60a1e50..b3330c149 100644 --- a/src/do.c +++ b/src/do.c @@ -1104,7 +1104,7 @@ boolean at_stairs, falling, portal; #ifdef REINCARNATION if (Is_rogue_level(newlevel) || Is_rogue_level(&u.uz)) - assign_rogue_graphics(Is_rogue_level(newlevel)); + assign_graphics(Is_rogue_level(newlevel) ? ROGUESET : PRIMARY); #endif #ifdef USE_TILES substitute_tiles(newlevel); diff --git a/src/drawing.c b/src/drawing.c index 772abc62e..6651950ef 100644 --- a/src/drawing.c +++ b/src/drawing.c @@ -17,8 +17,8 @@ #define C(n) #endif -char *symset = 0, *roguesymset = 0; -int symhandling = 0, roguehandling = 0; +char *symset[NUM_GRAPHICS] = {0,0}; +int symhandling[NUM_GRAPHICS] = {0,0}, currentgraphics = 0; uchar oc_syms[MAXOCLASSES] = DUMMY; /* the current object display symbols */ uchar showsyms[MAXPCHARS] = DUMMY; /* the current feature display symbols */ @@ -310,21 +310,6 @@ def_char_to_monclass(ch) /* * Explanations of the functions found below: * - * switch_graphics(arg) - * Called to swap the current display symbols - * (monsyms, showsyms, oc_syms). - * - * If !arg then the display symbols are - * taken from def_monsyms, defsyms, def_oc_syms - * default NetHack symbols. - * - * If arg then the display symbols are - * taken from the adjustable display symbols - * found in l_monsyms, l_showsyms, l_oc_syms. - * Those symbols may have been loaded from an - * external symfile by config file options or - * interactively in the options menu. - * * init_symbols() * Sets the current display symbols, the * loadable symbols to the default NetHack @@ -334,18 +319,36 @@ def_char_to_monclass(ch) * after execution begins. Any previously * loaded external symbol sets are discarded. * - * assign_rogue_graphics(arg) + * switch_symbols(arg) + * Called to swap in new current display symbols + * (monsyms, showsyms, oc_syms) from either + * the default symbols, or from the loadable + * symbols. + * + * If (arg == 0) then the display symbols are + * taken from def_monsyms, defsyms, def_oc_syms + * default NetHack symbols. + * + * If (arg != 0), which is the expected usage, + * then the display symbols are taken from the + * adjustable display symbols found in l_monsyms, + * l_showsyms, l_oc_syms. Those symbols may have + * been loaded from an external symbol file by + * config file options or interactively in the + * options menu. + * + * assign_graphics(arg) * * This is used in the game core to toggle in and * out of rogue level display mode. * - * If arg is TRUE, this places the rogue level + * If arg is ROGUESET, this places the rogue level * symbols from r_monsyms, r_showsyms, and r_oc_syms * into the current display symbols: monsyms, showsyms, * and oc_syms. * - * If arg is FALSE, this places the symbols from - * l_monsyms, l_showsyms, l_oc_syms into the current + * If arg is PRIMARY, this places the symbols + * from l_monsyms, l_showsyms, l_oc_syms into the current * display symbols: monsyms, showsyms, oc_syms. * * update_l_symset() @@ -357,7 +360,7 @@ def_char_to_monclass(ch) */ void -switch_graphics(nondefault) +switch_symbols(nondefault) int nondefault; { #ifdef ASCIIGRAPH @@ -372,22 +375,15 @@ int nondefault; for (i = 0; i < MAXOCLASSES; i++) oc_syms[i] = l_oc_syms[i]; - /* - * We can't use the SYMHANDLING or ROGUEHANDLING - * macros in this file (drawing.c) because doing - * so would cause link errors during some util - * program builds because of the presence of - * the Is_Roguelevel checks in those macros. - */ #ifdef PC9800 - if (symhandling == H_IBM + if (SYMHANDLING(H_IBM) && ibmgraphics_mode_callback) (*ibmgraphics_mode_callback)(); - else if (!symset && ascgraphics_mode_callback) + else if (!symset[currentgraphics] && ascgraphics_mode_callback) (*ascgraphics_mode_callback)(); #endif #ifdef TERMLIB - if (symhandling == H_DEC + if (SYMHANDLING(H_DEC) && decgraphics_mode_callback) (*decgraphics_mode_callback)(); #endif @@ -433,6 +429,49 @@ init_l_symbols() for (i = 0; i < MAXOCLASSES; i++) l_oc_syms[i] = def_oc_syms[i].sym; + symhandling[PRIMARY] = H_UNK; +} + +void +assign_graphics(whichset) +int whichset; +{ + /* Adjust graphics display characters on Rogue levels */ + register int i; + + switch(whichset) { + case ROGUESET: + + for (i = 0; i < MAXMCLASSES; i++) + monsyms[i] = r_monsyms[i]; + + for (i = 0; i < MAXPCHARS; i++) + showsyms[i] = r_showsyms[i]; + + for (i = 0; i < MAXOCLASSES; i++) + oc_syms[i] = r_oc_syms[i]; + +# if defined(MSDOS) && defined(USE_TILES) + if (iflags.grmode) tileview(FALSE); +# endif + currentgraphics = ROGUESET; + break; + case PRIMARY: + default: + for (i = 0; i < MAXMCLASSES; i++) + monsyms[i] = l_monsyms[i]; + + for (i = 0; i < MAXPCHARS; i++) + showsyms[i] = l_showsyms[i]; + + for (i = 0; i < MAXOCLASSES; i++) + oc_syms[i] = l_oc_syms[i]; +# if defined(MSDOS) && defined(USE_TILES) + if (iflags.grmode) tileview(TRUE); +# endif + currentgraphics = PRIMARY; + break; + } } #ifdef REINCARNATION @@ -453,43 +492,8 @@ init_r_symbols() for (i = 0; i < MAXOCLASSES; i++) r_oc_syms[i] = def_r_oc_syms[i]; -} -void -assign_rogue_graphics(is_rlevel) -boolean is_rlevel; -{ - /* Adjust graphics display characters on Rogue levels */ - register int i; - - if (is_rlevel) { - register int i; - - for (i = 0; i < MAXMCLASSES; i++) - monsyms[i] = r_monsyms[i]; - - for (i = 0; i < MAXPCHARS; i++) - showsyms[i] = r_showsyms[i]; - - for (i = 0; i < MAXOCLASSES; i++) - oc_syms[i] = r_oc_syms[i]; - -# if defined(MSDOS) && defined(USE_TILES) - if (iflags.grmode) tileview(FALSE); -# endif - } else { - for (i = 0; i < MAXMCLASSES; i++) - monsyms[i] = l_monsyms[i]; - - for (i = 0; i < MAXPCHARS; i++) - showsyms[i] = l_showsyms[i]; - - for (i = 0; i < MAXOCLASSES; i++) - oc_syms[i] = l_oc_syms[i]; -# if defined(MSDOS) && defined(USE_TILES) - if (iflags.grmode) tileview(TRUE); -# endif - } + symhandling[ROGUESET] = H_UNK; } void @@ -730,28 +734,5 @@ struct symparse loadsyms[] = { }; #endif /*ASCIIGRAPH*/ -/* OBSOLETE */ -#if 0 -STATIC_OVL void -graphics_opts(opts, optype, maxlen, offset) -register char *opts; -const char *optype; -int maxlen, offset; -{ - uchar translate[MAXPCHARS+1]; - int length, i; - - if (!(opts = string_for_env_opt(optype, opts, FALSE))) - return; - escapes(opts, opts); - - length = strlen(opts); - if (length > maxlen) length = maxlen; - /* match the form obtained from PC configuration files */ - for (i = 0; i < length; i++) - translate[i] = (uchar) opts[i]; - assign_graphics(translate, length, maxlen, offset); -} -#endif /*drawing.c*/ diff --git a/src/files.c b/src/files.c index 32a8c0c11..b243e7733 100644 --- a/src/files.c +++ b/src/files.c @@ -187,7 +187,7 @@ STATIC_DCL int FDECL(get_uchars, (FILE *,char *,char *,uchar *,BOOLEAN_P,int,con int FDECL(parse_config_line, (FILE *,char *,char *,char *)); #ifdef ASCIIGRAPH STATIC_DCL FILE *NDECL(fopen_sym_file); -STATIC_DCL void FDECL(set_symhandling, (char *,BOOLEAN_P)); +STATIC_DCL void FDECL(set_symhandling, (char *,int)); #endif #ifdef NOCWD_ASSUMPTIONS STATIC_DCL void FDECL(adjust_prefix, (char *, int)); @@ -2089,7 +2089,7 @@ char *tmp_levels; bufp = symbuf; } while (*bufp == '#'); } while (morelines); - switch_graphics(TRUE); + switch_symbols(TRUE); #endif /*ASCIIGRAPH*/ #ifdef WIZARD } else if (match_varname(buf, "WIZKIT", 6)) { @@ -2442,8 +2442,8 @@ fopen_sym_file() * 0 if it wasn't found in the sym file or other problem. */ int -read_sym_file(rogueflag) -boolean rogueflag; +read_sym_file(which_set) +int which_set; { char buf[4*BUFSZ]; FILE *fp; @@ -2453,19 +2453,17 @@ boolean rogueflag; symset_count = 0; chosen_symset_start = chosen_symset_end = FALSE; while (fgets(buf, 4*BUFSZ, fp)) { - if (!parse_sym_line(buf, rogueflag)) { + if (!parse_sym_line(buf, which_set)) { raw_printf("Bad symbol line: \"%.50s\"", buf); wait_synch(); } } (void) fclose(fp); - if (!chosen_symset_end && !chosen_symset_start) return 0; + if (!chosen_symset_end && !chosen_symset_start) + return (symset[which_set] == 0) ? 1 : 0; if (!chosen_symset_end) { raw_printf("Missing finish for symset \"%s\"", -#ifdef REINCARNATION - rogueflag ? roguesymset : -#endif - symset); + symset[which_set] ? symset[which_set] : "unknown"); wait_synch(); } return 1; @@ -2473,18 +2471,13 @@ boolean rogueflag; /* returns 0 on error */ int -parse_sym_line(buf, rogueflag) +parse_sym_line(buf, which_set) char *buf; -boolean rogueflag; +int which_set; { int val; struct symparse *symp = (struct symparse *)0; char *bufp, *commentp, *altp; - char *symsetname = -#ifdef REINCARNATION - rogueflag ? roguesymset : -#endif - symset; if (*buf == '#') return 1; @@ -2516,8 +2509,9 @@ boolean rogueflag; if (!bufp) { if (strncmpi(buf, "finish", 6) == 0) { /* end current graphics set */ + if (chosen_symset_start) + chosen_symset_end = TRUE; chosen_symset_start = FALSE; - chosen_symset_end = TRUE; return 1; } return 0; @@ -2530,8 +2524,8 @@ boolean rogueflag; if (!symp) return 0; - if (!symsetname) { - /* A null symsetname indicates that we're just + if (!symset[which_set]) { + /* A null symset name indicates that we're just building a pick-list of possible symset values from the file, so only do that */ if (symp->range == SYM_CONTROL && symp->idx == 0) { @@ -2557,36 +2551,31 @@ boolean rogueflag; switch(symp->idx) { case 0: /* start of symset */ - if (!strcmpi(bufp, symsetname)) { /* desired one? */ + if (!strcmpi(bufp, symset[which_set])) { /* desired one? */ chosen_symset_start = TRUE; #ifdef REINCARNATION - if (rogueflag) { - init_r_symbols(); - roguehandling = H_UNK; - } + if (which_set == ROGUESET) init_r_symbols(); #endif - if (!rogueflag) { - init_l_symbols(); - symhandling = H_UNK; - } + if (which_set == PRIMARY) init_l_symbols(); } break; case 1: /* finish symset */ + if (chosen_symset_start) + chosen_symset_end = TRUE; chosen_symset_start = FALSE; - chosen_symset_end = TRUE; break; case 2: /* handler type identified */ if (chosen_symset_start) - set_symhandling(bufp, rogueflag); + set_symhandling(bufp, which_set); break; } } else { /* !SYM_CONTROL */ val = sym_val(bufp); if (chosen_symset_start) { #ifdef REINCARNATION - if (rogueflag) + if (which_set == ROGUESET) update_r_symset(symp, val); else #endif @@ -2598,28 +2587,17 @@ boolean rogueflag; } STATIC_OVL void -set_symhandling(handling, rogueflag) +set_symhandling(handling, which_set) char *handling; -boolean rogueflag; +int which_set; { int i = 0; -#ifdef REINCARNATION - if (rogueflag) roguehandling = H_UNK; -#endif - if (!rogueflag) symhandling = H_UNK; + symhandling[which_set] = H_UNK; while (known_handling[i]) { if (!strcmpi(known_handling[i], handling)) { -#ifdef REINCARNATION - if (rogueflag) { - roguehandling = i; - return; - } -#endif - if (!rogueflag) { - symhandling = i; - return; - } + symhandling[which_set] = i; + return; } i++; } diff --git a/src/mapglyph.c b/src/mapglyph.c index 186e22f95..dc0473d45 100644 --- a/src/mapglyph.c +++ b/src/mapglyph.c @@ -50,9 +50,11 @@ int explcolors[] = { #ifdef ROGUE_COLOR # if defined(USE_TILES) && defined(MSDOS) -#define HAS_ROGUE_IBM_GRAPHICS (ROGUEHANDLING(H_IBM) && !iflags.grmode) +#define HAS_ROGUE_IBM_GRAPHICS (currentgraphics == ROGUESET && \ + SYMHANDLING(H_IBM) && !iflags.grmode) # else -#define HAS_ROGUE_IBM_GRAPHICS (ROGUEHANDLING(H_IBM)) +#define HAS_ROGUE_IBM_GRAPHICS (currentgraphics == ROGUESET && \ + SYMHANDLING(H_IBM)) # endif #endif diff --git a/src/options.c b/src/options.c index 15ab6c871..687c742c0 100644 --- a/src/options.c +++ b/src/options.c @@ -364,10 +364,10 @@ static struct Comp_Opt 80, DISP_IN_GAME }, { "windowtype", "windowing system to use", WINTYPELEN, DISP_IN_GAME }, #ifdef BACKWARD_COMPAT - {"DECgraphics", "deprecated", 70, SET_IN_FILE}, - {"IBMgraphics", "deprecated", 70, SET_IN_FILE}, + {"DECgraphics", "load DECGraphics display symbols", 70, SET_IN_FILE}, + {"IBMgraphics", "load IBMGraphics display symbols", 70, SET_IN_FILE}, # ifdef MAC_GRAPHICS_ENV - {"Macgraphics", "deprecated", 70, SET_IN_FILE}, + {"Macgraphics", "load MACGraphics display symbols", 70, SET_IN_FILE}, # endif #endif { (char *)0, (char *)0, 0, 0 } @@ -597,7 +597,7 @@ initoptions() for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++) flags.end_disclose[i] = DISCLOSE_PROMPT_DEFAULT_NO; - switch_graphics(DEFAULT_GRAPHICS); /* set default characters */ + switch_symbols(FALSE); /* set default characters */ #if defined(UNIX) && defined(TTY_GRAPHICS) /* * Set defaults for some options depending on what we can @@ -609,11 +609,11 @@ initoptions() /* this detects the IBM-compatible console on most 386 boxes */ if ((opts = nh_getenv("TERM")) && !strncmp(opts, "AT", 2)) { #ifdef ASCIIGRAPH - if (!symset) load_symset("IBMGraphics", PRIMARY); + if (!symset[PRIMARY]) load_symset("IBMGraphics", PRIMARY); - if (!roguesymset) load_symset("RogueIBM", ROGUESET); + if (!symset[ROGUESET]) load_symset("RogueIBM", ROGUESET); - switch_graphics(TRUE); + switch_symbols(TRUE); #endif # ifdef TEXTCOLOR iflags.use_color = TRUE; @@ -627,19 +627,19 @@ initoptions() !strncmpi(opts, "vt", 2) && AS && AE && index(AS, '\016') && index(AE, '\017')) { # ifdef ASCIIGRAPH - if (!symset) load_symset("DECGraphics", PRIMARY); + if (!symset[PRIMARY]) load_symset("DECGraphics", PRIMARY); - switch_graphics(TRUE); + switch_symbols(TRUE); # endif /*ASCIIGRAPH*/ } # endif #endif /* UNIX || VMS */ #ifdef MAC_GRAPHICS_ENV - if (!symset) load_symset("MACGraphics", PRIMARY); - switch_graphics(TRUE); + if (!symset[PRIMARY]) load_symset("MACGraphics", PRIMARY); + switch_symbols(TRUE); #endif /* MAC_GRAPHICS_ENV */ flags.menu_style = MENU_FULL; @@ -1301,15 +1301,15 @@ boolean tinitial, tfrom_file; if (duplicate) complain_about_duplicate(opts,1); if (negated) bad_negation(fullname, FALSE); else if ((op = string_for_opt(opts, FALSE)) != 0) { - roguesymset = (char *)alloc(strlen(op) + 1); - Strcpy(roguesymset, op); - if (!read_sym_file(TRUE)) { + symset[ROGUESET] = (char *)alloc(strlen(op) + 1); + Strcpy(symset[ROGUESET], op); + if (!read_sym_file(ROGUESET)) { badoption(opts); - free((char *)roguesymset); - roguesymset = (char *)0; + free((char *)symset[ROGUESET]); + symset[ROGUESET] = (char *)0; } else { if (!initial && Is_rogue_level(&u.uz)) - assign_rogue_graphics(TRUE); + assign_graphics(ROGUESET); need_redraw = TRUE; } } @@ -1323,14 +1323,14 @@ boolean tinitial, tfrom_file; if (duplicate) complain_about_duplicate(opts,1); if (negated) bad_negation(fullname, FALSE); else if ((op = string_for_opt(opts, FALSE)) != 0) { - symset = (char *)alloc(strlen(op) + 1); - Strcpy(symset, op); - if (!read_sym_file(FALSE)) { + symset[PRIMARY] = (char *)alloc(strlen(op) + 1); + Strcpy(symset[PRIMARY], op); + if (!read_sym_file(PRIMARY)) { badoption(opts); - free((char *)symset); - symset = (char *)0; + free((char *)symset[PRIMARY]); + symset[PRIMARY] = (char *)0; } else { - switch_graphics(TRUE); + switch_symbols(TRUE); need_redraw = TRUE; } } @@ -2288,15 +2288,17 @@ goodfruit: boolean badflag = FALSE; if (duplicate) complain_about_duplicate(opts,1); if (!negated) { - if (symset) badflag = TRUE; + /* There is no rogue level DECgraphics-specific set */ + if (symset[PRIMARY]) + badflag = TRUE; else { - symset = (char *)alloc(strlen(fullname) + 1); - Strcpy(symset, fullname); - if (!read_sym_file(FALSE)) { + symset[PRIMARY] = (char *)alloc(strlen(fullname) + 1); + Strcpy(symset[PRIMARY], fullname); + if (!read_sym_file(PRIMARY)) { badflag = TRUE; - free((char *)symset); - symset = (char *)0; - } else switch_graphics(TRUE); + free((char *)symset[PRIMARY]); + symset[PRIMARY] = (char *)0; + } else switch_symbols(TRUE); } if (badflag) { pline("Failure to load symbol set %s.", @@ -2308,37 +2310,33 @@ goodfruit: } fullname = "IBMgraphics"; if (match_optname(opts, fullname, 10, TRUE)) { + const char *sym_name = fullname; boolean badflag = FALSE; if (duplicate) complain_about_duplicate(opts,1); if (!negated) { - if (symset) badflag = TRUE; - else { - symset = (char *)alloc(strlen(fullname) + 1); - Strcpy(symset, fullname); - if (!read_sym_file(FALSE)) { + for (i = 0; i < NUM_GRAPHICS; ++i) { + if (symset[i]) + badflag = TRUE; + else { + if (i == ROGUESET) sym_name = "RogueIBM"; + symset[i] = (char *)alloc(strlen(sym_name) + 1); + Strcpy(symset[i], sym_name); + if (!read_sym_file(i)) { badflag = TRUE; - free((char *)symset); - symset = (char *)0; - } else switch_graphics(TRUE); + free((char *)symset[i]); + symset[i] = (char *)0; + break; + } + } } -#ifdef REINCARNATION - if (roguesymset) badflag = TRUE; - else { - roguesymset = (char *)alloc(strlen(fullname) + 1); - Strcpy(roguesymset, fullname); - if (!read_sym_file(TRUE)) { - badflag = TRUE; - free((char *)roguesymset); - roguesymset = (char *)0; - } - if (!initial && Is_rogue_level(&u.uz)) - assign_rogue_graphics(TRUE); - } -#endif if (badflag) { pline("Failure to load symbol set %s.", - fullname); + sym_name); wait_synch(); + } else { + switch_symbols(TRUE); + if (!initial && Is_rogue_level(&u.uz)) + assign_graphics(ROGUESET); } } return; @@ -2349,20 +2347,24 @@ goodfruit: boolean badflag = FALSE; if (duplicate) complain_about_duplicate(opts,1); if (!negated) { - if (symset) badflag = TRUE; + if (symset[PRIMARY]) badflag = TRUE; else { - symset = (char *)alloc(strlen(fullname) + 1); - Strcpy(symset, fullname); - if (!read_sym_file(FALSE)) { + symset[PRIMARY] = (char *)alloc(strlen(fullname) + 1); + Strcpy(symset[PRIMARY], fullname); + if (!read_sym_file(PRIMARY)) { badflag = TRUE; - free((char *)symset); - symset = (char *)0; - } else switch_graphics(TRUE); + free((char *)symset[PRIMARY]); + symset[PRIMARY] = (char *)0; + } } if (badflag) { pline("Failure to load symbol set %s.", fullname); wait_synch(); + } else { + switch_symbols(TRUE); + if (!initial && Is_rogue_level(&u.uz)) + assign_graphics(ROGUESET); } } return; @@ -2777,7 +2779,8 @@ doset() return 0; } -struct textlist *symset_list; /* files.c will populate this wil list of available sets */ +struct textlist *symset_list = 0; /* files.c will populate this with + list of available sets */ STATIC_OVL boolean special_handling(optname, setinitial, setfromfile) @@ -3136,34 +3139,29 @@ boolean setinitial,setfromfile; if (pick_cnt >= 0) goto ape_again; } #endif /* AUTOPICKUP_EXCEPTIONS */ -#ifdef ASCIIGRAPH } else if (!strcmp("symset", optname) || - !strcmp("roguesymset", optname)) { + !strcmp("roguesymset", optname)) { menu_item *symset_pick = (menu_item *)0; boolean rogueflag = (*optname == 'r'); char *symset_name; - int chosen = -2; - - /* clear symset/roguesymset as a flag to read_sym_file() to build list */ - if (!rogueflag) { - symset_name = symset; - symset = (char *)0; - } + int chosen = -2, which_set = #ifdef REINCARNATION - if (rogueflag) { - symset_name = roguesymset; - roguesymset = (char *)0; - } + rogueflag ? ROGUESET : #endif + PRIMARY; +#ifdef ASCIIGRAPH + /* clear symset as a flag to read_sym_file() to build list */ + symset_name = symset[which_set]; + symset[which_set] = (char *)0; - if (read_sym_file(rogueflag) && symset_list) { + if (read_sym_file(which_set) && symset_list) { int let = 'a'; struct textlist *sl; tmpwin = create_nhwindow(NHW_MENU); start_menu(tmpwin); any.a_int = 1; add_menu(tmpwin, NO_GLYPH, &any, let++, 0, - ATR_NONE, "NetHack default", MENU_UNSELECTED); + ATR_NONE, "Default Symbols", MENU_UNSELECTED); sl = symset_list; while (sl) { if (sl->text) { @@ -3182,54 +3180,55 @@ boolean setinitial,setfromfile; } destroy_nhwindow(tmpwin); if (chosen > -1) { + /* chose an actual symset name from file */ sl = symset_list; while (sl) { if (sl->idx == chosen) { - if (symset_name) + if (symset_name) { free((genericptr_t)symset_name); - symset_name = (char *)alloc(strlen(sl->text)+1); - Strcpy(symset_name, sl->text); + symset_name = (char *)0; + } + symset[which_set] = (char *)alloc(strlen(sl->text)+1); + Strcpy(symset[which_set], sl->text); } sl = sl->next; } + } else if (chosen == -1) { + /* explicit selection of defaults */ + if (symset_name) free ((genericptr_t)symset_name); + symset_name = (char *)0; } /* clean up */ while (symset_list) { sl = symset_list; if (sl->text) free((genericptr_t)sl->text); symset_list = sl->next; - free((genericptr_t)sl); } symset_list = (struct textlist *)0; } - if(!rogueflag) { - init_l_symbols(); - if (chosen >= 0) { - symset = symset_name; - if (!read_sym_file(FALSE)) { - free((genericptr_t)symset); - symset = (char *)0; - } - } - } -# ifdef REINCARNATION - if (rogueflag) { - init_r_symbols(); - if (chosen >= 0) { - roguesymset = symset_name; - if (!read_sym_file(TRUE)) { - free((genericptr_t)roguesymset); - roguesymset = (char *)0; - } + + /* these set default symbols and clear the handling value */ + if(rogueflag) init_r_symbols(); + else init_l_symbols(); + + if (!symset[which_set] && symset_name) + symset[which_set] = symset_name; + + if (symset[which_set]) { + if (read_sym_file(which_set)) + switch_symbols(TRUE); + else { + free((genericptr_t)symset[which_set]); + symset[which_set] = (char *)0; + return 0; } } + + switch_symbols(TRUE); if (Is_rogue_level(&u.uz)) - assign_rogue_graphics(TRUE); + assign_graphics(ROGUESET); else - assign_rogue_graphics(FALSE); -#else - switch_graphics(TRUE); -# endif + assign_graphics(PRIMARY); need_redraw = TRUE; #endif /*ASCIIGRAPH*/ } else { @@ -3431,7 +3430,8 @@ char *buf; Sprintf(buf, "%s", rolestring(flags.initrace, races, noun)); #ifdef REINCARNATION else if (!strcmp(optname, "roguesymset")) - Sprintf(buf, "%s", roguesymset ? roguesymset : "default"); + Sprintf(buf, "%s", + symset[ROGUESET] ? symset[ROGUESET] : "default"); #endif else if (!strcmp(optname, "role")) Sprintf(buf, "%s", rolestring(flags.initrole, roles, name.m)); @@ -3465,7 +3465,8 @@ char *buf; FEATURE_NOTICE_VER_PATCH); } else if (!strcmp(optname, "symset")) - Sprintf(buf, "%s", symset ? symset : "default"); + Sprintf(buf, "%s", + symset[PRIMARY] ? symset[PRIMARY] : "default"); else if (!strcmp(optname, "tile_file")) Sprintf(buf, "%s", iflags.wc_tile_file ? iflags.wc_tile_file : defopt); else if (!strcmp(optname, "tile_height")) { @@ -3643,35 +3644,19 @@ free_autopickup_exceptions() #ifdef ASCIIGRAPH /* bundle some common usage into one easy-to-use routine */ int -load_symset(s, rogueflag) +load_symset(s, which_set) const char *s; -boolean rogueflag; +int which_set; { -#ifdef REINCARNATION - if (rogueflag) { - if (roguesymset) free((genericptr_t)roguesymset); - roguesymset = (char *)alloc(strlen(s)+1); - Strcpy(roguesymset,s); - if (read_sym_file(TRUE)) - switch_graphics(TRUE); - else { - free((genericptr_t)roguesymset); - roguesymset = (char *)0; - return 0; - } - } -#endif - if (!rogueflag) { - if (symset) free((genericptr_t)symset); - symset = (char *)alloc(strlen(s)+1); - Strcpy(symset,s); - if (read_sym_file(FALSE)) - switch_graphics(TRUE); - else { - free((genericptr_t)symset); - symset = (char *)0; - return 0; - } + if (symset[which_set]) free((genericptr_t)symset[which_set]); + symset[which_set] = (char *)alloc(strlen(s)+1); + Strcpy(symset[which_set],s); + if (read_sym_file(which_set)) + switch_symbols(TRUE); + else { + free((genericptr_t)symset[which_set]); + symset[which_set] = (char *)0; + return 0; } return 1; } diff --git a/src/restore.c b/src/restore.c index 55f66a7c0..bd75a9285 100644 --- a/src/restore.c +++ b/src/restore.c @@ -822,7 +822,7 @@ register int fd; if (!wizard && !discover) (void) delete_savefile(); #ifdef REINCARNATION - if (Is_rogue_level(&u.uz)) assign_rogue_graphics(TRUE); + if (Is_rogue_level(&u.uz)) assign_graphics(ROGUESET); #endif #ifdef USE_TILES substitute_tiles(&u.uz); diff --git a/sys/msdos/schema3.MSC b/sys/msdos/schema3.MSC index 7b6e7c885..bcff691ee 100644 --- a/sys/msdos/schema3.MSC +++ b/sys/msdos/schema3.MSC @@ -37,7 +37,7 @@ functions:11 _align_gname functions:12 _altar_wrath _Amonnam _amulet _Amulet_off _Amulet_on _An _an _angry_guards functions:13 _angry_priest _angry_shk_exists _any_light_source _aobjnam _append_slash _append_str _Armor_gone _Armor_off functions:14 _Armor_on _armor_to_dragon _armoroff _arti_invoke _artifact_exists _artifact_hit _artifact_name _artiname -functions:15 _artitouch _askchain _assign_graphics _assign_level _assign_rnd_level _assign_rogue_graphics _assign_soundcard _assign_video +functions:15 _artitouch _askchain _assign_level _assign_rnd_level _assign_graphics _assign_soundcard _assign_video functions:16 _assign_videocolors _assign_videoshades _assigninvlet _at_dgn_entrance _attach_egg_hatch_timeout _attack _attack_checks _attacks functions:17 _awaken_monsters _awaken_soldiers functions:18 _backfire _backsp _bad_location _bad_negation _bad_rock _badoption _bail _ballfall @@ -246,7 +246,7 @@ functions:220 _spoteffects _squadmon _srandom _stackobj _standoutbeg _standouten functions:221 _start_engulf _start_timer _start_tin _steal _steal_it _stealamulet _stealarm _stealgold functions:223 _stop_timer _store_version _strange_feeling _strategy _string_for_env_opt _string_for_opt _strncmpi _strprepend functions:224 _strstri _study_book _stumble_onto_mimic _sub_one_frombill _subfrombill _substitute_tiles _summon_minion _surface -functions:225 _swallow_to_glyph _swapin_file _swapout_oldest _switch_graphics _switchar _t_warn +functions:225 _swallow_to_glyph _swapin_file _swapout_oldest _switch_symbols _switchar _t_warn functions:226 _tabexpand _tactics _take_gold _take_off _tamedog _target_on _tele _tele_jump_ok functions:227 _tele_restrict _tele_trap _teleds _teleok _teleport_pet _temple_occupied _tended_shop _term_end_attr functions:228 _term_end_color diff --git a/sys/msdos/vidvga.c b/sys/msdos/vidvga.c index f96f78238..93916472f 100644 --- a/sys/msdos/vidvga.c +++ b/sys/msdos/vidvga.c @@ -547,7 +547,7 @@ boolean on; { /* vga_HideCursor(); */ if (on) { -/* switch_graphics(DEFAULT_GRAPHICS); */ +/* switch_symbols(FALSE); */ iflags.traditional_view = TRUE; clipx = 0; clipxmax = CO - 1; diff --git a/sys/share/pcmain.c b/sys/share/pcmain.c index 680224d34..ba185867d 100644 --- a/sys/share/pcmain.c +++ b/sys/share/pcmain.c @@ -307,11 +307,11 @@ char *argv[]; #if defined(MSDOS) || defined(WIN32) /* Player didn't specify any symbol set so use IBM defaults */ - if (!symset) { + if (!symset[PRIMARY]) { load_symset("IBMGraphics_2", PRIMARY); } # ifdef REINCARNATION - if (!roguesymset) { + if (!symset[ROGUESET]) { load_symset("RogueEpyx", ROGUESET); } # endif @@ -551,7 +551,7 @@ char *argv[]; # ifdef ASCIIGRAPH load_symset("IBMGraphics", PRIMARY); load_symset("RogueIBM", ROGUESET); - switch_graphics(TRUE); + switch_symbols(TRUE); # endif } break; @@ -560,7 +560,7 @@ char *argv[]; if (!strncmpi(argv[0]+1, "DEC", 3)) { # ifdef ASCIIGRAPH load_symset("DECGraphics", PRIMARY); - switch_graphics(TRUE); + switch_symbols(TRUE); # endif } break; diff --git a/sys/share/unixtty.c b/sys/share/unixtty.c index 133cb6ea1..72d474b1d 100644 --- a/sys/share/unixtty.c +++ b/sys/share/unixtty.c @@ -368,7 +368,7 @@ init_sco_cons() # ifdef ASCIIGRAPH load_symset("IBMGraphics", PRIMARY); load_symset("RogueIBM", ROGUESET); - switch_graphics(TRUE); + switch_symbols(TRUE); # endif # ifdef TEXTCOLOR if (has_colors()) diff --git a/sys/unix/unixmain.c b/sys/unix/unixmain.c index 29e270f94..209df0922 100644 --- a/sys/unix/unixmain.c +++ b/sys/unix/unixmain.c @@ -373,7 +373,7 @@ char *argv[]; #ifdef ASCIIGRAPH load_symset("IBMGraphics", PRIMARY); load_symset("RogueIBM", ROGUESET); - switch_graphics(TRUE); + switch_symbols(TRUE); #endif } break; @@ -382,7 +382,7 @@ char *argv[]; if (!strncmpi(argv[0]+1, "DEC", 3)) { #ifdef ASCIIGRAPH load_symset("DECGraphics", PRIMARY); - switch_graphics(TRUE); + switch_symbols(TRUE); #endif } break; diff --git a/sys/vms/vmsmain.c b/sys/vms/vmsmain.c index a3701aa89..9e077af44 100644 --- a/sys/vms/vmsmain.c +++ b/sys/vms/vmsmain.c @@ -272,7 +272,7 @@ char *argv[]; #ifdef ASCIIGRAPH load_symset("IBMGraphics", PRIMARY); load_symset("RogueIBM", ROGUESET); - switch_graphics(TRUE); + switch_symbols(TRUE); #endif } break; @@ -281,7 +281,7 @@ char *argv[]; if (!strncmpi(argv[0]+1, "DEC", 3)) { #ifdef ASCIIGRAPH load_symset("DECGraphics", PRIMARY); - switch_graphics(TRUE); + switch_symbols(TRUE); #endif } break;