]> granicus.if.org Git - nethack/commitdiff
Explicitly remove long worm segments from the map
authorPasi Kallinen <paxed@alt.org>
Mon, 19 Nov 2018 19:54:32 +0000 (21:54 +0200)
committerPasi Kallinen <paxed@alt.org>
Mon, 19 Nov 2018 19:54:35 +0000 (21:54 +0200)
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.

src/worm.c

index 427ccd04f0261df4cd15ae6f0c2ba0e82ae363bc..b2bf598dc59748afaaf075b7b82531ce5911e978 100644 (file)
@@ -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;
     }
 }