]> granicus.if.org Git - nethack/commitdiff
'Iu' vs unknown container contents
authorPatR <rankin@nethack.org>
Thu, 8 Feb 2018 01:31:44 +0000 (17:31 -0800)
committerPatR <rankin@nethack.org>
Thu, 8 Feb 2018 01:31:44 +0000 (17:31 -0800)
An inventory of unpaid items where more than one was present would
show
|> bag's contents    N zorkmids
if any of the items were inside a container whose contents aren't
known.  But if there was only one item (so container must be owned
by hero) the 'Iu' output menu was skipped for pline and yielded
|> scroll of magic mapping   133 zorkmids
Force the menu display if the lone unpaid item is inside a container
whose contents are unknown.

I'm not sure whether a hero-owned container can have both unknown
contents and an unpaid item in normal play.  I managed it while
trying to fix a reported problem--except I can no longer find the
relevant report--where itemized shop billing also revealed unseen
container contents (for any number of items, not just 1).  That isn't
fixed yet, but I want to get the simpler 'Iu' part out of the way.

doc/fixes36.1
include/extern.h
src/invent.c
src/mkobj.c

index 9e430def88f612db74b2d92a11874c5f61e086ab..9b8633956849395cf2c5854942f44e50711a8b62 100644 (file)
@@ -507,6 +507,8 @@ shopkeepers in their own shop and priests in their own temple are no longer
        frightened by hero standing on scroll of scare monster
 the Wizard, Angels and lawful minions, the Riders, shopkeep/priest in own room
        are never frightened by tooled horns
+'Iu' would reveal unknown container contents if carrying one unpaid item inside
+       a hero-owned container whose contents weren't known
 
 
 Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository
index afbf4e498152dffe88bb6ca211edf7cbbdc06ea1..24a0c06cdc26ecc7bf66bdcf7ba4197b88c92167 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 extern.h        $NHDT-Date: 1517128658 2018/01/28 08:37:38 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.624 $ */
+/* NetHack 3.6 extern.h        $NHDT-Date: 1518053385 2018/02/08 01:29:45 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.625 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1284,6 +1284,7 @@ E struct obj *FDECL(splitobj, (struct obj *, long));
 E struct obj *FDECL(unsplitobj, (struct obj *));
 E void NDECL(clear_splitobjs);
 E void FDECL(replace_object, (struct obj *, struct obj *));
+E struct obj *FDECL(unknwn_contnr_contents, (struct obj *));
 E void FDECL(bill_dummy_object, (struct obj *));
 E void FDECL(costly_alteration, (struct obj *, int));
 E struct obj *FDECL(mksobj, (int, BOOLEAN_P, BOOLEAN_P));
index 89d823eec305a7091cb1e6473b59f378f8159a1e..828a947df119a2000e7121c25ad8a6d19edfaba0 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 invent.c        $NHDT-Date: 1512473628 2017/12/05 11:33:48 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.223 $ */
+/* NetHack 3.6 invent.c        $NHDT-Date: 1518053384 2018/02/08 01:29:44 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.224 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2541,22 +2541,26 @@ STATIC_OVL void
 dounpaid()
 {
     winid win;
-    struct obj *otmp, *marker;
+    struct obj *otmp, *marker, *contnr;
     register char ilet;
     char *invlet = flags.inv_order;
     int classcount, count, num_so_far;
     long cost, totcost;
 
     count = count_unpaid(invent);
+    otmp = marker = contnr = (struct obj *) 0;
 
     if (count == 1) {
-        marker = (struct obj *) 0;
         otmp = find_unpaid(invent, &marker);
+        contnr = unknwn_contnr_contents(otmp);
+    }
+    if  (otmp && !contnr) {
+        /* 1 item; use pline instead of popup menu */
         cost = unpaid_cost(otmp, FALSE);
         iflags.suppress_price++; /* suppress "(unpaid)" suffix */
         pline1(xprname(otmp, distant_name(otmp, doname),
-                       carried(otmp) ? otmp->invlet : CONTAINED_SYM, TRUE,
-                       cost, 0L));
+                       carried(otmp) ? otmp->invlet : CONTAINED_SYM,
+                       TRUE, cost, 0L));
         iflags.suppress_price--;
         return;
     }
index 567b845280f550bc36c9dd1b5c2f733dbbebf36f..ee692811138dd03a2a7e78ab838ad13c7b9fb985 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mkobj.c $NHDT-Date: 1513298759 2017/12/15 00:45:59 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.129 $ */
+/* NetHack 3.6 mkobj.c $NHDT-Date: 1518053380 2018/02/08 01:29:40 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.130 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -579,6 +579,23 @@ struct obj *otmp;
     }
 }
 
+/* is 'obj' inside a container whose contents aren't known?
+   if so, return the outermost container meeting that criterium */
+struct obj *
+unknwn_contnr_contents(obj)
+struct obj *obj;
+{
+    struct obj *result = 0, *parent;
+
+    while (obj->where == OBJ_CONTAINED) {
+        parent = obj->ocontainer;
+        if (!parent->cknown)
+            result = parent;
+        obj = parent;
+    }
+    return result;
+}
+
 /*
  * Create a dummy duplicate to put on shop bill.  The duplicate exists
  * only in the billobjs chain.  This function is used when a shop object