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
2024-01-06 12:06:54 -08:00
committed by PatR
parent 21068b05c5
commit 5cfa4cd9f6
+3 -2
View File
@@ -931,14 +931,15 @@ dogfood(struct monst *mon, struct obj *obj)
fx = (obj->otyp == CORPSE || obj->otyp == TIN || obj->otyp == EGG) fx = (obj->otyp == CORPSE || obj->otyp == TIN || obj->otyp == EGG)
? obj->corpsenm ? obj->corpsenm
: NUMMONS; /* valid mons[mndx] to pacify static analyzer */ : 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)) if (obj->otyp == CORPSE && is_rider(fptr))
return TABU; return TABU;
if ((obj->otyp == CORPSE || obj->otyp == EGG) if ((obj->otyp == CORPSE || obj->otyp == EGG)
/* Medusa's corpse doesn't pass the touch_petrifies() test /* Medusa's corpse doesn't pass the touch_petrifies() test
but does cause petrification if eaten */ but does cause petrification if eaten */
&& (touch_petrifies(fptr) || obj->corpsenm == PM_MEDUSA) && ((fptr && touch_petrifies(fptr)) || obj->corpsenm == PM_MEDUSA)
&& !resists_ston(mon)) && !resists_ston(mon))
return POISON; return POISON;
if (obj->otyp == LUMP_OF_ROYAL_JELLY if (obj->otyp == LUMP_OF_ROYAL_JELLY