Audit rloc()
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1655,7 +1655,7 @@ nopick:
|
||||
if (!Blind)
|
||||
pline1(buf);
|
||||
if (!tele_restrict(mon))
|
||||
(void) rloc(mon, FALSE);
|
||||
(void) rloc(mon, TRUE);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
12
src/mhitu.c
12
src/mhitu.c
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user