From: nethack.rankin Date: Sat, 25 Mar 2006 04:43:07 +0000 (+0000) Subject: chameleon/genocide fix (trunk only) X-Git-Tag: MOVE2GIT~1085 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8370782a1305125b10ee6d55a1fb6bf1e4e330dd;p=nethack chameleon/genocide fix (trunk only) 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. --- diff --git a/src/mon.c b/src/mon.c index dafaee257..a9e2890b7 100644 --- 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); }