From 1aff4f89fd4d53caf5a483323f1428668968735a Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 14 Mar 2016 15:32:17 -0700 Subject: [PATCH] sortloot fixes Fix some typos in the sort-by-invlet code and a logic error in the lately added subclass sorting for sort-by-pack. Regular inventory display only works correctly for the latter if invlet is the tie- breaker within object classes. When helmet/gloves/boots/&c and ammo/launcher/missile/&c sub-categories already break ties for armor and weapon classes, inventory ended up out of alphabetical order. --- src/invent.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/invent.c b/src/invent.c index 37937b6cf..5670476ab 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 invent.c $NHDT-Date: 1457207035 2016/03/05 19:43:55 $ $NHDT-Branch: chasonr $:$NHDT-Revision: 1.197 $ */ +/* NetHack 3.6 invent.c $NHDT-Date: 1457994703 2016/03/14 22:31:43 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.199 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -74,8 +74,11 @@ const genericptr vptr2; if (cls1 != cls2) return (int) (cls1 - cls2); + if ((sortlootmode & SORTLOOT_INVLET) != 0) { + ; /* skip sub-classes when sorting by packorder+invlet */ + /* for armor, group by sub-category */ - if (obj1->oclass == ARMOR_CLASS) { + } else if (obj1->oclass == ARMOR_CLASS) { static int armcat[7 + 1]; if (!armcat[7]) { @@ -119,13 +122,13 @@ const genericptr vptr2; if ((sortlootmode & SORTLOOT_INVLET) != 0) { c = obj1->invlet; val1 = ('a' <= c && c <= 'z') ? (c - 'a' + 2) - : ('A' <= c && c <= 'Z') ? (c - 'Z' + 2 + 26) + : ('A' <= c && c <= 'Z') ? (c - 'A' + 2 + 26) : (c == '$') ? 1 : (c == '#') ? 1 + 52 + 1 : 1 + 52 + 1 + 1; /* none of the above */ c = obj2->invlet; - val2 = ('a' <= c <= 'z') ? (c - 'a' + 2) - : ('A' <= c <= 'Z') ? (c - 'Z' + 2 + 26) + val2 = ('a' <= c && c <= 'z') ? (c - 'a' + 2) + : ('A' <= c && c <= 'Z') ? (c - 'A' + 2 + 26) : (c == '$') ? 1 : (c == '#') ? 1 + 52 + 1 : 1 + 52 + 1 + 1; /* none of the above */ -- 2.40.0