container->{cknown,lknown) vs perm_invent

Carried containers could have their contents-known state and/or
lock-known state changed without persistent inventory window being
updated to show the new information.

This also changes the behavior when player has hero zap self with
wand of locking or wizard lock spell.  If it doesn't trigger a
holding trap then the effect will hit inventory, similar to how
opening/knock operates (releasing hero from holding trap or hiting
inventory when that doesn't happen).
This commit is contained in:
PatR
2019-06-04 12:13:46 -07:00
parent 43afa91ff8
commit 093e7c31e4
4 changed files with 54 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.35 $ $NHDT-Date: 1559670600 2019/06/04 17:50:00 $
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.36 $ $NHDT-Date: 1559675614 2019/06/04 19:13:34 $
This fixes36.3 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.2 in May 2019. Please note, however,
@@ -46,6 +46,8 @@ various cases where objects had their bless/curse state become known weren't
updating persistent inventory window, when enabled, to reflect changes
(cited case was trying to remove cursed armor and being told of the
curse but there were lots of other situations with the same issue)
similar perm_invent issue when lock state known and/or contents known become
set for carried container
Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 end.c $NHDT-Date: 1559664950 2019/06/04 16:15:50 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.175 $ */
/* NetHack 3.6 end.c $NHDT-Date: 1559675615 2019/06/04 19:13:35 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.176 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1621,9 +1621,12 @@ boolean identified, all_containers, reportempty;
for (box = list; box; box = box->nobj) {
if (Is_container(box) || box->otyp == STATUE) {
box->cknown = 1; /* we're looking at the contents now */
if (identified)
box->lknown = 1;
if (!box->cknown || (identified && !box->lknown)) {
box->cknown = 1; /* we're looking at the contents now */
if (identified)
box->lknown = 1;
update_inventory();
}
if (box->otyp == BAG_OF_TRICKS) {
continue; /* wrong type of container */
} else if (box->cobj) {

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 pickup.c $NHDT-Date: 1559670608 2019/06/04 17:50:08 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.227 $ */
/* NetHack 3.6 pickup.c $NHDT-Date: 1559675617 2019/06/04 19:13:37 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.228 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1704,7 +1704,7 @@ int cindex, ccount; /* index of this container (1..N), number of them (N) */
cobj->lknown = 1;
return 0;
}
cobj->lknown = 1;
cobj->lknown = 1; /* floor container, so no need for update_inventory() */
if (cobj->otyp == BAG_OF_TRICKS) {
int tmp;
@@ -2493,16 +2493,19 @@ boolean more_containers; /* True iff #loot multiple and this isn't last one */
if (!u_handsy())
return 0;
if (!obj->lknown) { /* do this in advance */
obj->lknown = 1;
if (held)
update_inventory();
}
if (obj->olocked) {
pline("%s locked.", Tobjnam(obj, "are"));
if (held)
You("must put it down to unlock.");
obj->lknown = 1;
return 0;
} else if (obj->otrapped) {
if (held)
You("open %s...", the(xname(obj)));
obj->lknown = 1;
(void) chest_trap(obj, HAND, FALSE);
/* even if the trap fails, you've used up this turn */
if (multi >= 0) { /* in case we didn't become paralyzed */
@@ -2513,7 +2516,6 @@ boolean more_containers; /* True iff #loot multiple and this isn't last one */
abort_looting = TRUE;
return 1;
}
obj->lknown = 1;
current_container = obj; /* for use by in/out_container */
/*
@@ -3105,7 +3107,11 @@ struct obj *box; /* or bag */
/* caveat: this assumes that cknown, lknown, olocked, and otrapped
fields haven't been overloaded to mean something special for the
non-standard "container" horn of plenty */
box->lknown = 1;
if (!box->lknown) {
box->lknown = 1;
if (carried(box))
update_inventory(); /* jumping the gun slightly; hope that's ok */
}
if (box->olocked) {
pline("It's locked.");
} else if (box->otrapped) {
@@ -3226,6 +3232,8 @@ struct obj *box; /* or bag */
if (held)
(void) encumber_msg();
}
if (carried(box)) /* box is now empty with cknown set */
update_inventory();
}
/*pickup.c*/

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 zap.c $NHDT-Date: 1551395521 2019/02/28 23:12:01 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.307 $ */
/* NetHack 3.6 zap.c $NHDT-Date: 1559675618 2019/06/04 19:13:38 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.309 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -126,6 +126,7 @@ struct obj *obj;
if (obj->dknown)
makeknown(obj->otyp);
}
update_inventory();
}
}
@@ -1899,9 +1900,9 @@ struct obj *obj, *otmp;
(void) boxlock(obj, otmp);
if (obj_shudders(obj)) {
boolean cover =
((obj == level.objects[u.ux][u.uy]) && u.uundetected
&& hides_under(youmonst.data));
boolean cover = ((obj == level.objects[u.ux][u.uy])
&& u.uundetected
&& hides_under(youmonst.data));
if (cansee(obj->ox, obj->oy))
learn_it = TRUE;
@@ -1934,6 +1935,7 @@ struct obj *obj, *otmp;
obj->cknown = 0;
} else {
struct obj *o;
/* view contents (not recursively) */
for (o = obj->cobj; o; o = o->nobj)
o->dknown = 1; /* "seen", even if blind */
@@ -2494,22 +2496,39 @@ boolean ordinary;
learn_it = TRUE;
unpunish();
}
if (u.utrap) { /* escape web or bear trap */
(void) openholdingtrap(&youmonst, &learn_it);
} else {
/* invent is hit iff hero doesn't escape from a trap */
if (!u.utrap || !openholdingtrap(&youmonst, &learn_it)) {
struct obj *otmp;
boolean boxing = FALSE;
/* unlock carried boxes */
for (otmp = invent; otmp; otmp = otmp->nobj)
if (Is_box(otmp))
if (Is_box(otmp)) {
(void) boxlock(otmp, obj);
boxing = TRUE;
}
if (boxing)
update_inventory(); /* in case any box->lknown has changed */
/* trigger previously escaped trapdoor */
(void) openfallingtrap(&youmonst, TRUE, &learn_it);
}
break;
case WAN_LOCKING:
case SPE_WIZARD_LOCK:
if (!u.utrap) {
(void) closeholdingtrap(&youmonst, &learn_it);
/* similar logic to opening; invent is hit iff no trap triggered */
if (u.utrap || !closeholdingtrap(&youmonst, &learn_it)) {
struct obj *otmp;
boolean boxing = FALSE;
/* lock carried boxes */
for (otmp = invent; otmp; otmp = otmp->nobj)
if (Is_box(otmp)) {
(void) boxlock(otmp, obj);
boxing = TRUE;
}
if (boxing)
update_inventory(); /* in case any box->lknown has changed */
}
break;
case WAN_DIGGING:
@@ -2528,6 +2547,7 @@ boolean ordinary;
otmp->cknown = 1;
}
}
update_inventory();
learn_it = TRUE;
ustatusline();
break;