pull request #975 - maybe_unhide_at()

Pull request from entrez:  mayby_unhide_at() operating on the hero
rather than on a monster was buggy because it was looking at the wrong
fields when checking for being hidden (recently fixed) and for being
trapped (fixed here) because those are tracked by fields in 'u' rather
than in 'youmonst'.

Closes #975
This commit is contained in:
PatR
2023-02-09 15:31:41 -08:00

View File

@@ -4128,16 +4128,21 @@ void
maybe_unhide_at(coordxy x, coordxy y)
{
struct monst *mtmp;
boolean undetected = FALSE;
boolean undetected = FALSE, trapped = FALSE;
if ((mtmp = m_at(x, y)) == 0 && u_at(x, y)) {
if ((mtmp = m_at(x, y)) != (struct monst *) 0) {
undetected = mtmp->mundetected;
trapped = mtmp->mtrapped;
} else if (u_at(x, y)) {
mtmp = &gy.youmonst;
undetected = u.uundetected;
} else if (mtmp) {
undetected = mtmp->mundetected;
trapped = u.utrap;
} else {
return;
}
if (mtmp && undetected
&& ((hides_under(mtmp->data) && (!OBJ_AT(x, y) || mtmp->mtrapped))
if (undetected
&& ((hides_under(mtmp->data) && (!OBJ_AT(x, y) || trapped))
|| (mtmp->data->mlet == S_EEL && !is_pool(x, y))))
(void) hideunder(mtmp);
}