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:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user