mapglyph level-related function calls are done once per level

This commit is contained in:
nhmall
2019-12-07 22:03:43 -05:00
parent bb72823d7b
commit 2bf55a6ec7
5 changed files with 39 additions and 6 deletions

View File

@@ -695,6 +695,9 @@ const struct instance_globals g_init = {
DUMMY, /* lua_ver[LUA_VER_BUFSIZ] */
DUMMY, /* lua_copyright[LUA_COPYRIGHT_BUFSIZ] */
/* per-level glyph mapping flags */
0L, /* glyphmap_perlevel_flags */
IVMAGIC /* used to validate that structure layout has been preserved */
};

View File

@@ -1578,6 +1578,7 @@ boolean at_stairs, falling, portal;
/* Reset the screen. */
vision_reset(); /* reset the blockages */
g.glyphmap_perlevel_flags = 0L; /* force per-level mapglyph() changes */
docrt(); /* does a full vision recalc */
flush_screen(-1);

View File

@@ -9,9 +9,11 @@
#include "color.h"
#define HI_DOMESTIC CLR_WHITE /* monst.c */
#if 0
#if !defined(TTY_GRAPHICS)
#define has_color(n) TRUE
#endif
#endif
#ifdef TEXTCOLOR
static const int explcolors[] = {
@@ -57,6 +59,10 @@ static const int explcolors[] = {
#define is_objpile(x,y) (!Hallucination && g.level.objects[(x)][(y)] \
&& g.level.objects[(x)][(y)]->nexthere)
#define GMAP_SET 0x00000001
#define GMAP_ROGUELEVEL 0x00000002
#define GMAP_ALTARCOLOR 0x00000004
/*ARGSUSED*/
int
mapglyph(glyph, ochar, ocolor, ospecial, x, y, mgflags)
@@ -75,6 +81,21 @@ unsigned mgflags;
has_rogue_color = (has_rogue_ibm_graphics
&& g.symset[g.currentgraphics].nocolor == 0);
if (!g.glyphmap_perlevel_flags) {
/*
* GMAP_SET 0x00000001
* GMAP_ROGUELEVEL 0x00000002
* GMAP_ALTARCOLOR 0x00000004
*/
g.glyphmap_perlevel_flags |= GMAP_SET;
if (Is_rogue_level(&u.uz)) {
g.glyphmap_perlevel_flags |= GMAP_ROGUELEVEL;
} else if ((Is_astralevel(&u.uz) || Is_sanctum(&u.uz))) {
g.glyphmap_perlevel_flags |= GMAP_ALTARCOLOR;
}
}
/*
* Map the glyph back to a character and color.
*
@@ -142,7 +163,7 @@ unsigned mgflags;
== g.showsyms[S_water + SYM_OFF_P])) {
special |= MG_BW_LAVA;
} else if (offset == S_altar && iflags.use_color) {
if ((Is_astralevel(&u.uz) || Is_sanctum(&u.uz))
if ((g.glyphmap_perlevel_flags & GMAP_ALTARCOLOR)
&& (levl[x][y].altarmask & AM_SHRINE)) {
/* high altar */
color = CLR_BRIGHT_MAGENTA;
@@ -273,14 +294,16 @@ unsigned mgflags;
if ((special & MG_PET) != 0) {
ovidx = SYM_PET_OVERRIDE + SYM_OFF_X;
if (Is_rogue_level(&u.uz) ? g.ov_rogue_syms[ovidx]
: g.ov_primary_syms[ovidx])
if ((g.glyphmap_perlevel_flags & GMAP_ROGUELEVEL)
? g.ov_rogue_syms[ovidx]
: g.ov_primary_syms[ovidx])
idx = ovidx;
}
if (is_you) {
ovidx = SYM_HERO_OVERRIDE + SYM_OFF_X;
if (Is_rogue_level(&u.uz) ? g.ov_rogue_syms[ovidx]
: g.ov_primary_syms[ovidx])
if ((g.glyphmap_perlevel_flags & GMAP_ROGUELEVEL)
? g.ov_rogue_syms[ovidx]
: g.ov_primary_syms[ovidx])
idx = ovidx;
}
}
@@ -288,7 +311,8 @@ unsigned mgflags;
ch = g.showsyms[idx];
#ifdef TEXTCOLOR
/* Turn off color if no color defined, or rogue level w/o PC graphics. */
if (!has_color(color) || (Is_rogue_level(&u.uz) && !has_rogue_color))
if (!has_color(color) ||
((g.glyphmap_perlevel_flags & GMAP_ROGUELEVEL) && !has_rogue_color))
#endif
color = NO_COLOR;
*ochar = (int) ch;