]> granicus.if.org Git - nethack/commitdiff
remove redundant null-check on untrap_prob()
authorSHIRAKATA Kentaro <argrath@ub32.org>
Tue, 8 Feb 2022 20:50:49 +0000 (05:50 +0900)
committerPatR <rankin@nethack.org>
Fri, 11 Mar 2022 17:56:35 +0000 (09:56 -0800)
`ttmp` should not be NULL here, otherwise this function will crash at earlier code.

src/trap.c

index deeab493fe376a6c105e5ad73febb6c9bb078f39..09af868f1de1a6aeba6b15fbfd30cc8f95f227e5 100644 (file)
@@ -4468,6 +4468,7 @@ untrap_prob(struct trap *ttmp)
     int chance = 3;
 
     /* Only spiders know how to deal with webs reliably */
+    /* Assume ttmp is not NULL */
     if (ttmp->ttyp == WEB && !webmaker(g.youmonst.data))
         chance = 7; /* 3.7: used to be 30 */
     if (Confusion || Hallucination)
@@ -4479,7 +4480,7 @@ untrap_prob(struct trap *ttmp)
     if (Fumbling)
         chance *= 2;
     /* Your own traps are better known than others. */
-    if (ttmp && ttmp->madeby_u)
+    if (ttmp->madeby_u)
         chance--;
     if (Role_if(PM_ROGUE)) {
         if (rn2(2 * MAXULEV) < u.ulevel)