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.
This commit is contained in:
Pasi Kallinen
2018-11-19 21:54:35 +02:00
parent 2a439af336
commit b0428321b8
+11 -6
View File
@@ -596,10 +596,12 @@ struct monst *worm;
curr = wtails[worm->wormno]; curr = wtails[worm->wormno];
while (curr != wheads[worm->wormno]) { while (curr != wheads[worm->wormno]) {
if (!isok(curr->wx, curr->wy)) if (curr->wx) {
panic("worm seg not isok"); if (!isok(curr->wx, curr->wy))
if (level.monsters[curr->wx][curr->wy] != worm) panic("worm seg not isok");
panic("worm not at seg location"); if (level.monsters[curr->wx][curr->wy] != worm)
panic("worm not at seg location");
}
curr = curr->nseg; curr = curr->nseg;
} }
} }
@@ -621,8 +623,11 @@ register struct monst *worm;
/* if (!mtmp->wormno) return; bullet proofing */ /* if (!mtmp->wormno) return; bullet proofing */
while (curr) { while (curr) {
remove_monster(curr->wx, curr->wy); if (curr->wx) {
newsym(curr->wx, curr->wy); remove_monster(curr->wx, curr->wy);
newsym(curr->wx, curr->wy);
curr->wx = 0;
}
curr = curr->nseg; curr = curr->nseg;
} }
} }