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.
This commit is contained in:
PatR
2021-09-24 12:01:54 -07:00
parent c760911f2e
commit eaaeb81a9f
2 changed files with 8 additions and 8 deletions

View File

@@ -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

View File

@@ -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;
}