]> granicus.if.org Git - nethack/commitdiff
redundant feedback for `I u'
authornethack.rankin <nethack.rankin>
Thu, 7 Apr 2005 03:32:48 +0000 (03:32 +0000)
committernethack.rankin <nethack.rankin>
Thu, 7 Apr 2005 03:32:48 +0000 (03:32 +0000)
     When 3.4.0 added the shop price to inventory display of unpaid items,
it resulted in showing that price twice if you used the `I u' command while
carrying just one unpaid object.

k - a potion of object detection (unpaid, 150 zorkmids)    150 zorkmids

With two or more unpaid objects it uses a menu style display and explicitly
suppresses "(unpaid, N zorkmids)" from the inventory formatting.  Do the
same suppression when there's one item.

k - a potion of object detection                     150 zorkmids

doc/fixes34.4
src/invent.c

index f095dbe2694222467758c6699252a345d5a31fde..1b3b864481e60000a0c390faf6ea33a4dcaab61e 100644 (file)
@@ -108,6 +108,7 @@ fix some cases where movement was disallowed but the hero was still conscious
 after destroying drawbridge, hero could appear to be in the wall
 sometimes shop items which hero is forced to buy could be sold back twice
 vision was not updated when polymorphing a statue into a boulder
+`I u' when carrying single unpaid item listed its cost twice
 
 
 Platform- and/or Interface-Specific Fixes
index 3061ce41cf05715e854c4d5e4266a03c0e41f1c7..acc0acf3600541775f4064b683b354945b2e5c4a 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)invent.c   3.5     2005/02/07      */
+/*     SCCS Id: @(#)invent.c   3.5     2005/04/06      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1923,7 +1923,6 @@ dounpaid()
     register char ilet;
     char *invlet = flags.inv_order;
     int classcount, count, num_so_far;
-    int save_unpaid = 0;       /* lint init */
     long cost, totcost;
 
     count = count_unpaid(invent);
@@ -1931,14 +1930,12 @@ dounpaid()
     if (count == 1) {
        marker = (struct obj *) 0;
        otmp = find_unpaid(invent, &marker);
-
-       /* see if the unpaid item is in the top level inventory */
-       for (marker = invent; marker; marker = marker->nobj)
-           if (marker == otmp) break;
-
+       cost = unpaid_cost(otmp);
+       otmp->unpaid = 0;       /* suppress "(unpaid)" suffix */
        pline("%s", xprname(otmp, distant_name(otmp, doname),
-                           marker ? otmp->invlet : CONTAINED_SYM,
-                           TRUE, unpaid_cost(otmp), 0L));
+                           carried(otmp) ? otmp->invlet : CONTAINED_SYM,
+                           TRUE, cost, 0L));
+       otmp->unpaid = 1;       /*(wouldn't be here if this wasn't true)*/
        return;
     }
 
@@ -1959,12 +1956,10 @@ dounpaid()
                    }
 
                    totcost += cost = unpaid_cost(otmp);
-                   /* suppress "(unpaid)" suffix */
-                   save_unpaid = otmp->unpaid;
-                   otmp->unpaid = 0;
+                   otmp->unpaid = 0;   /* suppress "(unpaid)" suffix */
                    putstr(win, 0, xprname(otmp, distant_name(otmp, doname),
                                           ilet, TRUE, cost, 0L));
-                   otmp->unpaid = save_unpaid;
+                   otmp->unpaid = 1;
                    num_so_far++;
                }
            }
@@ -1982,27 +1977,28 @@ dounpaid()
         */
        for (otmp = invent; otmp; otmp = otmp->nobj) {
            if (Has_contents(otmp)) {
-               long contcost = 0L;
+               long contcost = 0L;
+
                marker = (struct obj *) 0;      /* haven't found any */
                while (find_unpaid(otmp->cobj, &marker)) {
                    totcost += cost = unpaid_cost(marker);
                    contcost += cost;
                    if (otmp->cknown) {
-                       save_unpaid = marker->unpaid;
-                       marker->unpaid = 0;    /* suppress "(unpaid)" suffix */
+                       marker->unpaid = 0; /* suppress "(unpaid)" suffix */
                        putstr(win, 0,
-                          xprname(marker, distant_name(marker, doname),
-                                  CONTAINED_SYM, TRUE, cost, 0L));
-                       marker->unpaid = save_unpaid;
+                              xprname(marker, distant_name(marker, doname),
+                                      CONTAINED_SYM, TRUE, cost, 0L));
+                       marker->unpaid = 1;
                    }
                }
                if (!otmp->cknown) {
-                       char contbuf[BUFSZ];
-                       /* Shopkeeper knows what to charge for contents */
-                       Sprintf(contbuf, "%s contents", s_suffix(xname(otmp)));
-                       putstr(win, 0,
-                               xprname((struct obj *)0, contbuf,
-                               CONTAINED_SYM, TRUE, contcost, 0L));
+                   char contbuf[BUFSZ];
+
+                   /* Shopkeeper knows what to charge for contents */
+                   Sprintf(contbuf, "%s contents", s_suffix(xname(otmp)));
+                   putstr(win, 0,
+                          xprname((struct obj *)0, contbuf,
+                                  CONTAINED_SYM, TRUE, contcost, 0L));
                }
            }
        }