symset properties (trunk only)
Pat Rankin wrote: > Symbol set definitions need a description attribute, above and > beyond allowing comments in the file, for inclusion in the 'O' > command's menu entries for selecting them. [...] > mapglyph.c isn't the proper place to decide whether to define > ROGUE_COLOR. That may need to become a symbol attribute, > which we'd then specify on the Epyx rogue set(s). Implement both of the suggestions above.
This commit is contained in:
@@ -189,7 +189,9 @@ start: RogueIBM
|
||||
finish
|
||||
|
||||
start: RogueEpyx
|
||||
Description: Rogue level color symbol set like Epyx Rogue
|
||||
Handling: IBM
|
||||
Color: Yes
|
||||
S_weapon: \x18 # up arrow
|
||||
S_armor: \x0a # Vert rect with o
|
||||
S_ring: \x09 # circle with arrow
|
||||
|
||||
@@ -499,6 +499,7 @@ E void NDECL(init_r_symbols);
|
||||
E void NDECL(init_symbols);
|
||||
E void NDECL(init_disp_symbols);
|
||||
E void NDECL(init_l_symbols);
|
||||
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));
|
||||
|
||||
20
include/rm.h
20
include/rm.h
@@ -234,11 +234,15 @@ struct symparse {
|
||||
const char *name;
|
||||
};
|
||||
|
||||
/* general linked list of text pointers */
|
||||
struct textlist {
|
||||
char *text; /* the text */
|
||||
int idx; /* an index value */
|
||||
struct textlist *next; /* next in list */
|
||||
/* linked list of symsets and their characteristics */
|
||||
struct symsetentry {
|
||||
struct symsetentry *next; /* next in list */
|
||||
char *name; /* ptr to symset name */
|
||||
char *desc; /* ptr to description */
|
||||
int idx; /* an index value */
|
||||
int handling; /* known handlers value */
|
||||
Bitfield(nocolor,1); /* don't use color if set */
|
||||
/* 7 free bits */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -261,10 +265,10 @@ struct textlist {
|
||||
extern const struct symdef defsyms[MAXPCHARS]; /* defaults */
|
||||
extern uchar showsyms[MAXPCHARS];
|
||||
extern const struct symdef def_warnsyms[WARNCOUNT];
|
||||
extern char *symset[NUM_GRAPHICS]; /* from drawing.c */
|
||||
extern int symhandling[NUM_GRAPHICS], currentgraphics; /* from drawing.c */
|
||||
extern struct symsetentry symset[NUM_GRAPHICS]; /* from drawing.c */
|
||||
extern int currentgraphics; /* from drawing.c */
|
||||
|
||||
#define SYMHANDLING(ht) (symhandling[currentgraphics] == (ht))
|
||||
#define SYMHANDLING(ht) (symset[currentgraphics].handling == (ht))
|
||||
|
||||
/*
|
||||
* The 5 possible states of doors
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
#define C(n)
|
||||
#endif
|
||||
|
||||
char *symset[NUM_GRAPHICS] = {0,0};
|
||||
int symhandling[NUM_GRAPHICS] = {0,0}, currentgraphics = 0;
|
||||
struct symsetentry symset[NUM_GRAPHICS];
|
||||
int currentgraphics = 0;
|
||||
|
||||
uchar oc_syms[MAXOCLASSES] = DUMMY; /* the current object display symbols */
|
||||
uchar showsyms[MAXPCHARS] = DUMMY; /* the current feature display symbols */
|
||||
@@ -380,7 +380,7 @@ int nondefault;
|
||||
if (SYMHANDLING(H_IBM)
|
||||
&& ibmgraphics_mode_callback)
|
||||
(*ibmgraphics_mode_callback)();
|
||||
else if (!symset[currentgraphics] && ascgraphics_mode_callback)
|
||||
else if (!symset[currentgraphics].name && ascgraphics_mode_callback)
|
||||
(*ascgraphics_mode_callback)();
|
||||
# endif
|
||||
# ifdef TERMLIB
|
||||
@@ -430,19 +430,19 @@ init_l_symbols()
|
||||
|
||||
for (i = 0; i < MAXOCLASSES; i++)
|
||||
l_oc_syms[i] = def_oc_syms[i].sym;
|
||||
symhandling[PRIMARY] = H_UNK;
|
||||
clear_symsetentry(PRIMARY, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
assign_graphics(whichset)
|
||||
int whichset;
|
||||
{
|
||||
/* Adjust graphics display characters on Rogue levels */
|
||||
register int i;
|
||||
|
||||
switch(whichset) {
|
||||
# ifdef REINCARNATION
|
||||
case ROGUESET:
|
||||
/* Adjust graphics display characters on Rogue levels */
|
||||
|
||||
for (i = 0; i < MAXMCLASSES; i++)
|
||||
monsyms[i] = r_monsyms[i];
|
||||
@@ -496,7 +496,11 @@ init_r_symbols()
|
||||
for (i = 0; i < MAXOCLASSES; i++)
|
||||
r_oc_syms[i] = def_r_oc_syms[i];
|
||||
|
||||
symhandling[ROGUESET] = H_UNK;
|
||||
clear_symsetentry(ROGUESET, FALSE);
|
||||
symset[ROGUESET].nocolor = 1; /* default on Rogue level is no color
|
||||
* but some symbol sets can
|
||||
* override that
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
@@ -545,6 +549,25 @@ int val;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
clear_symsetentry(which_set, name_too)
|
||||
int which_set;
|
||||
boolean name_too;
|
||||
{
|
||||
if (symset[which_set].desc)
|
||||
free((genericptr_t)symset[which_set].desc);
|
||||
symset[which_set].desc = (char *)0;
|
||||
|
||||
symset[which_set].nocolor = 0;
|
||||
symset[which_set].handling = H_UNK;
|
||||
|
||||
if (name_too) {
|
||||
if (symset[which_set].name)
|
||||
free((genericptr_t *)symset[which_set].name);
|
||||
symset[which_set].name = (char *)0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If you are adding code somewhere to be able to recognize
|
||||
* particular types of symset "handling", define a
|
||||
@@ -564,6 +587,9 @@ struct symparse loadsyms[] = {
|
||||
{SYM_CONTROL, 0, "begin"},
|
||||
{SYM_CONTROL, 1, "finish"},
|
||||
{SYM_CONTROL, 2, "handling"},
|
||||
{SYM_CONTROL, 3, "description"},
|
||||
{SYM_CONTROL, 4, "color"},
|
||||
{SYM_CONTROL, 4, "colour"},
|
||||
{SYM_PCHAR, S_stone, "S_stone"},
|
||||
{SYM_PCHAR, S_vwall, "S_vwall"},
|
||||
{SYM_PCHAR, S_hwall, "S_hwall"},
|
||||
|
||||
64
src/files.c
64
src/files.c
@@ -2421,7 +2421,7 @@ read_wizkit()
|
||||
#endif /*WIZARD*/
|
||||
|
||||
#ifdef ASCIIGRAPH
|
||||
extern struct textlist *symset_list; /* options.c */
|
||||
extern struct symsetentry *symset_list; /* options.c */
|
||||
extern struct symparse loadsyms[]; /* drawing.c */
|
||||
extern const char *known_handling[]; /* drawing.c */
|
||||
static int symset_count = 0; /* for pick-list building only */
|
||||
@@ -2460,10 +2460,11 @@ int which_set;
|
||||
}
|
||||
(void) fclose(fp);
|
||||
if (!chosen_symset_end && !chosen_symset_start)
|
||||
return (symset[which_set] == 0) ? 1 : 0;
|
||||
return (symset[which_set].name == 0) ? 1 : 0;
|
||||
if (!chosen_symset_end) {
|
||||
raw_printf("Missing finish for symset \"%s\"",
|
||||
symset[which_set] ? symset[which_set] : "unknown");
|
||||
symset[which_set].name ?
|
||||
symset[which_set].name : "unknown");
|
||||
wait_synch();
|
||||
}
|
||||
return 1;
|
||||
@@ -2524,25 +2525,38 @@ int which_set;
|
||||
if (!symp)
|
||||
return 0;
|
||||
|
||||
if (!symset[which_set]) {
|
||||
if (!symset[which_set].name) {
|
||||
/* 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) {
|
||||
struct textlist *tmpsp;
|
||||
tmpsp = (struct textlist *)alloc(sizeof(struct textlist));
|
||||
tmpsp->next = (struct textlist *)0;
|
||||
if (!symset_list) {
|
||||
if (symp->range == SYM_CONTROL) {
|
||||
struct symsetentry *tmpsp;
|
||||
switch (symp->idx) {
|
||||
case 0:
|
||||
tmpsp = (struct symsetentry *)alloc(sizeof(struct symsetentry));
|
||||
tmpsp->next = (struct symsetentry *)0;
|
||||
if (!symset_list) {
|
||||
symset_list = tmpsp;
|
||||
symset_count = 0;
|
||||
} else {
|
||||
} else {
|
||||
symset_count++;
|
||||
tmpsp->next = symset_list;
|
||||
symset_list = tmpsp;
|
||||
}
|
||||
tmpsp->idx = symset_count;
|
||||
tmpsp->text = (char *)alloc(strlen(bufp)+1);
|
||||
Strcpy(tmpsp->text, bufp);
|
||||
}
|
||||
tmpsp->idx = symset_count;
|
||||
tmpsp->name = (char *)alloc(strlen(bufp)+1);
|
||||
Strcpy(tmpsp->name, bufp);
|
||||
tmpsp->desc = (char *)0;
|
||||
tmpsp->nocolor = 0;
|
||||
break;
|
||||
case 3: /* description:something */
|
||||
tmpsp = symset_list; /* most recent symset */
|
||||
if (tmpsp && !tmpsp->desc) {
|
||||
tmpsp->desc = (char *)alloc(strlen(bufp)+1);
|
||||
Strcpy(tmpsp->desc, bufp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -2551,7 +2565,8 @@ int which_set;
|
||||
switch(symp->idx) {
|
||||
case 0:
|
||||
/* start of symset */
|
||||
if (!strcmpi(bufp, symset[which_set])) { /* desired one? */
|
||||
if (!strcmpi(bufp, symset[which_set].name)) {
|
||||
/* matches desired one */
|
||||
chosen_symset_start = TRUE;
|
||||
#ifdef REINCARNATION
|
||||
if (which_set == ROGUESET) init_r_symbols();
|
||||
@@ -2570,6 +2585,21 @@ int which_set;
|
||||
if (chosen_symset_start)
|
||||
set_symhandling(bufp, which_set);
|
||||
break;
|
||||
/* case 3: (description) is ignored here */
|
||||
case 4: /* color:off */
|
||||
if (chosen_symset_start) {
|
||||
if (bufp) {
|
||||
if (!strcmpi(bufp, "true") ||
|
||||
!strcmpi(bufp, "yes") ||
|
||||
!strcmpi(bufp, "on"))
|
||||
symset[which_set].nocolor = 0;
|
||||
else if (!strcmpi(bufp, "false") ||
|
||||
!strcmpi(bufp, "no") ||
|
||||
!strcmpi(bufp, "off"))
|
||||
symset[which_set].nocolor = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else { /* !SYM_CONTROL */
|
||||
val = sym_val(bufp);
|
||||
@@ -2593,10 +2623,10 @@ int which_set;
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
symhandling[which_set] = H_UNK;
|
||||
symset[which_set].handling = H_UNK;
|
||||
while (known_handling[i]) {
|
||||
if (!strcmpi(known_handling[i], handling)) {
|
||||
symhandling[which_set] = i;
|
||||
symset[which_set].handling = i;
|
||||
return;
|
||||
}
|
||||
i++;
|
||||
|
||||
@@ -48,7 +48,6 @@ int explcolors[] = {
|
||||
#define explode_color(n)
|
||||
#endif
|
||||
|
||||
#ifdef ROGUE_COLOR
|
||||
# if defined(USE_TILES) && defined(MSDOS)
|
||||
#define HAS_ROGUE_IBM_GRAPHICS (currentgraphics == ROGUESET && \
|
||||
SYMHANDLING(H_IBM) && !iflags.grmode)
|
||||
@@ -56,7 +55,6 @@ int explcolors[] = {
|
||||
#define HAS_ROGUE_IBM_GRAPHICS (currentgraphics == ROGUESET && \
|
||||
SYMHANDLING(H_IBM))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*ARGSUSED*/
|
||||
void
|
||||
@@ -71,9 +69,11 @@ unsigned *ospecial;
|
||||
#endif
|
||||
uchar ch;
|
||||
unsigned special = 0;
|
||||
#ifdef ROGUE_COLOR
|
||||
/* condense multiple tests in macro version down to single */
|
||||
boolean has_rogue_ibm_graphics = HAS_ROGUE_IBM_GRAPHICS;
|
||||
#ifdef ROGUE_COLOR
|
||||
boolean has_rogue_color = (has_rogue_ibm_graphics &&
|
||||
(symset[currentgraphics].nocolor == 0));
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -85,7 +85,7 @@ unsigned *ospecial;
|
||||
if ((offset = (glyph - GLYPH_WARNING_OFF)) >= 0) { /* a warning flash */
|
||||
ch = warnsyms[offset];
|
||||
# ifdef ROGUE_COLOR
|
||||
if (has_rogue_ibm_graphics)
|
||||
if (has_rogue_color)
|
||||
color = NO_COLOR;
|
||||
else
|
||||
# endif
|
||||
@@ -94,7 +94,7 @@ unsigned *ospecial;
|
||||
/* see swallow_to_glyph() in display.c */
|
||||
ch = (uchar) showsyms[S_sw_tl + (offset & 0x7)];
|
||||
#ifdef ROGUE_COLOR
|
||||
if (has_rogue_ibm_graphics && iflags.use_color)
|
||||
if (has_rogue_color && iflags.use_color)
|
||||
color = NO_COLOR;
|
||||
else
|
||||
#endif
|
||||
@@ -103,7 +103,7 @@ unsigned *ospecial;
|
||||
/* see zapdir_to_glyph() in display.c */
|
||||
ch = showsyms[S_vbeam + (offset & 0x3)];
|
||||
#ifdef ROGUE_COLOR
|
||||
if (has_rogue_ibm_graphics && iflags.use_color)
|
||||
if (has_rogue_color && iflags.use_color)
|
||||
color = NO_COLOR;
|
||||
else
|
||||
#endif
|
||||
@@ -114,7 +114,7 @@ unsigned *ospecial;
|
||||
} else if ((offset = (glyph - GLYPH_CMAP_OFF)) >= 0) { /* cmap */
|
||||
ch = showsyms[offset];
|
||||
#ifdef ROGUE_COLOR
|
||||
if (has_rogue_ibm_graphics && iflags.use_color) {
|
||||
if (has_rogue_color && iflags.use_color) {
|
||||
if (offset >= S_vwall && offset <= S_hcdoor)
|
||||
color = CLR_BROWN;
|
||||
else if (offset >= S_arrow_trap && offset <= S_polymorph_trap)
|
||||
@@ -140,7 +140,7 @@ unsigned *ospecial;
|
||||
if (offset == BOULDER && iflags.bouldersym) ch = iflags.bouldersym;
|
||||
else ch = oc_syms[(int)objects[offset].oc_class];
|
||||
#ifdef ROGUE_COLOR
|
||||
if (has_rogue_ibm_graphics && iflags.use_color) {
|
||||
if (has_rogue_color && iflags.use_color) {
|
||||
switch(objects[offset].oc_class) {
|
||||
case COIN_CLASS: color = CLR_YELLOW; break;
|
||||
case FOOD_CLASS: color = CLR_RED; break;
|
||||
@@ -152,7 +152,7 @@ unsigned *ospecial;
|
||||
} else if ((offset = (glyph - GLYPH_RIDDEN_OFF)) >= 0) { /* mon ridden */
|
||||
ch = monsyms[(int)mons[offset].mlet];
|
||||
#ifdef ROGUE_COLOR
|
||||
if (has_rogue_ibm_graphics)
|
||||
if (has_rogue_color)
|
||||
/* This currently implies that the hero is here -- monsters */
|
||||
/* don't ride (yet...). Should we set it to yellow like in */
|
||||
/* the monster case below? There is no equivalent in rogue. */
|
||||
@@ -164,7 +164,7 @@ unsigned *ospecial;
|
||||
} else if ((offset = (glyph - GLYPH_BODY_OFF)) >= 0) { /* a corpse */
|
||||
ch = oc_syms[(int)objects[CORPSE].oc_class];
|
||||
#ifdef ROGUE_COLOR
|
||||
if (has_rogue_ibm_graphics && iflags.use_color)
|
||||
if (has_rogue_color && iflags.use_color)
|
||||
color = CLR_RED;
|
||||
else
|
||||
#endif
|
||||
@@ -173,7 +173,7 @@ unsigned *ospecial;
|
||||
} else if ((offset = (glyph - GLYPH_DETECT_OFF)) >= 0) { /* mon detect */
|
||||
ch = monsyms[(int)mons[offset].mlet];
|
||||
#ifdef ROGUE_COLOR
|
||||
if (has_rogue_ibm_graphics)
|
||||
if (has_rogue_color)
|
||||
color = NO_COLOR; /* no need to check iflags.use_color */
|
||||
else
|
||||
#endif
|
||||
@@ -184,7 +184,7 @@ unsigned *ospecial;
|
||||
} else if ((offset = (glyph - GLYPH_INVIS_OFF)) >= 0) { /* invisible */
|
||||
ch = DEF_INVISIBLE;
|
||||
#ifdef ROGUE_COLOR
|
||||
if (has_rogue_ibm_graphics)
|
||||
if (has_rogue_color)
|
||||
color = NO_COLOR; /* no need to check iflags.use_color */
|
||||
else
|
||||
#endif
|
||||
@@ -193,7 +193,7 @@ unsigned *ospecial;
|
||||
} else if ((offset = (glyph - GLYPH_PET_OFF)) >= 0) { /* a pet */
|
||||
ch = monsyms[(int)mons[offset].mlet];
|
||||
#ifdef ROGUE_COLOR
|
||||
if (has_rogue_ibm_graphics)
|
||||
if (has_rogue_color)
|
||||
color = NO_COLOR; /* no need to check iflags.use_color */
|
||||
else
|
||||
#endif
|
||||
@@ -202,7 +202,7 @@ unsigned *ospecial;
|
||||
} else { /* a monster */
|
||||
ch = monsyms[(int)mons[glyph].mlet];
|
||||
#ifdef ROGUE_COLOR
|
||||
if (has_rogue_ibm_graphics && iflags.use_color) {
|
||||
if (has_rogue_color && iflags.use_color) {
|
||||
if (x == u.ux && y == u.uy)
|
||||
/* actually player should be yellow-on-gray if in a corridor */
|
||||
color = CLR_YELLOW;
|
||||
@@ -225,7 +225,7 @@ unsigned *ospecial;
|
||||
/* Turn off color if no color defined, or rogue level w/o PC graphics. */
|
||||
# ifdef REINCARNATION
|
||||
# ifdef ROGUE_COLOR
|
||||
if (!has_color(color) || (Is_rogue_level(&u.uz) && !has_rogue_ibm_graphics))
|
||||
if (!has_color(color) || (Is_rogue_level(&u.uz) && !has_rogue_color))
|
||||
# else
|
||||
if (!has_color(color) || Is_rogue_level(&u.uz))
|
||||
# endif
|
||||
|
||||
168
src/options.c
168
src/options.c
@@ -609,9 +609,9 @@ initoptions()
|
||||
/* this detects the IBM-compatible console on most 386 boxes */
|
||||
if ((opts = nh_getenv("TERM")) && !strncmp(opts, "AT", 2)) {
|
||||
#ifdef ASCIIGRAPH
|
||||
if (!symset[PRIMARY]) load_symset("IBMGraphics", PRIMARY);
|
||||
if (!symset[PRIMARY].name) load_symset("IBMGraphics", PRIMARY);
|
||||
|
||||
if (!symset[ROGUESET]) load_symset("RogueIBM", ROGUESET);
|
||||
if (!symset[ROGUESET].name) load_symset("RogueIBM", ROGUESET);
|
||||
|
||||
switch_symbols(TRUE);
|
||||
#endif
|
||||
@@ -627,10 +627,7 @@ initoptions()
|
||||
!strncmpi(opts, "vt", 2) && AS && AE &&
|
||||
index(AS, '\016') && index(AE, '\017')) {
|
||||
# ifdef ASCIIGRAPH
|
||||
if (!symset[PRIMARY]) load_symset("DECGraphics", PRIMARY);
|
||||
|
||||
|
||||
|
||||
if (!symset[PRIMARY].name) load_symset("DECGraphics", PRIMARY);
|
||||
switch_symbols(TRUE);
|
||||
# endif /*ASCIIGRAPH*/
|
||||
}
|
||||
@@ -638,7 +635,7 @@ initoptions()
|
||||
#endif /* UNIX || VMS */
|
||||
|
||||
#ifdef MAC_GRAPHICS_ENV
|
||||
if (!symset[PRIMARY]) load_symset("MACGraphics", PRIMARY);
|
||||
if (!symset[PRIMARY].name) load_symset("MACGraphics", PRIMARY);
|
||||
switch_symbols(TRUE);
|
||||
#endif /* MAC_GRAPHICS_ENV */
|
||||
flags.menu_style = MENU_FULL;
|
||||
@@ -1301,11 +1298,10 @@ 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[ROGUESET] = (char *)alloc(strlen(op) + 1);
|
||||
Strcpy(symset[ROGUESET], op);
|
||||
symset[ROGUESET].name = (char *)alloc(strlen(op) + 1);
|
||||
Strcpy(symset[ROGUESET].name, op);
|
||||
if (!read_sym_file(ROGUESET)) {
|
||||
free((char *)symset[ROGUESET]);
|
||||
symset[ROGUESET] = (char *)0;
|
||||
clear_symsetentry(ROGUESET, TRUE);
|
||||
raw_printf("Unable to load symbol set \"%s\" from \"%s\".",
|
||||
op, SYMBOLS);
|
||||
wait_synch();
|
||||
@@ -1325,11 +1321,10 @@ 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[PRIMARY] = (char *)alloc(strlen(op) + 1);
|
||||
Strcpy(symset[PRIMARY], op);
|
||||
symset[PRIMARY].name = (char *)alloc(strlen(op) + 1);
|
||||
Strcpy(symset[PRIMARY].name, op);
|
||||
if (!read_sym_file(PRIMARY)) {
|
||||
free((char *)symset[PRIMARY]);
|
||||
symset[PRIMARY] = (char *)0;
|
||||
clear_symsetentry(PRIMARY, TRUE);
|
||||
raw_printf("Unable to load symbol set \"%s\" from \"%s\".",
|
||||
op, SYMBOLS);
|
||||
wait_synch();
|
||||
@@ -2293,15 +2288,14 @@ goodfruit:
|
||||
if (duplicate) complain_about_duplicate(opts,1);
|
||||
if (!negated) {
|
||||
/* There is no rogue level DECgraphics-specific set */
|
||||
if (symset[PRIMARY])
|
||||
if (symset[PRIMARY].name)
|
||||
badflag = TRUE;
|
||||
else {
|
||||
symset[PRIMARY] = (char *)alloc(strlen(fullname) + 1);
|
||||
Strcpy(symset[PRIMARY], fullname);
|
||||
symset[PRIMARY].name = (char *)alloc(strlen(fullname) + 1);
|
||||
Strcpy(symset[PRIMARY].name, fullname);
|
||||
if (!read_sym_file(PRIMARY)) {
|
||||
badflag = TRUE;
|
||||
free((char *)symset[PRIMARY]);
|
||||
symset[PRIMARY] = (char *)0;
|
||||
clear_symsetentry(PRIMARY, TRUE);
|
||||
} else switch_symbols(TRUE);
|
||||
}
|
||||
if (badflag) {
|
||||
@@ -2319,16 +2313,15 @@ goodfruit:
|
||||
if (duplicate) complain_about_duplicate(opts,1);
|
||||
if (!negated) {
|
||||
for (i = 0; i < NUM_GRAPHICS; ++i) {
|
||||
if (symset[i])
|
||||
if (symset[i].name)
|
||||
badflag = TRUE;
|
||||
else {
|
||||
if (i == ROGUESET) sym_name = "RogueIBM";
|
||||
symset[i] = (char *)alloc(strlen(sym_name) + 1);
|
||||
Strcpy(symset[i], sym_name);
|
||||
symset[i].name = (char *)alloc(strlen(sym_name) + 1);
|
||||
Strcpy(symset[i].name, sym_name);
|
||||
if (!read_sym_file(i)) {
|
||||
badflag = TRUE;
|
||||
free((char *)symset[i]);
|
||||
symset[i] = (char *)0;
|
||||
clear_symsetentry(i, TRUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2353,14 +2346,13 @@ goodfruit:
|
||||
boolean badflag = FALSE;
|
||||
if (duplicate) complain_about_duplicate(opts,1);
|
||||
if (!negated) {
|
||||
if (symset[PRIMARY]) badflag = TRUE;
|
||||
if (symset[PRIMARY]).name badflag = TRUE;
|
||||
else {
|
||||
symset[PRIMARY] = (char *)alloc(strlen(fullname) + 1);
|
||||
Strcpy(symset[PRIMARY], fullname);
|
||||
symset[PRIMARY].name = (char *)alloc(strlen(fullname) + 1);
|
||||
Strcpy(symset[PRIMARY].name, fullname);
|
||||
if (!read_sym_file(PRIMARY)) {
|
||||
badflag = TRUE;
|
||||
free((char *)symset[PRIMARY]);
|
||||
symset[PRIMARY] = (char *)0;
|
||||
clear_symsetentry(PRIMARY, TRUE);
|
||||
}
|
||||
}
|
||||
if (badflag) {
|
||||
@@ -2483,7 +2475,6 @@ goodfruit:
|
||||
badoption(opts);
|
||||
}
|
||||
|
||||
|
||||
static NEARDATA const char *menutype[] = {
|
||||
"traditional", "combination", "partial", "full"
|
||||
};
|
||||
@@ -2785,7 +2776,7 @@ doset()
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct textlist *symset_list = 0; /* files.c will populate this with
|
||||
struct symsetentry *symset_list = 0; /* files.c will populate this with
|
||||
list of available sets */
|
||||
|
||||
STATIC_OVL boolean
|
||||
@@ -3149,7 +3140,8 @@ boolean setinitial,setfromfile;
|
||||
!strcmp("roguesymset", optname)) {
|
||||
menu_item *symset_pick = (menu_item *)0;
|
||||
boolean rogueflag = (*optname == 'r');
|
||||
char *symset_name;
|
||||
struct symsetentry *sl;
|
||||
char *symset_name, fmtstr[20];
|
||||
int chosen = -2, res, which_set =
|
||||
#ifdef REINCARNATION
|
||||
rogueflag ? ROGUESET :
|
||||
@@ -3159,14 +3151,15 @@ boolean setinitial,setfromfile;
|
||||
if (rogueflag) return TRUE;
|
||||
#endif
|
||||
#ifdef ASCIIGRAPH
|
||||
/* clear symset as a flag to read_sym_file() to build list */
|
||||
symset_name = symset[which_set];
|
||||
symset[which_set] = (char *)0;
|
||||
/* 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;
|
||||
symset_list = (struct symsetentry *)0;
|
||||
|
||||
res = read_sym_file(which_set);
|
||||
if (res && symset_list) {
|
||||
int let = 'a';
|
||||
struct textlist *sl;
|
||||
char symsetchoice[BUFSZ];
|
||||
int let = 'a', biggest = 0, thissize = 0;
|
||||
tmpwin = create_nhwindow(NHW_MENU);
|
||||
start_menu(tmpwin);
|
||||
any.a_int = 1;
|
||||
@@ -3174,10 +3167,21 @@ boolean setinitial,setfromfile;
|
||||
ATR_NONE, "Default Symbols", MENU_UNSELECTED);
|
||||
sl = symset_list;
|
||||
while (sl) {
|
||||
if (sl->text) {
|
||||
/* find biggest name */
|
||||
if (sl->name) thissize = strlen(sl->name);
|
||||
if (thissize > biggest) biggest = thissize;
|
||||
sl = sl->next;
|
||||
}
|
||||
Sprintf(fmtstr,"%%-%ds %%s", biggest + 5);
|
||||
|
||||
sl = symset_list;
|
||||
while (sl) {
|
||||
if (sl->name) {
|
||||
any.a_int = sl->idx + 2;
|
||||
Sprintf(symsetchoice, fmtstr, sl->name,
|
||||
sl->desc ? sl->desc : "");
|
||||
add_menu(tmpwin, NO_GLYPH, &any, let, 0,
|
||||
ATR_NONE, sl->text, MENU_UNSELECTED);
|
||||
ATR_NONE, symsetchoice, MENU_UNSELECTED);
|
||||
sl = sl->next;
|
||||
if (let == 'z') let = 'A';
|
||||
else let++;
|
||||
@@ -3189,32 +3193,37 @@ boolean setinitial,setfromfile;
|
||||
free((genericptr_t)symset_pick);
|
||||
}
|
||||
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) {
|
||||
/* chose an actual symset name from file */
|
||||
sl = symset_list;
|
||||
while (sl) {
|
||||
if (sl->idx == chosen) {
|
||||
if (symset_name) {
|
||||
free((genericptr_t)symset_name);
|
||||
symset_name = (char *)0;
|
||||
}
|
||||
symset[which_set] = (char *)alloc(strlen(sl->text)+1);
|
||||
Strcpy(symset[which_set], sl->text);
|
||||
}
|
||||
sl = sl->next;
|
||||
/* free the now stale attributes */
|
||||
clear_symsetentry(which_set, TRUE);
|
||||
|
||||
/* transfer only the name of the symbol set */
|
||||
symset[which_set].name =
|
||||
(char *)alloc(strlen(sl->name)+1);
|
||||
Strcpy(symset[which_set].name, sl->name);
|
||||
|
||||
break;
|
||||
}
|
||||
} else if (chosen == -1) {
|
||||
sl = sl->next;
|
||||
}
|
||||
}
|
||||
|
||||
else if (chosen == -1) {
|
||||
/* explicit selection of defaults */
|
||||
/* free the now stale symset attributes */
|
||||
if (symset_name) free ((genericptr_t)symset_name);
|
||||
symset_name = (char *)0;
|
||||
clear_symsetentry(which_set, TRUE);
|
||||
}
|
||||
/* clean up */
|
||||
while (symset_list) {
|
||||
sl = symset_list;
|
||||
if (sl->text) free((genericptr_t)sl->text);
|
||||
symset_list = sl->next;
|
||||
}
|
||||
symset_list = (struct textlist *)0;
|
||||
} else if (!res) {
|
||||
/* The symbols file could not be accessed */
|
||||
pline("Unable to access \"%s\" file.", SYMBOLS);
|
||||
@@ -3225,32 +3234,45 @@ boolean setinitial,setfromfile;
|
||||
SYMBOLS);
|
||||
return TRUE;
|
||||
}
|
||||
/* these set default symbols and clear the handling value */
|
||||
|
||||
/* clean up */
|
||||
while (symset_list) {
|
||||
sl = symset_list;
|
||||
if (sl->name) free((genericptr_t)sl->name);
|
||||
sl->name = (char *)0;
|
||||
|
||||
if (sl->desc) free((genericptr_t)sl->desc);
|
||||
sl->desc = (char *)0;
|
||||
|
||||
symset_list = sl->next;
|
||||
free((genericptr_t)sl);
|
||||
}
|
||||
|
||||
/* Set default symbols and clear the handling value */
|
||||
# ifdef REINCARNATION
|
||||
if(rogueflag) init_r_symbols();
|
||||
else
|
||||
# endif
|
||||
init_l_symbols();
|
||||
|
||||
if (!symset[which_set] && symset_name)
|
||||
symset[which_set] = symset_name;
|
||||
if (!symset[which_set].name && symset_name)
|
||||
symset[which_set].name = symset_name;
|
||||
|
||||
if (symset[which_set]) {
|
||||
if (symset[which_set].name) {
|
||||
if (read_sym_file(which_set))
|
||||
switch_symbols(TRUE);
|
||||
else {
|
||||
free((genericptr_t)symset[which_set]);
|
||||
symset[which_set] = (char *)0;
|
||||
clear_symsetentry(which_set, TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch_symbols(TRUE);
|
||||
# ifdef REINCARNATION
|
||||
if (Is_rogue_level(&u.uz))
|
||||
assign_graphics(ROGUESET);
|
||||
else
|
||||
#endif
|
||||
# endif
|
||||
assign_graphics(PRIMARY);
|
||||
need_redraw = TRUE;
|
||||
#endif /*ASCIIGRAPH*/
|
||||
@@ -3454,7 +3476,8 @@ char *buf;
|
||||
#ifdef REINCARNATION
|
||||
else if (!strcmp(optname, "roguesymset"))
|
||||
Sprintf(buf, "%s",
|
||||
symset[ROGUESET] ? symset[ROGUESET] : "default");
|
||||
symset[ROGUESET].name ?
|
||||
symset[ROGUESET].name : "default");
|
||||
#endif
|
||||
else if (!strcmp(optname, "role"))
|
||||
Sprintf(buf, "%s", rolestring(flags.initrole, roles, name.m));
|
||||
@@ -3489,7 +3512,8 @@ char *buf;
|
||||
}
|
||||
else if (!strcmp(optname, "symset"))
|
||||
Sprintf(buf, "%s",
|
||||
symset[PRIMARY] ? symset[PRIMARY] : "default");
|
||||
symset[PRIMARY].name ?
|
||||
symset[PRIMARY].name : "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")) {
|
||||
@@ -3671,14 +3695,14 @@ load_symset(s, which_set)
|
||||
const char *s;
|
||||
int which_set;
|
||||
{
|
||||
if (symset[which_set]) free((genericptr_t)symset[which_set]);
|
||||
symset[which_set] = (char *)alloc(strlen(s)+1);
|
||||
Strcpy(symset[which_set],s);
|
||||
clear_symsetentry(which_set, TRUE);
|
||||
|
||||
symset[which_set].name = (char *)alloc(strlen(s)+1);
|
||||
Strcpy(symset[which_set].name,s);
|
||||
if (read_sym_file(which_set))
|
||||
switch_symbols(TRUE);
|
||||
else {
|
||||
free((genericptr_t)symset[which_set]);
|
||||
symset[which_set] = (char *)0;
|
||||
clear_symsetentry(which_set, TRUE);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
||||
@@ -307,11 +307,11 @@ char *argv[];
|
||||
|
||||
#if defined(MSDOS) || defined(WIN32)
|
||||
/* Player didn't specify any symbol set so use IBM defaults */
|
||||
if (!symset[PRIMARY]) {
|
||||
if (!symset[PRIMARY].name) {
|
||||
load_symset("IBMGraphics_2", PRIMARY);
|
||||
}
|
||||
# ifdef REINCARNATION
|
||||
if (!symset[ROGUESET]) {
|
||||
if (!symset[ROGUESET].name) {
|
||||
load_symset("RogueEpyx", ROGUESET);
|
||||
}
|
||||
# endif
|
||||
|
||||
Reference in New Issue
Block a user