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:
20
src/pickup.c
20
src/pickup.c
@@ -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*/
|
||||
|
||||
Reference in New Issue
Block a user