From dfd5ca6cad5cf8cfeeb49259eda967234b610175 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 30 Mar 2024 07:52:23 -0700 Subject: [PATCH] more display of T-shirt/apron text at end-of-game This doesn't directly affect nethack, but it should prevent HTML dumplog for variants that include that from showing T-shirt and apron slogan text in tooltips for the 'gameover' map. And it makes end-of-game attribute disclosure slightly less susceptible to being unintentionally reverted. Code in pull request #300 shows that it uses do_screen_description() for tooltips and do_screen_description() uses distant_name() for objects so that's where I added this change that will trigger the code from commit c6992777f580acafc2e7c2f219da1612607842a6. --- src/objnam.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/objnam.c b/src/objnam.c index 747c261dc..7d2f581f7 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 objnam.c $NHDT-Date: 1702349266 2023/12/12 02:47:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.407 $ */ +/* NetHack 3.7 objnam.c $NHDT-Date: 1711809641 2024/03/30 14:40:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.427 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -340,6 +340,7 @@ distant_name( char *(*func)(OBJ_P)) /* formatting routine (usually xname or doname) */ { char *str; + unsigned save_oid; coordxy ox = 0, oy = 0; /* * (r * r): square of the x or y distance; @@ -360,6 +361,19 @@ distant_name( int r = (u.xray_range > 2) ? u.xray_range : 2, neardist = (r * r) * 2 - r; /* same as r*r + r*(r-1) */ + /* setting o_id to 0 prevents xname() from adding T-shirt or apron + slogan, Hawaiian shirt motif, or candy wrapper label when called + with 'program_state.gameover' set; we want this suppression for + html-dump (not implemented in nethack) to prevent object-on-map + tooltips from including that extra text; also guards against a + potential change to minimal_xname() [indirectly used by attribute + disclosure] that propogates o_id rather than leave it 0, and + against a potential extra chance to browse the map with getpos() + during final disclosure (not currently implemented, nor planned) */ + save_oid = obj->o_id; + if (gp.program_state.gameover) + obj->o_id = 0; + /* this maybe-nearby part used to be replicated in multiple callers */ if (get_obj_location(obj, &ox, &oy, 0) && cansee(ox, oy) && (obj->oartifact || distu(ox, oy) <= neardist)) { @@ -379,6 +393,9 @@ distant_name( str = (*func)(obj); --gd.distantname; } + + obj->o_id = save_oid; /* reset to normal */ + return str; }