From: nethack.allison Date: Mon, 2 Oct 2006 13:15:50 +0000 (+0000) Subject: symbol preprocessing (trunk only) X-Git-Tag: MOVE2GIT~864 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=084dce82d056e0357c8e26b48101ecdeae412c3b;p=nethack symbol preprocessing (trunk only) Clean up the preprocessing associated with the loadable symbol stuff. Base it on new LOADSYMSETS, rather than on the previously existing ASCIIGRAPH preprocessor define. --- diff --git a/include/config.h b/include/config.h index 0aa825656..8b54d1d67 100644 --- a/include/config.h +++ b/include/config.h @@ -355,6 +355,8 @@ typedef unsigned char uchar; * complexity of the game but also to the size of the load module. */ +/* display features */ +#define LOADSYMSETS /* loadable symbol sets; only default symbols w/o this */ /* dungeon features */ #define SINKS /* Kitchen sinks - Janet Walz */ /* dungeon levels */ diff --git a/include/extern.h b/include/extern.h index c5267f664..5febadf0e 100644 --- a/include/extern.h +++ b/include/extern.h @@ -499,8 +499,8 @@ E void NDECL(init_r_symbols); E void NDECL(init_symbols); E void NDECL(init_showsyms); E void NDECL(init_l_symbols); +#ifdef LOADSYMSETS E void FDECL(clear_symsetentry, (int,BOOLEAN_P)); -#ifdef ASCIIGRAPH E void FDECL(update_l_symset, (struct symparse *,int)); E void FDECL(update_r_symset, (struct symparse *,int)); #endif @@ -718,7 +718,7 @@ E void FDECL(check_recordfile, (const char *)); #if defined(WIZARD) E void NDECL(read_wizkit); #endif -#ifdef ASCIIGRAPH +#ifdef LOADSYMSETS E int FDECL(read_sym_file, (int)); E int FDECL(parse_sym_line, (char *,int)); #endif @@ -1536,7 +1536,7 @@ E void FDECL(set_option_mod_status, (const char *,int)); E int FDECL(add_autopickup_exception, (const char *)); E void NDECL(free_autopickup_exceptions); #endif /* AUTOPICKUP_EXCEPTIONS */ -#ifdef ASCIIGRAPH +#ifdef LOADSYMSETS E int FDECL(load_symset, (const char *,int)); E void FDECL(parsesymbols, (char *)); E struct symparse *FDECL(match_sym, (char *)); diff --git a/include/rm.h b/include/rm.h index 28ae5bb34..244bcc86a 100644 --- a/include/rm.h +++ b/include/rm.h @@ -273,7 +273,11 @@ extern struct symsetentry symset[NUM_GRAPHICS]; /* from drawing.c */ extern int currentgraphics; /* from drawing.c */ extern uchar showsyms[]; +#ifdef LOADSYMSETS #define SYMHANDLING(ht) (symset[currentgraphics].handling == (ht)) +#else +#define SYMHANDLING(ht) ((ht) == H_UNK) +#endif /* * The 5 possible states of doors diff --git a/include/tcap.h b/include/tcap.h index 074a818d8..232fd0a76 100644 --- a/include/tcap.h +++ b/include/tcap.h @@ -12,7 +12,7 @@ #endif /* might display need graphics code? */ -#if !defined(AMIGA) && !defined(TOS) && !defined(MAC) && !defined(ASCIIGRAPH) +#if !defined(AMIGA) && !defined(TOS) && !defined(MAC) # if defined(TERMLIB) || defined(OS2) || defined(MSDOS) # define ASCIIGRAPH # endif diff --git a/include/unixconf.h b/include/unixconf.h index d003b6ef1..56c85a2cc 100644 --- a/include/unixconf.h +++ b/include/unixconf.h @@ -56,7 +56,6 @@ #define TEXTCOLOR /* Use System V r3.2 terminfo color support */ /* and/or ANSI color support on termcap systems */ /* and/or X11 color */ -#define ASCIIGRAPH /* ASCII graphics support on terminals */ #define POSIX_JOB_CONTROL /* use System V / Solaris 2.x / POSIX job control */ /* (e.g., VSUSP) */ #define POSIX_TYPES /* use POSIX types for system calls and termios */ diff --git a/include/vmsconf.h b/include/vmsconf.h index 4382fb69b..ba9ca9a46 100644 --- a/include/vmsconf.h +++ b/include/vmsconf.h @@ -74,11 +74,6 @@ */ #define DLB /* use data librarian code */ -/* - * Needed to support DECgraphics and/or IBMgraphics display styles. - */ -#define ASCIIGRAPH /* ASCII graphics support on terminals */ - /* * You may define TEXTCOLOR if your system has any terminals that recognize * ANSI color sequences of the form ``[#;#m'', where the first # is diff --git a/src/drawing.c b/src/drawing.c index d9b726de3..0f69eeb32 100644 --- a/src/drawing.c +++ b/src/drawing.c @@ -17,7 +17,10 @@ #define C(n) #endif +#ifdef LOADSYMSETS struct symsetentry symset[NUM_GRAPHICS]; +#endif + int currentgraphics = 0; uchar showsyms[SYM_MAX] = DUMMY; /* symbols to be displayed */ @@ -344,33 +347,6 @@ def_char_to_monclass(ch) * */ -void -switch_symbols(nondefault) -int nondefault; -{ -#ifdef ASCIIGRAPH - register int i; - - if (nondefault) { - for (i = 0; i < SYM_MAX; i++) - showsyms[i] = l_syms[i]; -# ifdef PC9800 - if (SYMHANDLING(H_IBM) - && ibmgraphics_mode_callback) - (*ibmgraphics_mode_callback)(); - else if (!symset[currentgraphics].name && ascgraphics_mode_callback) - (*ascgraphics_mode_callback)(); -# endif -# ifdef TERMLIB - if (SYMHANDLING(H_DEC) - && decgraphics_mode_callback) - (*decgraphics_mode_callback)(); -# endif - } else -#endif - init_symbols(); -} - void init_symbols() { @@ -431,7 +407,9 @@ init_l_symbols() l_syms[i + SYM_OFF_X] = DEF_INVISIBLE; } +#ifdef LOADSYMSETS clear_symsetentry(PRIMARY, FALSE); +#endif } #ifdef REINCARNATION @@ -464,11 +442,13 @@ init_r_symbols() r_syms[i + SYM_OFF_X] = DEF_INVISIBLE; } +# ifdef LOADSYMSETS clear_symsetentry(ROGUESET, FALSE); symset[ROGUESET].nocolor = 1; /* default on Rogue level is no color * but some symbol sets can * override that */ +# endif } #endif /*REINCARNATION*/ @@ -506,7 +486,32 @@ int whichset; } } -#ifdef ASCIIGRAPH +void +switch_symbols(nondefault) +int nondefault; +{ + register int i; + + if (nondefault) { + for (i = 0; i < SYM_MAX; i++) + showsyms[i] = l_syms[i]; +# ifdef PC9800 + if (SYMHANDLING(H_IBM) + && ibmgraphics_mode_callback) + (*ibmgraphics_mode_callback)(); + else if (!symset[currentgraphics].name && ascgraphics_mode_callback) + (*ascgraphics_mode_callback)(); +# endif +# ifdef TERMLIB + if (SYMHANDLING(H_DEC) + && decgraphics_mode_callback) + (*decgraphics_mode_callback)(); +# endif + } else + init_symbols(); +} + +#ifdef LOADSYMSETS void update_l_symset(symp, val) struct symparse *symp; @@ -737,7 +742,7 @@ struct symparse loadsyms[] = { {SYM_OTH, SYM_INVISIBLE + SYM_OFF_X, "S_invisible"}, {0,0,(const char *)0} /* fence post */ }; -#endif /*ASCIIGRAPH*/ +#endif /*LOADSYMSETS*/ /*drawing.c*/ diff --git a/src/files.c b/src/files.c index 457706c25..92f740b7e 100644 --- a/src/files.c +++ b/src/files.c @@ -185,7 +185,7 @@ STATIC_DCL char *FDECL(make_lockname, (const char *,char *)); STATIC_DCL FILE *FDECL(fopen_config_file, (const char *)); STATIC_DCL int FDECL(get_uchars, (FILE *,char *,char *,uchar *,BOOLEAN_P,int,const char *)); int FDECL(parse_config_line, (FILE *,char *,char *,char *)); -#ifdef ASCIIGRAPH +#ifdef LOADSYMSETS STATIC_DCL FILE *NDECL(fopen_sym_file); STATIC_DCL void FDECL(set_symhandling, (char *,int)); #endif @@ -2057,6 +2057,10 @@ char *tmp_levels; WARNCOUNT, "WARNINGS"); assign_warnings(translate); } else if (match_varname(buf, "SYMBOLS", 4)) { + /* This part is not ifdef LOADSYMSETS because we want to be able + * to silently ignore its presence in a config file if that is + * not defined. + */ char *op, symbuf[BUFSZ]; boolean morelines; do { @@ -2075,11 +2079,10 @@ char *tmp_levels; /* strip trailing space now that '\' is gone */ while (--op >= bufp && isspace(*op)) *op = '\0'; } - -#ifdef ASCIIGRAPH +#ifdef LOADSYMSETS /* parse here */ parsesymbols(bufp); -#endif /*ASCIIGRAPH*/ +#endif if (morelines) do { *symbuf = '\0'; @@ -2090,9 +2093,9 @@ char *tmp_levels; bufp = symbuf; } while (*bufp == '#'); } while (morelines); -#ifdef ASCIIGRAPH +#ifdef LOADSYMSETS switch_symbols(TRUE); -#endif /*ASCIIGRAPH*/ +#endif #ifdef WIZARD } else if (match_varname(buf, "WIZKIT", 6)) { (void) strncpy(wizkit, bufp, WIZKIT_MAX-1); @@ -2422,7 +2425,7 @@ read_wizkit() #endif /*WIZARD*/ -#ifdef ASCIIGRAPH +#ifdef LOADSYMSETS extern struct symsetentry *symset_list; /* options.c */ extern struct symparse loadsyms[]; /* drawing.c */ extern const char *known_handling[]; /* drawing.c */ @@ -2570,9 +2573,9 @@ int which_set; if (!strcmpi(bufp, symset[which_set].name)) { /* matches desired one */ chosen_symset_start = TRUE; -#ifdef REINCARNATION +# ifdef REINCARNATION if (which_set == ROGUESET) init_r_symbols(); -#endif +# endif if (which_set == PRIMARY) init_l_symbols(); } break; @@ -2606,11 +2609,11 @@ int which_set; } else { /* !SYM_CONTROL */ val = sym_val(bufp); if (chosen_symset_start) { -#ifdef REINCARNATION +# ifdef REINCARNATION if (which_set == ROGUESET) update_r_symset(symp, val); else -#endif +# endif update_l_symset(symp, val); } } @@ -2634,7 +2637,7 @@ int which_set; i++; } } -#endif /*ASCIIGRAPH*/ +#endif /*LOADSYMSETS*/ /* ---------- END CONFIG FILE HANDLING ----------- */ diff --git a/src/mapglyph.c b/src/mapglyph.c index cf6b4697e..be382f373 100644 --- a/src/mapglyph.c +++ b/src/mapglyph.c @@ -32,7 +32,7 @@ int explcolors[] = { #define pet_color(n) color = iflags.use_color ? mons[n].mcolor : NO_COLOR #define warn_color(n) color = iflags.use_color ? def_warnsyms[n].color : NO_COLOR #define explode_color(n) color = iflags.use_color ? explcolors[n] : NO_COLOR -# if defined(REINCARNATION) && defined(ASCIIGRAPH) +# if defined(REINCARNATION) && defined(LOADSYMSETS) # define ROGUE_COLOR # endif diff --git a/src/options.c b/src/options.c index 9463c58af..81af6d972 100644 --- a/src/options.c +++ b/src/options.c @@ -333,10 +333,19 @@ static struct Comp_Opt #ifdef MSDOS { "soundcard", "type of sound card to use", 20, SET_IN_FILE }, #endif - { "symset", "load a set of display symbols from the symbols file", 70, SET_IN_GAME }, + { "symset", "load a set of display symbols from the symbols file", 70, +#ifdef LOADSYMSETS + SET_IN_GAME }, +#else + DISP_IN_GAME}, +#endif { "roguesymset", "load a set of rogue display symbols from the symbols file", 70, #ifdef REINCARNATION +# ifdef LOADSYMSETS SET_IN_GAME }, +# else + DISP_IN_GAME}, +# endif #else SET_IN_FILE }, #endif @@ -608,7 +617,7 @@ initoptions() */ /* this detects the IBM-compatible console on most 386 boxes */ if ((opts = nh_getenv("TERM")) && !strncmp(opts, "AT", 2)) { -#ifdef ASCIIGRAPH +#ifdef LOADSYMSETS if (!symset[PRIMARY].name) load_symset("IBMGraphics", PRIMARY); if (!symset[ROGUESET].name) load_symset("RogueIBM", ROGUESET); @@ -626,10 +635,10 @@ initoptions() if ((opts = nh_getenv("TERM")) && !strncmpi(opts, "vt", 2) && AS && AE && index(AS, '\016') && index(AE, '\017')) { -# ifdef ASCIIGRAPH +# ifdef LOADSYMSETS if (!symset[PRIMARY].name) load_symset("DECGraphics", PRIMARY); switch_symbols(TRUE); -# endif /*ASCIIGRAPH*/ +# endif /*LOADSYMSETS*/ } # endif #endif /* UNIX || VMS */ @@ -1294,7 +1303,7 @@ boolean tinitial, tfrom_file; fullname = "roguesymset"; if (match_optname(opts, fullname, 7, TRUE)) { -#if defined(REINCARNATION) && defined(ASCIIGRAPH) +#if defined(REINCARNATION) && defined(LOADSYMSETS) if (duplicate) complain_about_duplicate(opts,1); if (negated) bad_negation(fullname, FALSE); else if ((op = string_for_opt(opts, FALSE)) != 0) { @@ -1317,7 +1326,7 @@ boolean tinitial, tfrom_file; fullname = "symset"; if (match_optname(opts, fullname, 6, TRUE)) { -#ifdef ASCIIGRAPH +#ifdef LOADSYMSETS if (duplicate) complain_about_duplicate(opts,1); if (negated) bad_negation(fullname, FALSE); else if ((op = string_for_opt(opts, FALSE)) != 0) { @@ -1483,9 +1492,9 @@ boolean tinitial, tfrom_file; ) { int color_number, color_incr; -#ifndef WIN32CON +# ifndef WIN32CON if (duplicate) complain_about_duplicate(opts,1); -#endif +# endif # ifdef MAC if (match_optname(opts, "hicolor", 3, TRUE)) { if (negated) { @@ -1605,6 +1614,7 @@ goodfruit: else warning_opts(opts, fullname); return; } + #ifdef BACKWARD_COMPAT /* boulder:symbol */ fullname = "boulder"; @@ -2280,11 +2290,11 @@ goodfruit: } #endif -#ifdef ASCIIGRAPH -# if defined(BACKWARD_COMPAT) +#if defined(BACKWARD_COMPAT) fullname = "DECgraphics"; if (match_optname(opts, fullname, 10, TRUE)) { boolean badflag = FALSE; +# ifdef LOADSYMSETS if (duplicate) complain_about_duplicate(opts,1); if (!negated) { /* There is no rogue level DECgraphics-specific set */ @@ -2304,12 +2314,14 @@ goodfruit: wait_synch(); } } +# endif /*LOADSYMSETS*/ return; } fullname = "IBMgraphics"; if (match_optname(opts, fullname, 10, TRUE)) { const char *sym_name = fullname; boolean badflag = FALSE; +# ifdef LOADSYMSETS if (duplicate) complain_about_duplicate(opts,1); if (!negated) { for (i = 0; i < NUM_GRAPHICS; ++i) { @@ -2338,12 +2350,15 @@ goodfruit: # endif } } +# endif /*LOADSYMSETS*/ return; } -# ifdef MAC_GRAPHICS_ENV +#endif +#ifdef MAC_GRAPHICS_ENV fullname = "MACgraphics"; if (match_optname(opts, fullname, 11, TRUE)) { boolean badflag = FALSE; +# ifdef LOADSYMSETS if (duplicate) complain_about_duplicate(opts,1); if (!negated) { if (symset[PRIMARY]).name badflag = TRUE; @@ -2365,10 +2380,9 @@ goodfruit: assign_graphics(ROGUESET); } } +# endif /*LOADSYMSETS*/ return; } -# endif -# endif #endif /* OK, if we still haven't recognized the option, check the boolean * options list @@ -2776,8 +2790,10 @@ doset() return 0; } +#ifdef LOADSYMSETS struct symsetentry *symset_list = 0; /* files.c will populate this with list of available sets */ +#endif STATIC_OVL boolean special_handling(optname, setinitial, setfromfile) @@ -3140,9 +3156,12 @@ boolean setinitial,setfromfile; !strcmp("roguesymset", optname)) { menu_item *symset_pick = (menu_item *)0; boolean rogueflag = (*optname == 'r'); - struct symsetentry *sl; +#ifdef LOADSYMSETS + int res; char *symset_name, fmtstr[20]; - int chosen = -2, res, which_set = + struct symsetentry *sl; +#endif + int chosen = -2, which_set = #ifdef REINCARNATION rogueflag ? ROGUESET : #endif @@ -3150,7 +3169,7 @@ boolean setinitial,setfromfile; #ifndef REINCARNATION if (rogueflag) return TRUE; #endif -#ifdef ASCIIGRAPH +#ifdef LOADSYMSETS /* clear symset[].name as a flag to read_sym_file() to build list */ symset_name = symset[which_set].name; symset[which_set].name = (char *)0; @@ -3275,7 +3294,7 @@ boolean setinitial,setfromfile; # endif assign_graphics(PRIMARY); need_redraw = TRUE; -#endif /*ASCIIGRAPH*/ +#endif /*LOADSYMSETS*/ } else { /* didn't match any of the special options */ return FALSE; @@ -3477,8 +3496,11 @@ char *buf; #ifdef REINCARNATION else if (!strcmp(optname, "roguesymset")) Sprintf(buf, "%s", +# ifdef LOADSYMSETS symset[ROGUESET].name ? - symset[ROGUESET].name : "default"); + symset[ROGUESET].name : +# endif + "default"); #endif else if (!strcmp(optname, "role")) Sprintf(buf, "%s", rolestring(flags.initrole, roles, name.m)); @@ -3513,8 +3535,11 @@ char *buf; } else if (!strcmp(optname, "symset")) Sprintf(buf, "%s", +#ifdef LOADSYMSETS symset[PRIMARY].name ? - symset[PRIMARY].name : "default"); + symset[PRIMARY].name : +#endif + "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")) { @@ -3689,7 +3714,8 @@ free_autopickup_exceptions() } } #endif /* AUTOPICKUP_EXCEPTIONS */ -#ifdef ASCIIGRAPH + +#ifdef LOADSYMSETS /* bundle some common usage into one easy-to-use routine */ int load_symset(s, which_set) @@ -3776,7 +3802,7 @@ char *strval; escapes(strval, buf); return (int)*buf; } -#endif +#endif /*LOADSYMSETS*/ /* data for option_help() */ static const char *opt_intro[] = { diff --git a/sys/share/pcmain.c b/sys/share/pcmain.c index cfd683a0e..7b12a0985 100644 --- a/sys/share/pcmain.c +++ b/sys/share/pcmain.c @@ -305,17 +305,19 @@ char *argv[]; process_options(argc, argv); #endif -#if defined(MSDOS) || defined(WIN32) +#ifdef LOADSYMSETS +# if defined(MSDOS) || defined(WIN32) /* Player didn't specify any symbol set so use IBM defaults */ if (!symset[PRIMARY].name) { load_symset("IBMGraphics_2", PRIMARY); } -# ifdef REINCARNATION +# ifdef REINCARNATION if (!symset[ROGUESET].name) { load_symset("RogueEpyx", ROGUESET); } +# endif # endif -#endif +#endif /*LOADSYMSETS*/ #ifdef MSDOS init_nhwindows(&argc,argv); @@ -548,7 +550,7 @@ char *argv[]; case 'I': case 'i': if (!strncmpi(argv[0]+1, "IBM", 3)) { -# ifdef ASCIIGRAPH +# ifdef LOADSYMSETS load_symset("IBMGraphics", PRIMARY); load_symset("RogueIBM", ROGUESET); switch_symbols(TRUE); @@ -558,7 +560,7 @@ char *argv[]; /* case 'D': */ case 'd': if (!strncmpi(argv[0]+1, "DEC", 3)) { -# ifdef ASCIIGRAPH +# ifdef LOADSYMSETS load_symset("DECGraphics", PRIMARY); switch_symbols(TRUE); # endif diff --git a/sys/share/unixtty.c b/sys/share/unixtty.c index 72d474b1d..0c677efab 100644 --- a/sys/share/unixtty.c +++ b/sys/share/unixtty.c @@ -365,7 +365,7 @@ init_sco_cons() if (!strcmp(windowprocs.name, "tty") && sco_flag_console) { atexit(sco_mapon); sco_mapoff(); -# ifdef ASCIIGRAPH +# ifdef LOADSYMSETS load_symset("IBMGraphics", PRIMARY); load_symset("RogueIBM", ROGUESET); switch_symbols(TRUE); diff --git a/sys/unix/unixmain.c b/sys/unix/unixmain.c index 209df0922..54dd91f96 100644 --- a/sys/unix/unixmain.c +++ b/sys/unix/unixmain.c @@ -370,7 +370,7 @@ char *argv[]; case 'I': case 'i': if (!strncmpi(argv[0]+1, "IBM", 3)) { -#ifdef ASCIIGRAPH +#ifdef LOADSYMSETS load_symset("IBMGraphics", PRIMARY); load_symset("RogueIBM", ROGUESET); switch_symbols(TRUE); @@ -380,7 +380,7 @@ char *argv[]; /* case 'D': */ case 'd': if (!strncmpi(argv[0]+1, "DEC", 3)) { -#ifdef ASCIIGRAPH +#ifdef LOADSYMSETS load_symset("DECGraphics", PRIMARY); switch_symbols(TRUE); #endif diff --git a/sys/vms/vmsmain.c b/sys/vms/vmsmain.c index 9e077af44..1124411c4 100644 --- a/sys/vms/vmsmain.c +++ b/sys/vms/vmsmain.c @@ -269,7 +269,7 @@ char *argv[]; case 'I': case 'i': if (!strncmpi(argv[0]+1, "IBM", 3)) { -#ifdef ASCIIGRAPH +#ifdef LOADSYMSETS load_symset("IBMGraphics", PRIMARY); load_symset("RogueIBM", ROGUESET); switch_symbols(TRUE); @@ -279,7 +279,7 @@ char *argv[]; /* case 'D': */ case 'd': if (!strncmpi(argv[0]+1, "DEC", 3)) { -#ifdef ASCIIGRAPH +#ifdef LOADSYMSETS load_symset("DECGraphics", PRIMARY); switch_symbols(TRUE); #endif