From: nhmall Date: Tue, 8 Feb 2022 22:31:34 +0000 (-0500) Subject: fix mintrap() return value and resurrect dead code X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fe03b102082e379b54dc7e1d31551ea7819d27c1;p=nethack fix mintrap() return value and resurrect dead code fixes #672 --- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 388b4f540..a81de9e4b 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1005,6 +1005,9 @@ giving a prefix keystroke other than 'm' prior to a command that doesn't use prior revision broke all prefix usage movement command revamp broke 'm>' and 'm<' on stairs to avoid auto-pickup at the destination +when trapeffect_selector() returns 2 to caller mintrap(), meant to + signify that the monster was killed in the trap, ensure that + mintrap() returns that value too curses: 'msg_window' option wasn't functional for curses unless the binary also included tty support diff --git a/src/trap.c b/src/trap.c index af4205763..759bb5299 100644 --- a/src/trap.c +++ b/src/trap.c @@ -3064,8 +3064,8 @@ int mintrap(register struct monst *mtmp) { register struct trap *trap = t_at(mtmp->mx, mtmp->my); - boolean trapkilled = FALSE; struct permonst *mptr = mtmp->data; + int trap_result = 0; if (!trap) { mtmp->mtrapped = 0; /* perhaps teleported? */ @@ -3129,11 +3129,9 @@ mintrap(register struct monst *mtmp) if (trap->madeby_u && rnl(5)) setmangry(mtmp, FALSE); - return trapeffect_selector(mtmp, trap, 0); + trap_result = trapeffect_selector(mtmp, trap, 0); } - if (trapkilled) - return 2; - return mtmp->mtrapped; + return (trap_result == 2) ? trap_result : mtmp->mtrapped; } /* Combine cockatrice checks into single functions to avoid repeating code. */