commit ccb10489aee5f2af752177b0f8451790140292e2

Author: PatR <rankin@nethack.org>
Date:   Fri Dec 3 18:35:12 2021 -0800

    showrace when hero can't see self

    This supersedes pull request #644 by entrez, "Fix: expanded-glyphs
    hero color regression".  The code to change color for the hero in
    special circumstances (for 'showrace' and for some PC rogue stuff)
    was relying on the hero's map coordinates rather than verifying
    that the hero was shown at that spot.  When the hero is invisible
    and lacks see invisible, he isn't shown.  But the color of whatever
    could be seen beneath him was incorrectly having its color changed
    (to HI_DOMESTIC for showrace or to YELLOW for PC rogue).

    Closes #644
This commit is contained in:
PatR
2021-12-03 18:45:53 -08:00
parent 3bb9f91a1e
commit c3dc95f926
2 changed files with 24 additions and 10 deletions

View File

@@ -916,6 +916,8 @@ glob shrinkage while hero was away from glob's level wasn't handled properly
unpaid shop-owned glob that shrank to nothing had weight 0 which triggered
onbill warnings when 'sanity_check' was On; for 'Ix' and itemized
billing, the empty weight was shown to player if 'wizweight' was On
if 'showrace' was On and invisible hero couldn't see invisible so didn't see
self, the color of wharever could be seen underneath changed to white
curses: 'msg_window' option wasn't functional for curses unless the binary
also included tty support

View File

@@ -2171,20 +2171,33 @@ map_glyphinfo(xchar x, xchar y, int glyph, unsigned mgflags,
glyph_info *glyphinfo)
{
int offset;
boolean is_you = (x == u.ux && y == u.uy);
boolean is_you = (x == u.ux && y == u.uy
/* verify hero or steed (not something underneath
when hero is invisible without see invisible) */
&& canspotself());
const glyph_map *gmap = &glyphmap[glyph];
glyphinfo->gm = *gmap; /* glyphflags, symidx, color, tileidx */
/* Only hero tinkering permitted on-the-fly (who).
Unique glyphs in glyphmap[] determine everything else (what). */
/*
* Only hero tinkering permitted on-the-fly (who).
* Unique glyphs in glyphmap[] determine everything else (what).
*
* (Note: if hero is invisible without see invisible, he/she usually
* can't see himself/herself. This applies to accessibility hacks
* as well as to regular display.)
*/
if (is_you) {
#ifdef TEXTCOLOR
if (iflags.use_color && HAS_ROGUE_IBM_GRAPHICS
&& g.symset[g.currentgraphics].nocolor == 0) {
if (!iflags.use_color || Upolyd) {
; /* color tweak not needed (!use_color) or not wanted (Upolyd) */
} else if (HAS_ROGUE_IBM_GRAPHICS
&& g.symset[g.currentgraphics].nocolor == 0) {
/* actually player should be yellow-on-gray if in corridor */
glyphinfo->gm.color = CLR_YELLOW;
} else if (iflags.use_color && flags.showrace && !Upolyd) {
/* special case the hero for `showrace' option */
} else if (flags.showrace) {
/* for showrace, non-human hero is displayed by the symbol of
corresponding type of monster rather than by '@' (handled
by newsym()); we change the color to same as human hero */
glyphinfo->gm.color = HI_DOMESTIC;
}
#endif
@@ -2297,9 +2310,8 @@ reset_glyphmap(enum glyphmap_change_triggers trigger)
/* condense multiple tests in macro version down to single */
boolean has_rogue_ibm_graphics = HAS_ROGUE_IBM_GRAPHICS,
has_rogue_color =
(has_rogue_ibm_graphics
&& g.symset[g.currentgraphics].nocolor == 0);
has_rogue_color = (has_rogue_ibm_graphics
&& g.symset[g.currentgraphics].nocolor == 0);
if (trigger == gm_levelchange)
g.glyphmap_perlevel_flags = 0;