]> granicus.if.org Git - nethack/commitdiff
fix the tail-less long worm placement warning
authorPatR <rankin@nethack.org>
Thu, 17 Dec 2020 20:21:35 +0000 (12:21 -0800)
committerPatR <rankin@nethack.org>
Thu, 17 Dec 2020 20:21:35 +0000 (12:21 -0800)
Hidden tail segment was taken off the map as intended but the
check and warning in place_wormtail_randonly() didn't expect
to see that.  A post-3.6 issue.

Also fix the spelling error in the warning message.

doc/fixes37.0
src/worm.c

index 696c3e1afedaf8e60c4f5f4c1b84abf24b6740e8..b873c083349463f8722f4843dae03924d4c3b158 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.393 $ $NHDT-Date: 1608175317 2020/12/17 03:21:57 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.394 $ $NHDT-Date: 1608236443 2020/12/17 20:20:43 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -433,6 +433,8 @@ fix genetic engineers dropping Schroedinger's cat box
 the checks and handling for fountains, sinks, and drawbridges were being
        missed during liquid_flow
 monster movement flags unification allowed displacer beasts to displace Riders
+a long worm with no visible segments (but one internal segment) might trigger
+       warning: tail 'segement' at <0,some_y>, worm at <mx,my> if teleported
 
 curses: 'msg_window' option wasn't functional for curses unless the binary
        also included tty support
index 9027f925b717076d6e2da688cbecf5a9d30bb19d..9081a9919bebccbfa84e703fbb071a17f0dfaf83 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 worm.c  $NHDT-Date: 1599559380 2020/09/08 10:03:00 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.48 $ */
+/* NetHack 3.7 worm.c  $NHDT-Date: 1608236444 2020/12/17 20:20:44 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.49 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2009. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -755,15 +755,17 @@ xchar x, y;
         return;
     }
     if (wtails[wnum] == wheads[wnum]) {
-        /* single segment, co-located with worm so nothing to place */
-        if (curr->wx != worm->mx || curr->wy != worm->my) {
+        /* single segment, co-located with worm;
+           should either have same coordinates or have seg->wx==0
+           to indicate that it is not currently on the map */
+        if (curr->wx && (curr->wx != worm->mx || curr->wy != worm->my)) {
             impossible(
-        "place_worm_tail_randomly: tail segement at <%d,%d>, worm at <%d,%d>",
+         "place_worm_tail_randomly: tail segment at <%d,%d>, worm at <%d,%d>",
                        curr->wx, curr->wy, worm->mx, worm->my);
             if (m_at(curr->wx, curr->wy) == worm)
                 remove_monster(curr->wx, curr->wy);
-            curr->wx = worm->mx, curr->wy = worm->my;
         }
+        curr->wx = worm->mx, curr->wy = worm->my;
         return;
     }
     /* remove head segment from map in case we end up calling toss_wsegs();