]> granicus.if.org Git - nethack/commitdiff
chameleon/genocide fix (trunk only)
authornethack.rankin <nethack.rankin>
Sat, 25 Mar 2006 04:43:07 +0000 (04:43 +0000)
committernethack.rankin <nethack.rankin>
Sat, 25 Mar 2006 04:43:07 +0000 (04:43 +0000)
     While testing some pending teleport changes, I was baffled by having
my adjacent pet sometimes vanish when accompanying me on a level teleport.
Tracing through parts of execution:  keepdogs() kept it; losedogs() called
mon_arrive() which called place_monster() for it, but then right after that
kill_genocided_monsters() removed it.  Turns out that `kill_cham' was left
uninitialized for the first iteration through the fmon loop (and pet had
always just been inserted as first entry of the fmon list).

     No fixes entry; this revises a post-3.4.3 revision.

src/mon.c

index dafaee257c02f0e99c42e808722424814100e28d..a9e2890b74d766c0b4d3c9baab19a806703c1779 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mon.c      3.5     2005/07/13      */
+/*     SCCS Id: @(#)mon.c      3.5     2006/03/24      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2764,17 +2764,17 @@ kill_genocided_monsters()
         *      2) otherwise, force every chameleon which is imitating
         *         any genocided species to take on a new form.
         */
-       for (mtmp = fmon; mtmp; mtmp = mtmp2, kill_cham = FALSE) {
+       for (mtmp = fmon; mtmp; mtmp = mtmp2) {
            mtmp2 = mtmp->nmon;
            if (DEADMONSTER(mtmp)) continue;
            mndx = monsndx(mtmp->data);
-           if (mtmp->cham >= LOW_PM && (mvitals[mtmp->cham].mvflags & G_GENOD))
-               kill_cham = TRUE;
+           kill_cham = (mtmp->cham >= LOW_PM &&
+                         (mvitals[mtmp->cham].mvflags & G_GENOD));
            if ((mvitals[mndx].mvflags & G_GENOD) || kill_cham) {
-               if (mtmp->cham >= LOW_PM && !kill_cham)
-                       (void) newcham(mtmp, (struct permonst *)0, FALSE, FALSE);
+               if (mtmp->cham >= LOW_PM && !kill_cham)
+                   (void) newcham(mtmp, (struct permonst *)0, FALSE, FALSE);
                else
-                       mondead(mtmp);
+                   mondead(mtmp);
            }
            if (mtmp->minvent) kill_eggs(mtmp->minvent);
        }