github PR #879 - pets eating shapeshifter corpses

Pull request from entrez:  the check for whether a pet in desperate
straits will eat a corpse that will cause it to polymorph used bad
logic.  The suspect code was added post-3.6.

Fixes #879
This commit is contained in:
PatR
2022-09-21 12:07:05 -07:00

View File

@@ -965,17 +965,11 @@ dogfood(struct monst *mon, struct obj *obj)
|| (acidic(fptr) && !resists_acid(mon))
|| (poisonous(fptr) && !resists_poison(mon)))
return POISON;
/* polymorphing is preferable to starvation, and pet might also
want to take its chances on that if they've been mistreated */
else if (is_shapeshifter(fptr)) {
if (mon->mtame == 1) {
/* A herbivore still won't eat a nonvegan corpse, but
in any other circumstance a pet with tameness 1 will
happily eat a shapeshifter. */
return (herbi && !vegan(fptr)) ? MANFOOD : CADAVER;
}
return starving ? ACCFOOD : MANFOOD;
} else if (vegan(fptr))
/* avoid polymorph unless starving or abused (in which case the
pet will consider it for a chance to become more powerful) */
else if (is_shapeshifter(fptr) && mon->mtame > 1 && !starving)
return MANFOOD;
else if (vegan(fptr))
return herbi ? CADAVER : MANFOOD;
/* most humanoids will avoid cannibalism unless starving;
arbitrary: elves won't eat other elves even then */