From: nethack.rankin Date: Thu, 21 Apr 2011 00:29:26 +0000 (+0000) Subject: avoid mkclass() infinite loop (trunk only) X-Git-Tag: MOVE2GIT~216 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=95f5e029d87064930dd6d17bd4ca741dfaca7d57;p=nethack 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. --- 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 */