From 31d86a8c418f2bbe50543ef5697d126bd04da51f Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 12 Mar 2025 01:28:05 -0700 Subject: [PATCH] trapped box->tknown If 'autounlock' is set to test a chest for traps, skip "check for traps?" when tknown is set; go directly to "disarm trap?" if the chest is trapped, skip that too if it isn't. If wand of probing hits a chest, set the tknown bit. --- src/lock.c | 13 +++---------- src/zap.c | 14 +++++++++----- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/lock.c b/src/lock.c index 47e160b7a..2fe2a198a 100644 --- a/src/lock.c +++ b/src/lock.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 lock.c $NHDT-Date: 1718745135 2024/06/18 21:12:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.137 $ */ +/* NetHack 3.7 lock.c $NHDT-Date: 1741793439 2025/03/12 07:30:39 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.145 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -432,14 +432,6 @@ pick_lock( boolean it; int count; - /* - * FIXME: - * (chest->otrapped && chest->tknown) is handled, to skip - * checking for a trap and continue with asking about disarm; - * (chest->tknown && !chest->otrapped) ignores tknown and will - * ask about checking for non-existant trap. - */ - if (u.dz < 0 && !autounlock) { /* beware stale u.dz value */ There("isn't any sort of lock up %s.", Levitation ? "here" : "there"); @@ -478,7 +470,8 @@ pick_lock( if (autounlock && (flags.autounlock & AUTOUNLOCK_UNTRAP) != 0 && could_untrap(FALSE, TRUE) - && (c = ynq(safe_qbuf(qbuf, "Check ", " for a trap?", + && (c = otmp->tknown ? (otmp->otrapped ? 'y' : 'n') + : ynq(safe_qbuf(qbuf, "Check ", " for a trap?", otmp, yname, ysimple_name, "this"))) != 'n') { if (c == 'q') diff --git a/src/zap.c b/src/zap.c index 3faf11645..7118ca4da 100644 --- a/src/zap.c +++ b/src/zap.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 zap.c $NHDT-Date: 1737344505 2025/01/19 19:41:45 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.562 $ */ +/* NetHack 3.7 zap.c $NHDT-Date: 1741793439 2025/03/12 07:30:39 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.564 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2209,10 +2209,14 @@ bhito(struct obj *obj, struct obj *otmp) obj->dknown = 1; if (Is_container(obj) || obj->otyp == STATUE) { obj->cknown = obj->lknown = 1; - /* plural handling here is superfluous because containers - and statues don't stack */ - if (obj->otrapped) - pline("%s trapped!", Tobjnam(obj, "are")); + if (Is_box(obj) && !obj->tknown) { + /* obj->tknown applies to boxes and chests, not bags or + statues; plural handling here and the "empty" case + below are superfluous because containers don't stack */ + if (obj->otrapped) + pline("%s trapped!", Tobjnam(obj, "are")); + obj->tknown = 1; + } if (!obj->cobj) { pline("%s empty.", Tobjnam(obj, "are"));