From eaaeb81a9fee81989fe3033df249192031ab5a19 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 24 Sep 2021 12:01:54 -0700 Subject: [PATCH] recalc_mapseen vs rooms Reported and diagnosed by entrez: recalc_mapseen() has been looking at all slots in u.urooms[] rather than stopping at the first \0. Since the whole array doesn't get zeroed out when the value changes, stale room indices might follow that first \0 and any rooms those referred to would erroneously get flagged as having been visited by overview updates. Wouldn't matter for the level where the stale indices got set, since you'd have to have been in those rooms for it to happen, but would matter once you moved on to other levels. --- doc/fixes37.0 | 3 +++ src/dungeon.c | 13 +++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 4eec2daf9..8fadd8e14 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -619,6 +619,9 @@ similar "The ogre lord yanks Cleaver from your corpses!" due to caching the next item, to avoid churning through the whole pool of obufs gas clouds are a little random in how they spread out from a point Izchak occasionally stocks wands/scrolls/spellbooks of light +data tracking for #overview was mis-using u.urooms[] and after being in a + situation where hero was in multiple rooms at once, visiting other + levels might flag unvisisted rooms as having been visited Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/src/dungeon.c b/src/dungeon.c index 5738a36a5..6d536cc83 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -2765,6 +2765,7 @@ recalc_mapseen(void) struct trap *t; unsigned i, ridx, atmp; int x, y, ltyp, count; + char uroom; /* Should not happen in general, but possible if in the process * of being booted from the quest. The mapseen object gets @@ -2816,18 +2817,14 @@ recalc_mapseen(void) /* flags.msanctum, .valley, and .vibrating_square handled below */ /* track rooms the hero is in */ - for (i = 0; i < SIZE(u.urooms); ++i) { - if (!u.urooms[i]) - continue; - - ridx = u.urooms[i] - ROOMOFFSET; + for (i = 0; (uroom = u.urooms[i]) != '\0'; ++i) { + ridx = (unsigned) uroom - ROOMOFFSET; mptr->msrooms[ridx].seen = 1; mptr->msrooms[ridx].untended = (g.rooms[ridx].rtype >= SHOPBASE) - ? (!(mtmp = shop_keeper(u.urooms[i])) || !inhishop(mtmp)) + ? (!(mtmp = shop_keeper(uroom)) || !inhishop(mtmp)) : (g.rooms[ridx].rtype == TEMPLE) - ? (!(mtmp = findpriest(u.urooms[i])) - || !inhistemple(mtmp)) + ? (!(mtmp = findpriest(uroom)) || !inhistemple(mtmp)) : 0; }