]> granicus.if.org Git - nethack/commitdiff
worm display bug
authorarromdee <arromdee>
Fri, 3 May 2002 03:47:39 +0000 (03:47 +0000)
committerarromdee <arromdee>
Fri, 3 May 2002 03:47:39 +0000 (03:47 +0000)
This fixes a long worm display bug.  The bug wasn't really in the worm code, it
was in goodpos().  goodpos() could place worm segments on top of one another.
If you split a worm when the tail was located on top of the head, the tail
would be removed from the screen, making the head seem to vanish.

doc/fixes34.1
src/teleport.c

index 6fbf4a557468c6d93e43872ae94d9dab24c957b1..10bbe5da619fc145d61fc307435b42e6384fe283 100644 (file)
@@ -95,6 +95,8 @@ corpses in bones files don't retain their role characteristic
 boulder was not displayed if blind and discovered with a monster known via
        ESP behind it
 don't claim that statue comes to life if the monster it turns into is invisible
+fix goodpos() so worm segments don't get placed on top of each other (causing
+       a possible display problem if the worm is cut in two)
 
 
 Platform- and/or Interface-Specific Fixes
index 49730f279d7ea850a0e45eb52100a360c3da427b..ece66dc35841b917306d814185c69dce1c606b54 100644 (file)
@@ -42,7 +42,17 @@ struct monst *mtmp;
        if (mtmp) {
            struct monst *mtmp2 = m_at(x,y);
 
-           if (mtmp2 && mtmp2 != mtmp)
+           /* Be careful with long worms.  A monster may be placed back in
+            * its own location.  Normally, if m_at() returns the same monster
+            * that we're trying to place, the monster is being placed in its
+            * own location.  However, that is not correct for worm segments,
+            * because all the segments of the worm return the same m_at().
+            * Actually we overdo the check a little bit--a worm can't be placed
+            * in its own location, period.  If we just checked for mtmp->mx
+            * != x || mtmp->my != y, we'd miss the case where we're called
+            * to place the worm segment and the worm's head is at x,y.
+            */
+           if (mtmp2 && (mtmp2 != mtmp || mtmp->wormno))
                return FALSE;
 
            mdat = mtmp->data;