From 81e72dd0ccd2786ac058c03b37500b09b6ce03c6 Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 24 Apr 2025 11:19:20 -0700 Subject: [PATCH] notice_all_mons() Process monsters more consistently. --- src/hack.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/hack.c b/src/hack.c index d7e6f6b1f..7c30870c7 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1728,22 +1728,25 @@ notice_all_mons(boolean reset) struct monst **arr = NULL; int j, i = 0, cnt = 0; - for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) + for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { + if (DEADMONSTER(mtmp)) + continue; if (canspotmon(mtmp)) cnt++; else if (reset) mtmp->mspotted = FALSE; - + } if (!cnt) return; - arr = (struct monst **) alloc(cnt * sizeof(struct monst *)); - + arr = (struct monst **) alloc(cnt * sizeof (struct monst *)); for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { + if (DEADMONSTER(mtmp)) + continue; if (!canspotmon(mtmp)) mtmp->mspotted = FALSE; - else if (!DEADMONSTER(mtmp) && i < cnt) + else if (i < cnt) arr[i++] = mtmp; }