check_leash's handling of 2nd leash
Noticed by code inspection: the inventory scan to find leashes in use didn't reset the monster traversal loop for each leash, so with more than one active it wouldn't necessarily find and check the monster attached to the second one.
This commit is contained in:
@@ -254,6 +254,7 @@ show correct gender in ^X display when polymorphed into non-humanoid form
|
||||
for wizard and explore modes, skip second screen of ^X output when first
|
||||
screen is cancelled by ESC
|
||||
polyself into minotaur causes hard headgear to fall off
|
||||
with multiple leashes in use, 2nd had 50/50 chance of having unbounded length
|
||||
|
||||
|
||||
Platform- and/or Interface-Specific Fixes
|
||||
|
||||
68
src/apply.c
68
src/apply.c
@@ -530,44 +530,44 @@ check_leash(x, y)
|
||||
register xchar x, y;
|
||||
{
|
||||
register struct obj *otmp;
|
||||
register struct monst *mtmp = fmon;
|
||||
register struct monst *mtmp;
|
||||
|
||||
for(otmp = invent; otmp; otmp = otmp->nobj)
|
||||
if(otmp->otyp == LEASH && otmp->leashmon != 0) {
|
||||
while(mtmp) {
|
||||
if(!DEADMONSTER(mtmp) && ((int)mtmp->m_id == otmp->leashmon &&
|
||||
(dist2(u.ux,u.uy,mtmp->mx,mtmp->my) >
|
||||
dist2(x,y,mtmp->mx,mtmp->my)))
|
||||
) {
|
||||
if(otmp->cursed && !breathless(mtmp->data)) {
|
||||
if(um_dist(mtmp->mx, mtmp->my, 5)) {
|
||||
pline("%s chokes to death!",Monnam(mtmp));
|
||||
mondied(mtmp);
|
||||
} else
|
||||
if(um_dist(mtmp->mx, mtmp->my, 3))
|
||||
pline("%s chokes on the leash!",
|
||||
Monnam(mtmp));
|
||||
} else {
|
||||
if(um_dist(mtmp->mx, mtmp->my, 5)) {
|
||||
pline("%s leash snaps loose!",
|
||||
s_suffix(Monnam(mtmp)));
|
||||
m_unleash(mtmp, FALSE);
|
||||
} else {
|
||||
if(um_dist(mtmp->mx, mtmp->my, 3)) {
|
||||
You("pull on the leash.");
|
||||
if (mtmp->data->msound != MS_SILENT)
|
||||
switch(rn2(3)) {
|
||||
case 0: growl(mtmp); break;
|
||||
case 1: yelp(mtmp); break;
|
||||
default: whimper(mtmp); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (otmp = invent; otmp; otmp = otmp->nobj) {
|
||||
if (otmp->otyp != LEASH || otmp->leashmon == 0) continue;
|
||||
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
|
||||
if (DEADMONSTER(mtmp)) continue;
|
||||
if ((int)mtmp->m_id == otmp->leashmon) break;
|
||||
}
|
||||
if (!mtmp) {
|
||||
impossible("leash in use isn't attached to anything?");
|
||||
otmp->leashmon = 0;
|
||||
continue;
|
||||
}
|
||||
if (dist2(u.ux,u.uy,mtmp->mx,mtmp->my) >
|
||||
dist2(x,y,mtmp->mx,mtmp->my)) {
|
||||
if (otmp->cursed && !breathless(mtmp->data)) {
|
||||
if (um_dist(mtmp->mx, mtmp->my, 5)) {
|
||||
pline("%s chokes to death!", Monnam(mtmp));
|
||||
mondied(mtmp);
|
||||
} else if (um_dist(mtmp->mx, mtmp->my, 3)) {
|
||||
pline("%s chokes on the leash!", Monnam(mtmp));
|
||||
}
|
||||
} else {
|
||||
if (um_dist(mtmp->mx, mtmp->my, 5)) {
|
||||
pline("%s leash snaps loose!", s_suffix(Monnam(mtmp)));
|
||||
m_unleash(mtmp, FALSE);
|
||||
} else if (um_dist(mtmp->mx, mtmp->my, 3)) {
|
||||
You("pull on the leash.");
|
||||
if (mtmp->data->msound != MS_SILENT)
|
||||
switch (rn2(3)) {
|
||||
case 0: growl(mtmp); break;
|
||||
case 1: yelp(mtmp); break;
|
||||
default: whimper(mtmp); break;
|
||||
}
|
||||
}
|
||||
mtmp = mtmp->nmon;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* OVL0 */
|
||||
|
||||
Reference in New Issue
Block a user