From: Pasi Kallinen Date: Mon, 19 Nov 2018 19:54:32 +0000 (+0200) Subject: Explicitly remove long worm segments from the map X-Git-Tag: nmake-explicit-path~160 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b0428321b8f8448ddb572dc13561aca1250e71aa;p=nethack Explicitly remove long worm segments from the map When a long worm was removed from the map, the segments for that worm retained their map location info. This caused problems later on if wormgone (or toss_wsegs) was called, because it would try to remove the segments of that worm from the map. --- diff --git a/src/worm.c b/src/worm.c index 427ccd04f..b2bf598dc 100644 --- a/src/worm.c +++ b/src/worm.c @@ -596,10 +596,12 @@ struct monst *worm; curr = wtails[worm->wormno]; while (curr != wheads[worm->wormno]) { - if (!isok(curr->wx, curr->wy)) - panic("worm seg not isok"); - if (level.monsters[curr->wx][curr->wy] != worm) - panic("worm not at seg location"); + if (curr->wx) { + if (!isok(curr->wx, curr->wy)) + panic("worm seg not isok"); + if (level.monsters[curr->wx][curr->wy] != worm) + panic("worm not at seg location"); + } curr = curr->nseg; } } @@ -621,8 +623,11 @@ register struct monst *worm; /* if (!mtmp->wormno) return; bullet proofing */ while (curr) { - remove_monster(curr->wx, curr->wy); - newsym(curr->wx, curr->wy); + if (curr->wx) { + remove_monster(curr->wx, curr->wy); + newsym(curr->wx, curr->wy); + curr->wx = 0; + } curr = curr->nseg; } }