From 6f5aba00cdd3e0b8faa745843dd113dc7bffb369 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 29 Aug 2025 14:20:49 -0700 Subject: [PATCH] fix issue #1440 - spurious sanity check warning Issue reported by NullCGT: if the spot in front of a drawbridge held water and got frozen, sanity checking for ice-melt timer would issue complaints about melt timer for non-ice whenever the bridge was open. Ice in front of closed bridge was handled ok, but ice beneath an open bridge issued a spurious warning each turn if the sanity_check option (wizard mode-only) was on. Fixes #1440 --- src/timeout.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/timeout.c b/src/timeout.c index 248dde41f..1b85d5398 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 timeout.c $NHDT-Date: 1727251273 2024/09/25 08:01:13 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.193 $ */ +/* NetHack 3.7 timeout.c $NHDT-Date: 1756531249 2025/08/29 21:20:49 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.205 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2179,7 +2179,13 @@ timer_sanity_check(void) the analyzer isn't aware that isok() filters such things */ assert(x > 0 && x < COLNO && y >= 0 && y < ROWNO); - if (curr->func_index == MELT_ICE_AWAY && !is_ice(x, y)) + if (curr->func_index == MELT_ICE_AWAY && !is_ice(x, y) + /* the terrain under the span of an open drawbridge might + be frozen moat; is_ice() only checks for that when + the drawbridge is closed (and terrain here would be + DRAWBRIGE_UP) */ + && !(levl[x][y].typ == DRAWBRIDGE_DOWN + && (levl[x][y].drawbridgemask & DB_UNDER) == DB_ICE)) impossible( "timer sanity: melt timer %lu on non-ice %d <%d,%d>", t_id, levl[x][y].typ, x, y);