]> granicus.if.org Git - nethack/commitdiff
Audit rloc()
authorSean Hunt <scshunt@csclub.uwaterloo.ca>
Sun, 24 May 2015 12:40:33 +0000 (21:40 +0900)
committernhmall <mjnh@persona.ca>
Sun, 24 May 2015 13:31:40 +0000 (09:31 -0400)
Most of the time, rloc() is used for teleporting monsters and it's not a
big deal if they can't find somewhere to go. In a few cases, it is. I
went through all the callsites and made calls to rloc() not cause
impossible()s if they don't need to.

Fixes a bug/suite of bugs reported by ais523.

12 files changed:
src/apply.c
src/dig.c
src/dothrow.c
src/mhitm.c
src/mhitu.c
src/minion.c
src/monmove.c
src/muse.c
src/steal.c
src/teleport.c
src/vault.c
src/wizard.c

index eb4b57c1d259496d0b82e42810d709fae44b1648..59fea44a18a126eea14b4177d0cc609ea788b3be 100644 (file)
@@ -886,7 +886,7 @@ struct obj *obj;
         freeinv(obj);
         (void) mpickobj(mtmp, obj);
         if (!tele_restrict(mtmp))
-            (void) rloc(mtmp, FALSE);
+            (void) rloc(mtmp, TRUE);
     } else if (!is_unicorn(mtmp->data) && !humanoid(mtmp->data)
                && (!mtmp->minvis || perceives(mtmp->data)) && rn2(5)) {
         if (vis)
index 0c6e54dbaf325b093c1de212327d42d70889eaf1..a659ff130176fce8adb89eba7572547b51d463aa 100644 (file)
--- a/src/dig.c
+++ b/src/dig.c
@@ -63,7 +63,7 @@ boolean waslit, rockit;
             return;                   /* don't cover the portal */
         if ((mtmp = m_at(x, y)) != 0) /* make sure crucial monsters survive */
             if (!passes_walls(mtmp->data))
-                (void) rloc(mtmp, FALSE);
+                (void) rloc(mtmp, TRUE);
     } else if (lev->typ == ROOM)
         return;
 
index 33cefc1ce77b601c03be48f5dbdd76820dd1cd5d..0b6296058f469514301d1f4bb8b4a6eb4f5d8ae7 100644 (file)
@@ -1655,7 +1655,7 @@ nopick:
     if (!Blind)
         pline1(buf);
     if (!tele_restrict(mon))
-        (void) rloc(mon, FALSE);
+        (void) rloc(mon, TRUE);
     return (ret);
 }
 
index 6f061da254eaff62fa282649593654441578cd43..35f6cd5be273a72fa623a5b8053ebea1b878c309 100644 (file)
@@ -1017,7 +1017,7 @@ register struct attack *mattk;
             if (vis)
                 Strcpy(mdef_Monnam, Monnam(mdef));
             mdef->mstrategy &= ~STRAT_WAITFORU;
-            (void) rloc(mdef, FALSE);
+            (void) rloc(mdef, TRUE);
             if (vis && !canspotmon(mdef) && mdef != u.usteed)
                 pline("%s suddenly disappears!", mdef_Monnam);
         }
@@ -1139,7 +1139,7 @@ register struct attack *mattk;
             pline("%s steals some gold from %s.", buf, mon_nam(mdef));
         }
         if (!tele_restrict(magr)) {
-            (void) rloc(magr, FALSE);
+            (void) rloc(magr, TRUE);
             if (vis && !canspotmon(magr))
                 pline("%s suddenly disappears!", buf);
         }
@@ -1202,7 +1202,7 @@ register struct attack *mattk;
                 return (MM_DEF_DIED
                         | (grow_up(magr, mdef) ? 0 : MM_AGR_DIED));
             if (pa->mlet == S_NYMPH && !tele_restrict(magr)) {
-                (void) rloc(magr, FALSE);
+                (void) rloc(magr, TRUE);
                 if (vis && !canspotmon(magr))
                     pline("%s suddenly disappears!", buf);
             }
index 90a4392348c425d3dfd63af6a3a77d4c11d94e21..83b69398e971d063c793460bb1e8bc2d9b00f2fa 100644 (file)
@@ -1265,7 +1265,7 @@ register struct attack *mattk;
                       : "makes some remarks about how difficult theft is "
                         "lately");
             if (!tele_restrict(mtmp))
-                (void) rloc(mtmp, FALSE);
+                (void) rloc(mtmp, TRUE);
             return 3;
         } else if (mtmp->mcan) {
             if (!Blind) {
@@ -1276,7 +1276,7 @@ register struct attack *mattk;
             }
             if (rn2(3)) {
                 if (!tele_restrict(mtmp))
-                    (void) rloc(mtmp, FALSE);
+                    (void) rloc(mtmp, TRUE);
                 return 3;
             }
             break;
@@ -1289,7 +1289,7 @@ register struct attack *mattk;
             break;
         default:
             if (!is_animal(mtmp->data) && !tele_restrict(mtmp))
-                (void) rloc(mtmp, FALSE);
+                (void) rloc(mtmp, TRUE);
             if (is_animal(mtmp->data) && *buf) {
                 if (canseemon(mtmp))
                     pline("%s tries to %s away with %s.", Monnam(mtmp),
@@ -1392,7 +1392,7 @@ register struct attack *mattk;
                 return 2;
             } else if (!rn2(33)) {
                 if (!tele_restrict(mtmp))
-                    (void) rloc(mtmp, FALSE);
+                    (void) rloc(mtmp, TRUE);
                 monflee(mtmp, d(3, 6), TRUE, FALSE);
                 return 3;
             }
@@ -2381,7 +2381,7 @@ register struct monst *mon;
         verbalize("You're such a %s; I wish...",
                   flags.female ? "sweet lady" : "nice guy");
         if (!tele_restrict(mon))
-            (void) rloc(mon, FALSE);
+            (void) rloc(mon, TRUE);
         return 1;
     }
     if (u.ualign.type == A_CHAOTIC)
@@ -2503,7 +2503,7 @@ register struct monst *mon;
     if (!rn2(25))
         mon->mcan = 1; /* monster is worn out */
     if (!tele_restrict(mon))
-        (void) rloc(mon, FALSE);
+        (void) rloc(mon, TRUE);
     return 1;
 }
 
index 916fcdad347296c77e09bea070fbf8f4f4839b77..0e9851d24baaa5653ed2d9441d154f7989bb6c60 100644 (file)
@@ -245,7 +245,7 @@ register struct monst *mtmp;
         pline("%s says, \"Good hunting, %s.\"", Amonnam(mtmp),
               flags.female ? "Sister" : "Brother");
         if (!tele_restrict(mtmp))
-            (void) rloc(mtmp, FALSE);
+            (void) rloc(mtmp, TRUE);
         return (1);
     }
     cash = money_cnt(invent);
index 70787c7ccab2b608816211827dc67a8e7422f462..fefb03fb7fc326f79ba353ec867e469c0374ffe7 100644 (file)
@@ -386,7 +386,7 @@ register struct monst *mtmp;
     /* some monsters teleport */
     if (mtmp->mflee && !rn2(40) && can_teleport(mdat) && !mtmp->iswiz
         && !level.flags.noteleport) {
-        (void) rloc(mtmp, FALSE);
+        (void) rloc(mtmp, TRUE);
         return (0);
     }
     if (mdat->msound == MS_SHRIEK && !um_dist(mtmp->mx, mtmp->my, 1))
@@ -439,7 +439,7 @@ register struct monst *mtmp;
             if (is_demon(youmonst.data)) {
                 /* "Good hunting, brother" */
                 if (!tele_restrict(mtmp))
-                    (void) rloc(mtmp, FALSE);
+                    (void) rloc(mtmp, TRUE);
             } else {
                 mtmp->minvis = mtmp->perminvis = 0;
                 /* Why?  For the same reason in real demon talk */
@@ -821,7 +821,7 @@ register int after;
     if (ptr == &mons[PM_TENGU] && !rn2(5) && !mtmp->mcan
         && !tele_restrict(mtmp)) {
         if (mtmp->mhp < 7 || mtmp->mpeaceful || rn2(2))
-            (void) rloc(mtmp, FALSE);
+            (void) rloc(mtmp, TRUE);
         else
             mnexto(mtmp);
         mmoved = 1;
@@ -1192,7 +1192,7 @@ not_special:
             worm_move(mtmp);
     } else {
         if (is_unicorn(ptr) && rn2(2) && !tele_restrict(mtmp)) {
-            (void) rloc(mtmp, FALSE);
+            (void) rloc(mtmp, TRUE);
             return (1);
         }
         if (mtmp->wormno)
index a77fe188335cbb1d9a723881238b8674a1cfa53f..e94b197ee15c8e353239b641c41665aab6d2fad1 100644 (file)
@@ -646,7 +646,7 @@ struct monst *mtmp;
         }
         if (oseen && how)
             makeknown(how);
-        (void) rloc(mtmp, FALSE);
+        (void) rloc(mtmp, TRUE);
         return 2;
     case MUSE_WAN_TELEPORTATION:
         zap_oseen = oseen;
@@ -1238,7 +1238,7 @@ register struct obj *otmp;
                 if (cansee(mtmp->mx, mtmp->my))
                     pline("%s resists the magic!", Monnam(mtmp));
             } else if (!tele_restrict(mtmp))
-                (void) rloc(mtmp, FALSE);
+                (void) rloc(mtmp, TRUE);
         }
         break;
     case WAN_CANCELLATION:
index eb251ba925b2835de3cd615658011f57395e732b..eef47b98d6ca51c2772c9a36030a33b0ceca2c26 100644 (file)
@@ -116,7 +116,7 @@ register struct monst *mtmp;
               (Levitation || Flying) ? "beneath" : "between", whose, what);
         if (!ygold || !rn2(5)) {
             if (!tele_restrict(mtmp))
-                (void) rloc(mtmp, FALSE);
+                (void) rloc(mtmp, TRUE);
             monflee(mtmp, 0, FALSE, FALSE);
         }
     } else if (ygold) {
@@ -131,7 +131,7 @@ register struct monst *mtmp;
         add_to_minv(mtmp, ygold);
         Your("purse feels lighter.");
         if (!tele_restrict(mtmp))
-            (void) rloc(mtmp, FALSE);
+            (void) rloc(mtmp, TRUE);
         monflee(mtmp, 0, FALSE, FALSE);
         context.botl = 1;
     }
@@ -164,7 +164,7 @@ stealarm(VOID_ARGS)
                        so we don't set mavenge bit here. */
                     monflee(mtmp, 0, FALSE, FALSE);
                     if (!tele_restrict(mtmp))
-                        (void) rloc(mtmp, FALSE);
+                        (void) rloc(mtmp, TRUE);
                     break;
                 }
             }
@@ -554,7 +554,7 @@ struct monst *mtmp;
         (void) mpickobj(mtmp, otmp); /* may merge and free otmp */
         pline("%s stole %s!", Monnam(mtmp), doname(otmp));
         if (can_teleport(mtmp->data) && !tele_restrict(mtmp))
-            (void) rloc(mtmp, FALSE);
+            (void) rloc(mtmp, TRUE);
     }
 }
 
index 04d98392ca4a4d0b37bf43aa8cf761626cee6ef0..61f45a0c18d2cc1541ad2de669d25553a0dc23b7 100644 (file)
@@ -1068,7 +1068,7 @@ struct monst *mtmp;
         rloc_to(mtmp, c.x, c.y);
         return;
     }
-    (void) rloc(mtmp, FALSE);
+    (void) rloc(mtmp, TRUE);
 }
 
 boolean
@@ -1105,7 +1105,7 @@ int in_sight;
         if (trap->once)
             mvault_tele(mtmp);
         else
-            (void) rloc(mtmp, FALSE);
+            (void) rloc(mtmp, TRUE);
 
         if (in_sight) {
             if (canseemon(mtmp))
@@ -1333,12 +1333,12 @@ boolean give_feedback;
         if (give_feedback)
             You("are no longer inside %s!", mon_nam(mtmp));
         unstuck(mtmp);
-        (void) rloc(mtmp, FALSE);
+        (void) rloc(mtmp, TRUE);
     } else if (is_rider(mtmp->data) && rn2(13)
                && enexto(&cc, u.ux, u.uy, mtmp->data))
         rloc_to(mtmp, cc.x, cc.y);
     else
-        (void) rloc(mtmp, FALSE);
+        (void) rloc(mtmp, TRUE);
     return TRUE;
 }
 
index d82bdd66235aef6b90330ab87751a70496c269e7..2d0480764ddb24ce42c7232eaeac483a50e874d7 100644 (file)
@@ -614,7 +614,7 @@ register struct monst *grd;
             if (u_carry_gold) { /* player teleported */
                 m = grd->mx;
                 n = grd->my;
-                (void) rloc(grd, FALSE);
+                (void) rloc(grd, TRUE);
                 levl[m][n].typ = egrd->fakecorr[0].ftyp;
                 newsym(m, n);
                 grd->mpeaceful = 0;
index f4ee623cf66b27a0f3d834cb565afe72cd90a887..aa014649052d5d8e92c2a9acaabdff37476aa3b9 100644 (file)
@@ -326,7 +326,7 @@ register struct monst *mtmp;
         if (In_W_tower(mtmp->mx, mtmp->my, &u.uz)
             || (mtmp->iswiz && !xupstair && !mon_has_amulet(mtmp))) {
             if (!rn2(3 + mtmp->mhp / 10))
-                (void) rloc(mtmp, FALSE);
+                (void) rloc(mtmp, TRUE);
         } else if (xupstair
                    && (mtmp->mx != xupstair || mtmp->my != yupstair)) {
             (void) mnearto(mtmp, xupstair, yupstair, TRUE);