src/dog: Fix TIN or EGG based corpsenm

TIN or EGG can have the corpsenm not assigned into a
proper monster and instead have an value of -1.

Take this into account in assigning the monster (fptr)
pointer to only point into >= LOW_PM monste entries.
This commit is contained in:
Mika Kuoppala
2023-12-13 19:11:13 +02:00
committed by PatR
parent 21068b05c5
commit 5cfa4cd9f6

View File

@@ -931,14 +931,15 @@ dogfood(struct monst *mon, struct obj *obj)
fx = (obj->otyp == CORPSE || obj->otyp == TIN || obj->otyp == EGG)
? obj->corpsenm
: NUMMONS; /* valid mons[mndx] to pacify static analyzer */
fptr = &mons[fx];
fptr = fx >= LOW_PM ? &mons[fx] : NULL;
if (obj->otyp == CORPSE && is_rider(fptr))
return TABU;
if ((obj->otyp == CORPSE || obj->otyp == EGG)
/* Medusa's corpse doesn't pass the touch_petrifies() test
but does cause petrification if eaten */
&& (touch_petrifies(fptr) || obj->corpsenm == PM_MEDUSA)
&& ((fptr && touch_petrifies(fptr)) || obj->corpsenm == PM_MEDUSA)
&& !resists_ston(mon))
return POISON;
if (obj->otyp == LUMP_OF_ROYAL_JELLY