Prevent infinite loop making Medusa statues

While fuzzing, the game got stuck here trying to generate
a random stoneable monster for a Medusa level statue.
I didn't investigate deeper why it failed to find a matching
monster type.
This commit is contained in:
Pasi Kallinen
2023-03-28 19:49:49 +03:00
parent 0532eae7d2
commit 5c39096fd4

View File

@@ -593,8 +593,11 @@ fixup_special(void)
x = somex(croom);
y = somey(croom);
if (goodpos(x, y, (struct monst *) 0, 0)) {
int tryct2 = 0;
otmp = mk_tt_object(STATUE, x, y);
while (otmp && (poly_when_stoned(&mons[otmp->corpsenm])
while (++tryct2 < 100 && otmp
&& (poly_when_stoned(&mons[otmp->corpsenm])
|| pm_resistance(&mons[otmp->corpsenm],
MR_STONE))) {
/* set_corpsenm() handles weight too */
@@ -610,8 +613,10 @@ fixup_special(void)
mkcorpstat(STATUE, (struct monst *) 0, (struct permonst *) 0,
somex(croom), somey(croom), CORPSTAT_NONE);
if (otmp) {
while (pm_resistance(&mons[otmp->corpsenm], MR_STONE)
|| poly_when_stoned(&mons[otmp->corpsenm])) {
tryct = 0;
while (++tryct < 100
&& (pm_resistance(&mons[otmp->corpsenm], MR_STONE)
|| poly_when_stoned(&mons[otmp->corpsenm]))) {
/* set_corpsenm() handles weight too */
set_corpsenm(otmp, rndmonnum());
}