leash sanity checking
I still haven't found any explanation for the report by a hardfought player recently that going down some stairs with a pair of leashed pets got one into a confused state where it was flagged as leashed but the corresponding leash was no longer in use. This adds some new object and monster sanity checks regarding leashes, and it changes o_unleash(obj) to clear obj->leashmon even if/when the monster can't be found. It also changes behavior for dipping an attached leash into a potion of polymorph when that happens to yield another leash--now the new one will end up being pre-attached.
This commit is contained in:
@@ -1769,6 +1769,16 @@ poly_obj(struct obj *obj, int id)
|
||||
otmp->cursed = FALSE;
|
||||
}
|
||||
}
|
||||
if (obj->otyp == LEASH && obj->leashmon != 0) {
|
||||
if (otmp->otyp == LEASH) {
|
||||
otmp->leashmon = obj->leashmon;
|
||||
/* clear m_id before delobj(), to avoid o_unleash() by obfree() */
|
||||
obj->leashmon = 0;
|
||||
} else {
|
||||
/* obfree() would do this if we didn't do it here */
|
||||
o_unleash(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/* no box contents --KAA */
|
||||
if (Has_contents(otmp))
|
||||
|
||||
Reference in New Issue
Block a user