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:
13
src/objnam.c
13
src/objnam.c
@@ -1407,11 +1407,16 @@ doname_base(
|
||||
if (obj->otyp == LEASH && obj->leashmon != 0) {
|
||||
struct monst *mlsh = find_mid(obj->leashmon, FM_FMON);
|
||||
|
||||
if (!mlsh) {
|
||||
impossible("leashed monster not on this level");
|
||||
obj->leashmon = 0;
|
||||
} else {
|
||||
if (mlsh && !DEADMONSTER(mlsh)) {
|
||||
ConcatF1(bp, 0, " (attached to %s)", noit_mon_nam(mlsh));
|
||||
} else {
|
||||
if (mlsh) /*&& DEADMONSTER(mlsh)*/
|
||||
impossible("leashed %s #%u is dead",
|
||||
mon_pmname(mlsh), (unsigned) obj->leashmon);
|
||||
else
|
||||
impossible("leashed monster #%u not found",
|
||||
(unsigned) obj->leashmon);
|
||||
obj->leashmon = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user