more wormgone
When wormgone() takes a long worm off the map, clear its stale mx,my coordinates. None of its callers need those anymore. Also a bit of potential long worm clean up that occurred to me when I looked at object bypass handling. Expected to be a no-op here.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 dog.c $NHDT-Date: 1652524227 2022/05/14 10:30:27 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.119 $ */
|
/* NetHack 3.7 dog.c $NHDT-Date: 1652577033 2022/05/15 01:10:33 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.120 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -609,9 +609,7 @@ mon_leave(struct monst *mtmp)
|
|||||||
more segments than can fit in that field gets truncated */
|
more segments than can fit in that field gets truncated */
|
||||||
num_segs = min(cnt, MAX_NUM_WORMS - 1);
|
num_segs = min(cnt, MAX_NUM_WORMS - 1);
|
||||||
wormgone(mtmp); /* discard tail segments, take head off map */
|
wormgone(mtmp); /* discard tail segments, take head off map */
|
||||||
/* this used to be place_monster() but relmon() doesn't
|
/* mtmp->mx,mtmp->my is now 0,0 */
|
||||||
need that as long as coordinates reflect actual state */
|
|
||||||
mtmp->mx = mtmp->my = 0; /* off normal map */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return num_segs;
|
return num_segs;
|
||||||
@@ -722,14 +720,13 @@ migrate_to_level(
|
|||||||
xchar xyflags, mx = mtmp->mx, my = mtmp->my; /* <mx,my> needed below */
|
xchar xyflags, mx = mtmp->mx, my = mtmp->my; /* <mx,my> needed below */
|
||||||
int num_segs; /* count of worm segments */
|
int num_segs; /* count of worm segments */
|
||||||
|
|
||||||
/* prepare to take mtmp off the map */
|
|
||||||
num_segs = mon_leave(mtmp);
|
|
||||||
|
|
||||||
if (mtmp->mleashed) {
|
if (mtmp->mleashed) {
|
||||||
mtmp->mtame--;
|
mtmp->mtame--;
|
||||||
m_unleash(mtmp, TRUE);
|
m_unleash(mtmp, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* prepare to take mtmp off the map */
|
||||||
|
num_segs = mon_leave(mtmp);
|
||||||
/* take off map and move mtmp from fmon list to migrating_mons */
|
/* take off map and move mtmp from fmon list to migrating_mons */
|
||||||
relmon(mtmp, &g.migrating_mons); /* mtmp->mx,my get changed to 0,0 */
|
relmon(mtmp, &g.migrating_mons); /* mtmp->mx,my get changed to 0,0 */
|
||||||
mtmp->mstate |= MON_MIGRATING;
|
mtmp->mstate |= MON_MIGRATING;
|
||||||
|
|||||||
+21
-6
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 worm.c $NHDT-Date: 1608236444 2020/12/17 20:20:44 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.49 $ */
|
/* NetHack 3.7 worm.c $NHDT-Date: 1652577033 2022/05/15 01:10:33 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.55 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2009. */
|
/*-Copyright (c) Robert Patrick Rankin, 2009. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -297,23 +297,38 @@ worm_nomove(struct monst *worm)
|
|||||||
/*
|
/*
|
||||||
* wormgone()
|
* wormgone()
|
||||||
*
|
*
|
||||||
* Check for mon->wormno before calling this function!
|
* Kill a worm tail. Also takes the head off the map. Caller needs to
|
||||||
|
* keep track of what its coordinates were if planning to put it back.
|
||||||
*
|
*
|
||||||
* Kill a worm tail.
|
* Should only be called when mon->wormno is non-zero.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
wormgone(struct monst *worm)
|
wormgone(struct monst *worm)
|
||||||
{
|
{
|
||||||
int wnum = worm->wormno;
|
int wnum = worm->wormno;
|
||||||
|
|
||||||
worm->wormno = 0;
|
if (!wnum) /* note: continuing with wnum==0 runs to completion */
|
||||||
/* This will also remove the real monster (ie 'w') from the its
|
impossible("wormgone: wormno is 0");
|
||||||
* position in level.monsters[][].
|
|
||||||
|
worm->wormno = 0; /* still a long worm but doesn't grow/shrink anymore */
|
||||||
|
/*
|
||||||
|
* This will also remove the real monster (ie 'w') from the its
|
||||||
|
* position in level.monsters[][]. (That happens when removing
|
||||||
|
* the hidden tail segment which is co-located with the head.)
|
||||||
*/
|
*/
|
||||||
toss_wsegs(wtails[wnum], TRUE);
|
toss_wsegs(wtails[wnum], TRUE);
|
||||||
|
worm->mx = worm->my = 0; /* 'worm' is no longer on map but has not
|
||||||
|
* been killed off; caller might put it back */
|
||||||
|
|
||||||
wheads[wnum] = wtails[wnum] = (struct wseg *) 0;
|
wheads[wnum] = wtails[wnum] = (struct wseg *) 0;
|
||||||
wgrowtime[wnum] = 0L;
|
wgrowtime[wnum] = 0L;
|
||||||
|
|
||||||
|
/* we don't expect to encounter this here but check for it anyway;
|
||||||
|
when a long worm gets created by a polymorph zap, it gets flagged
|
||||||
|
with MCORPSENM()==PM_LONG_WORM so that the same zap won't trigger
|
||||||
|
another polymorph if it hits the new tail */
|
||||||
|
if (worm->data == &mons[PM_LONG_WORM] && has_mcorpsenm(worm))
|
||||||
|
MCORPSENM(worm) = NON_PM; /* not polymorph-proof */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+4
-3
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 worn.c $NHDT-Date: 1649529637 2022/04/09 18:40:37 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.82 $ */
|
/* NetHack 3.7 worn.c $NHDT-Date: 1652577035 2022/05/15 01:10:35 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.84 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2013. */
|
/*-Copyright (c) Robert Patrick Rankin, 2013. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -860,8 +860,9 @@ bypass_obj(struct obj *obj)
|
|||||||
|
|
||||||
/* set or clear the bypass bit in a list of objects */
|
/* set or clear the bypass bit in a list of objects */
|
||||||
void
|
void
|
||||||
bypass_objlist(struct obj *objchain,
|
bypass_objlist(
|
||||||
boolean on) /* TRUE => set, FALSE => clear */
|
struct obj *objchain,
|
||||||
|
boolean on) /* TRUE => set, FALSE => clear */
|
||||||
{
|
{
|
||||||
if (on && objchain)
|
if (on && objchain)
|
||||||
g.context.bypasses = TRUE;
|
g.context.bypasses = TRUE;
|
||||||
|
|||||||
Reference in New Issue
Block a user