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:
PatR
2024-04-30 13:27:10 -07:00
parent 37a7e62be5
commit 6ebc3a7291
5 changed files with 75 additions and 7 deletions

View File

@@ -702,10 +702,10 @@ o_unleash(struct obj *otmp)
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
if (mtmp->m_id == (unsigned) otmp->leashmon) {
mtmp->mleashed = 0;
otmp->leashmon = 0;
update_inventory();
break;
}
otmp->leashmon = 0;
update_inventory();
}
/* mtmp is about to die, or become untame */