]> granicus.if.org Git - nethack/commitdiff
more sortloot revamp fallout
authorPatR <rankin@nethack.org>
Wed, 20 Apr 2016 00:01:01 +0000 (17:01 -0700)
committerPatR <rankin@nethack.org>
Wed, 20 Apr 2016 00:01:01 +0000 (17:01 -0700)
getobj() was caching 'invent' in 'firstobj', dating from the days
of the !GOLDOBJ configuration, and sortloot() could change the value
of invent, making firstobj end up pointing somewhere into the midst
of the inventory list.  So collecting letters of applicable items
could miss things (typically right after restoring a saved game).
Repeating the command would operate on already sorted invent, making
firstobj remain valid and things mysteriously reappear after having
been missed before.

Just get rid of 'firstobj' since it's no longer useful.

src/invent.c

index 49fdb3c1a6f5a22ddb73b80bb93a881e6d255b36..d5840422ce7a1acebc35aab4b7a4d127bbb4cd9c 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 invent.c        $NHDT-Date: 1461028538 2016/04/19 01:15:38 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.204 $ */
+/* NetHack 3.6 invent.c        $NHDT-Date: 1461110442 2016/04/20 00:00:42 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.205 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1061,7 +1061,6 @@ register const char *let, *word;
     register int foo = 0;
     register char *bp = buf;
     xchar allowcnt = 0; /* 0, 1 or 2 */
-    struct obj *firstobj = invent;
     boolean usegold = FALSE; /* can't use gold because its illegal */
     boolean allowall = FALSE;
     boolean allownone = FALSE;
@@ -1114,7 +1113,7 @@ register const char *let, *word;
            and so won't have to re-sort in the for(;;) loop below */
         sortloot(&invent, SORTLOOT_INVLET, FALSE);
 
-    for (otmp = firstobj; otmp; otmp = otmp->nobj) {
+    for (otmp = invent; otmp; otmp = otmp->nobj) {
         if (&bp[foo] == &buf[sizeof buf - 1]
             || ap == &altlets[sizeof altlets - 1]) {
             /* we must have a huge number of NOINVSYM items somehow */