From d43f8f6f9e59033e9066aed1386cbd0e5fa97c09 Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 8 Dec 2019 10:36:52 -0800 Subject: [PATCH] altar color revisited The issue of mimics masquerading as altars just came up two weeks ago but never entered my mind when I worked on this yesterday. --- include/extern.h | 3 ++- src/mapglyph.c | 16 +++++++++------- src/pager.c | 9 +++------ src/pray.c | 20 +++++++++++++++++++- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/include/extern.h b/include/extern.h index eaa7d5f3d..02823455c 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 extern.h $NHDT-Date: 1575768406 2019/12/08 01:26:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.766 $ */ +/* NetHack 3.6 extern.h $NHDT-Date: 1575830178 2019/12/08 18:36:18 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.767 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2045,6 +2045,7 @@ E boolean FDECL(can_pray, (BOOLEAN_P)); E int NDECL(dopray); E const char *NDECL(u_gname); E int NDECL(doturn); +E int FDECL(altarmask_at, (int, int)); E const char *NDECL(a_gname); E const char *FDECL(a_gname_at, (XCHAR_P x, XCHAR_P y)); E const char *FDECL(align_gname, (ALIGNTYP_P)); diff --git a/src/mapglyph.c b/src/mapglyph.c index 7a28091d9..74492cc74 100644 --- a/src/mapglyph.c +++ b/src/mapglyph.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mapglyph.c $NHDT-Date: 1575755075 2019/12/07 21:44:35 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.58 $ */ +/* NetHack 3.6 mapglyph.c $NHDT-Date: 1575830186 2019/12/08 18:36:26 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.60 $ */ /* Copyright (c) David Cohrs, 1991 */ /* NetHack may be freely redistributed. See license for details. */ @@ -163,22 +163,24 @@ unsigned mgflags; == g.showsyms[S_water + SYM_OFF_P])) { special |= MG_BW_LAVA; } else if (offset == S_altar && iflags.use_color) { + int amsk = altarmask_at(x, y); /* might be a mimic */ + if ((g.glyphmap_perlevel_flags & GMAP_ALTARCOLOR) - && (levl[x][y].altarmask & AM_SHRINE)) { + && (amsk & AM_SHRINE) != 0) { /* high altar */ color = CLR_BRIGHT_MAGENTA; } else { - switch (levl[x][y].altarmask & AM_MASK) { + switch (amsk & AM_MASK) { #if 0 /* - * On OSX with XTERM=xterm-color256 these render as + * On OSX with TERM=xterm-color256 these render as * white -> tty: gray, curses: ok * gray -> both tty and curses: black * black -> both tty and curses: blue * red -> both tty and curses: ok. - * Since the colors have specific associations (mainly with - * the unicorns matched with each alignment), we shouldn't use + * Since the colors have specific associations (with the + * unicorns matched with each alignment), we shouldn't use * scrambled colors and we don't have sufficient information - * to handle platform-specific variations. + * to handle platform-specific color variations. */ case AM_LAWFUL: /* 4 */ color = CLR_WHITE; diff --git a/src/pager.c b/src/pager.c index bf185f64e..f29cedadb 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pager.c $NHDT-Date: 1574722864 2019/11/25 23:01:04 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.162 $ */ +/* NetHack 3.6 pager.c $NHDT-Date: 1575830188 2019/12/08 18:36:28 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.175 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -483,11 +483,8 @@ char *buf, *monbuf; switch (glyph_to_cmap(glyph)) { case S_altar: - amsk = ((mtmp = m_at(x, y)) != 0 && has_mcorpsenm(mtmp) - && M_AP_TYPE(mtmp) == M_AP_FURNITURE - && mtmp->mappearance == S_altar) ? MCORPSENM(mtmp) - : levl[x][y].altarmask; - algn = Amask2align(amsk & ~AM_SHRINE); + amsk = altarmask_at(x, y); + algn = Amask2align(amsk & AM_MASK); Sprintf(buf, "%s %saltar", /* like endgame high priests, endgame high altars are only recognizable when immediately adjacent */ diff --git a/src/pray.c b/src/pray.c index 0da0c2a23..0562cd7ec 100644 --- a/src/pray.c +++ b/src/pray.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pray.c $NHDT-Date: 1575755077 2019/12/07 21:44:37 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.133 $ */ +/* NetHack 3.6 pray.c $NHDT-Date: 1575830189 2019/12/08 18:36:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.134 $ */ /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2077,6 +2077,24 @@ doturn() return 1; } +int +altarmask_at(x, y) +int x, y; +{ + int res = 0; + + if (isok(x, y)) { + struct monst *mon = m_at(x, y); + + if (mon && M_AP_TYPE(mon) == M_AP_FURNITURE + && mon->mappearance == S_altar) + res = has_mcorpsenm(mon) ? MCORPSENM(mon) : 0; + else if (IS_ALTAR(levl[x][y].typ)) + res = levl[x][y].altarmask; + } + return res; +} + const char * a_gname() {