From 407696c305de990216b42cc4e37fd1653a6882bf Mon Sep 17 00:00:00 2001 From: arromdee Date: Fri, 3 May 2002 03:47:39 +0000 Subject: [PATCH] worm display bug 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 | 2 ++ src/teleport.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/fixes34.1 b/doc/fixes34.1 index 6fbf4a557..10bbe5da6 100644 --- a/doc/fixes34.1 +++ b/doc/fixes34.1 @@ -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 diff --git a/src/teleport.c b/src/teleport.c index 49730f279..ece66dc35 100644 --- a/src/teleport.c +++ b/src/teleport.c @@ -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; -- 2.40.0