From: Michael Meyer Date: Thu, 9 Feb 2023 16:38:59 +0000 (-0500) Subject: Tweak maybe_unhide_at() a bit more X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e725c195d9643cffb79355a1b66e1dbd70aa9e4d;p=nethack Tweak maybe_unhide_at() a bit more A monster may be unhidden if it's caught in a trap, but maybe_unhide_at was checking mtmp->mtrapped across the board, which wouldn't work for the hero. Use u.utrap instead under those circumstances. Also refactor a bit so it shouldn't need the repeated guards against mtmp being null. --- diff --git a/src/mon.c b/src/mon.c index 5375769f3..0303b53a8 100644 --- a/src/mon.c +++ b/src/mon.c @@ -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); }