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.
This commit is contained in:
nethack.allison
2006-10-02 13:15:50 +00:00
parent 58a1828f18
commit 084dce82d0
14 changed files with 119 additions and 83 deletions

View File

@@ -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*/

View File

@@ -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 ----------- */

View File

@@ -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

View File

@@ -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[] = {