fix put request #377 - worm mismanagement

An earlier change resulted in place_worm_tail_randomly() sometimes
removing a long worm from the map unintentionally.  It was still on
the monster list so if wizard mode sanity_check option was On, there
would be warnings of a monster which isn't on the map.

The change which triggered this was necessary so I'm inclined to
blame place_worm_tail_randomly() laziness.

This is a superset of the pull request's fix.

Fixes #377
This commit is contained in:
PatR
2020-08-07 16:05:11 -07:00
parent 5851888ba5
commit e1cab093bd
2 changed files with 20 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.276 $ $NHDT-Date: 1596785361 2020/08/07 07:29:21 $
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.277 $ $NHDT-Date: 1596841504 2020/08/07 23:05:04 $
General Fixes and Modified Features
-----------------------------------
@@ -313,6 +313,11 @@ some versions of tiles processing (not X11's) complained about the rename of
"{acid,blinding} venom" to "splash of {acid,blinding} venom"
wizard mode #timeout changed to show timed Displacement in 'can be timed in
normal play' section instead of 'timed via #wizintrinsic only' section
the fix to make worm visibility checks work as intended forced the coordinates
of the extra tail segment co-located with the worm monster to match
the worm instead of leaving it off the map; place_worm_tail_randomly()
reverses the segments and can throw some away if there isn't room,
but throwing away the extra segment removed the worm from the map
curses: 'msg_window' option wasn't functional for curses unless the binary
also included tty support

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 worm.c $NHDT-Date: 1596498230 2020/08/03 23:43:50 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.46 $ */
/* NetHack 3.7 worm.c $NHDT-Date: 1596841504 2020/08/07 23:05:04 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.47 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2009. */
/* NetHack may be freely redistributed. See license for details. */
@@ -727,6 +727,18 @@ xchar x, y;
impossible("place_worm_tail_randomly: wormno is set without a tail!");
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)
impossible(
"place_worm_tail_randomly: tail segement at <%d,%d>, worm at <%d,%d>",
curr->wx, curr->wy, worm->mx, worm->my);
return;
}
/* remove head segment from map in case we end up calling toss_wsegs();
if it doesn't get tossed, it will become the final tail segment and
get new coordinates */
wheads[wnum]->wx = wheads[wnum]->wy = 0;
wheads[wnum] = new_tail = curr;
curr = curr->nseg;
@@ -736,7 +748,7 @@ xchar x, y;
while (curr) {
xchar nx, ny;
char tryct = 0;
int tryct = 0;
/* pick a random direction from x, y and search for goodpos() */
do {