From 3a6e2a98020db6843e8cd4c3ef9f3bba11c51d2d Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 10 Jan 2020 04:36:28 -0800 Subject: [PATCH] escaping buried iron ball Noticed while testing the look-at-self feedback for traps. When punished and the iron ball gets buried, hero becomes "tethered to a buried object". It is possible to simply walk away (like from a pit, bear trap, web, stuck in floor by solidified lava or sinking into molten lava) but that requires many tries. Once the escape happens, "you finally wrench the ball free" and are supposed to have it reattached to a replacement chain. However, buried_ball() wouldn't look at buried objects if the trap countdown timer was 0 (which is the case when finally wrenching free). So hero got a new chain to drag around but it had no heavy iron ball attached. I didn't turn on sanity checking but that would have complained about this. Normal dragging didn't care but I wouldn't be surprised if various actions that checked Punished and picked up the ball in order to put it down again elsewhere would have had possibly serious trouble. --- doc/fixes37.0 | 6 +++++- src/dig.c | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 54669c251..f8bf80a07 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.58 $ $NHDT-Date: 1578624299 2020/01/10 02:44:59 $ +$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.59 $ $NHDT-Date: 1578659784 2020/01/10 12:36:24 $ General Fixes and Modified Features ----------------------------------- @@ -36,6 +36,10 @@ wizard mode wishing for "Amulet of Yendor" has 50:50 chance for true Amulet or a cheap plastic imitation; recognize "real Amulet of Yendor" and "fake Amulet of Yendor" to precisely specify either of them unpaid globs showed weight info unconditionally outside of wizmode +walking out of tethered-to-buried-object trap condition was supposed to + reinstate punishment but wasn't finding the buried iron ball because + the trap condition was cleared first to indicate escape; result was + attached chain that got dragged around but had no ball attached Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/src/dig.c b/src/dig.c index 802af8968..e86eb5eef 100644 --- a/src/dig.c +++ b/src/dig.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 dig.c $NHDT-Date: 1547421446 2019/01/13 23:17:26 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.117 $ */ +/* NetHack 3.6 dig.c $NHDT-Date: 1578659784 2020/01/10 12:36:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.135 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1741,7 +1741,10 @@ coord *cc; * only lets hero get one step away from the buried ball?] */ - if (u.utrap && u.utraptype == TT_BURIEDBALL) + /* u.utrap might have already been cleared, in which case the value + of u.utraptype is no longer meaningful; if u.utrap is still set + then u.utraptype needs to be for buried ball */ + if (!u.utrap || u.utraptype == TT_BURIEDBALL) { for (otmp = g.level.buriedobjlist; otmp; otmp = otmp->nobj) { if (otmp->otyp != HEAVY_IRON_BALL) continue; @@ -1760,6 +1763,7 @@ coord *cc; bdist = odist; } } + } if (ball) { /* found, but not at < cc->x, cc->y > */ cc->x = ball->ox;