From 95f5e029d87064930dd6d17bd4ca741dfaca7d57 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Thu, 21 Apr 2011 00:29:26 +0000 Subject: [PATCH] avoid mkclass() infinite loop (trunk only) Back on Feb 28, I committed a patch to prevent the special level loader from generating mail daemons for levels which specified random demons. It had a pair of copy+paste mistakes that could result in mkclass() looping forever. It was looking at the same monster every time and if that monster was one which mustn't be generated, it would just keep repeating. --- src/makemon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/makemon.c b/src/makemon.c index 2b7a2846c..27db7259b 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -1430,7 +1430,7 @@ int spc; * order of strength. */ for(num = rnd(num); num > 0; first++) - if (mk_gen_ok(last, G_GONE, mask)) { + if (mk_gen_ok(first, G_GONE, mask)) { /* skew towards lower value monsters at lower exp. levels */ num -= mons[first].geno & G_FREQ; if (num && adj_lev(&mons[first]) > (u.ulevel*2)) { @@ -1465,7 +1465,7 @@ int class; if (!num) return NON_PM; for (num = rnd(num); num > 0; first++) - if (mk_gen_ok(last, G_GENOD, (G_NOGEN|G_UNIQ))) + if (mk_gen_ok(first, G_GENOD, (G_NOGEN|G_UNIQ))) num -= mons[first].geno & G_FREQ; first--; /* correct an off-by-one error */