simplify unpunish()
unpunish() duplicated much of delobj() in order to use dealloc_obj(). Switch to delobj(). That required a fix to feel_location() when it was called by savebones() after vision is turned disabled.
This commit is contained in:
+19
-13
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 display.c $NHDT-Date: 1652391730 2022/05/12 21:42:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.183 $ */
|
/* NetHack 3.7 display.c $NHDT-Date: 1654931503 2022/06/11 07:11:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.184 $ */
|
||||||
/* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */
|
/* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */
|
||||||
/* and Dave Cohrs, 1990. */
|
/* and Dave Cohrs, 1990. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -769,19 +769,25 @@ feel_location(xchar x, xchar y)
|
|||||||
* something has been dropped on the ball/chain. If the bit is
|
* something has been dropped on the ball/chain. If the bit is
|
||||||
* not cleared, then when the ball/chain is moved it will drop
|
* not cleared, then when the ball/chain is moved it will drop
|
||||||
* the wrong glyph.
|
* the wrong glyph.
|
||||||
|
*
|
||||||
|
* Note: during unpunish() we can be called by delobj() when
|
||||||
|
* destroying uchain while uball hasn't been cleared yet (so
|
||||||
|
* Punished will still yield True but uchain might not be part
|
||||||
|
* of the floor list anymore).
|
||||||
*/
|
*/
|
||||||
if (uchain->ox == x && uchain->oy == y) {
|
if (uchain && uchain->where == OBJ_FLOOR
|
||||||
if (g.level.objects[x][y] == uchain)
|
&& uchain->ox == x && uchain->oy == y
|
||||||
u.bc_felt |= BC_CHAIN;
|
&& g.level.objects[x][y] == uchain)
|
||||||
else
|
u.bc_felt |= BC_CHAIN;
|
||||||
u.bc_felt &= ~BC_CHAIN; /* do not feel the chain */
|
else
|
||||||
}
|
u.bc_felt &= ~BC_CHAIN; /* do not feel the chain */
|
||||||
if (!carried(uball) && uball->ox == x && uball->oy == y) {
|
|
||||||
if (g.level.objects[x][y] == uball)
|
if (uball && uball->where == OBJ_FLOOR
|
||||||
u.bc_felt |= BC_BALL;
|
&& uball->ox == x && uball->oy == y
|
||||||
else
|
&& g.level.objects[x][y] == uball)
|
||||||
u.bc_felt &= ~BC_BALL; /* do not feel the ball */
|
u.bc_felt |= BC_BALL;
|
||||||
}
|
else
|
||||||
|
u.bc_felt &= ~BC_BALL; /* do not feel the ball */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Floor spaces are dark if unlit. Corridors are dark if unlit. */
|
/* Floor spaces are dark if unlit. Corridors are dark if unlit. */
|
||||||
|
|||||||
+4
-5
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.7 read.c $NHDT-Date: 1637992351 2021/11/27 05:52:31 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.229 $ */
|
/* NetHack 3.7 read.c $NHDT-Date: 1654931501 2022/06/11 07:11:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.257 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -2833,11 +2833,10 @@ unpunish(void)
|
|||||||
struct obj *savechain = uchain;
|
struct obj *savechain = uchain;
|
||||||
|
|
||||||
/* chain goes away */
|
/* chain goes away */
|
||||||
obj_extract_self(uchain);
|
|
||||||
maybe_unhide_at(uchain->ox, uchain->oy);
|
|
||||||
newsym(uchain->ox, uchain->oy);
|
|
||||||
setworn((struct obj *) 0, W_CHAIN); /* sets 'uchain' to Null */
|
setworn((struct obj *) 0, W_CHAIN); /* sets 'uchain' to Null */
|
||||||
dealloc_obj(savechain);
|
/* for floor, unhides monster hidden under chain, calls newsym() */
|
||||||
|
delobj(savechain);
|
||||||
|
|
||||||
/* the chain is gone but the no longer attached ball persists */
|
/* the chain is gone but the no longer attached ball persists */
|
||||||
setworn((struct obj *) 0, W_BALL); /* sets 'uball' to Null */
|
setworn((struct obj *) 0, W_BALL); /* sets 'uball' to Null */
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user