]> granicus.if.org Git - nethack/commitdiff
fix mintrap() return value and resurrect dead code
authornhmall <nhmall@nethack.org>
Tue, 8 Feb 2022 22:31:34 +0000 (17:31 -0500)
committernhmall <nhmall@nethack.org>
Tue, 8 Feb 2022 22:31:34 +0000 (17:31 -0500)
fixes #672

doc/fixes3-7-0.txt
src/trap.c

index 388b4f5404064d51abfe31c4206bda3c65af631b..a81de9e4b2c6835c1170e9ad2bdfb58e8b6a87a6 100644 (file)
@@ -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
index af4205763b7a525d56b5a417d6e72f9ebe460861..759bb52990f9c3a6eb2ef220528ac4fd7992a1f6 100644 (file)
@@ -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. */