From e8e8c14b345bc4cae9f54e27cf1b9929e0feff42 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 22 Mar 2016 01:19:27 -0700 Subject: [PATCH] more fixes for revised 'sortloot' After some permutation of commands which displayed items, the 'd' command presented a prompt with the list of letters scrambled (in loot order or pack order rather than invlet order), so explicitly sort when getobj operates. Done for ggetobj too. For menustyle:Traditional, ',' followed by 'm' presented a pickup list in pile order even when sortloot was 'l' or 'f'. That was an unintentional change during the 'revamp'. --- doc/fixes36.1 | 1 + src/hack.c | 4 ++++ src/invent.c | 53 ++++++++++++++++++++++++++++++++------------------- src/pickup.c | 2 +- 4 files changed, 39 insertions(+), 21 deletions(-) diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 1d1b68691..c8e65af55 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -193,6 +193,7 @@ female gnome who gains level can grow up into male-only gnome lord; give an kicked weapon which successfully hits monster vanishes from play unseen landmine explosion could result in "The statue crumbles." post-3.6.0: fix "object lost" panic during pickup caused by sortloot revamp +post-3.6.0: more sortloot revisions Platform- and/or Interface-Specific Fixes diff --git a/src/hack.c b/src/hack.c index 6ce28907a..b3fd6654d 100644 --- a/src/hack.c +++ b/src/hack.c @@ -2197,6 +2197,7 @@ register boolean newlev; *ptr2 = '\0'; } +/* possibly deliver a one-time room entry message */ void check_special_room(newlev) register boolean newlev; @@ -2327,11 +2328,13 @@ register boolean newlev; return; } +/* the ',' command */ int dopickup() { int count; struct trap *traphere = t_at(u.ux, u.uy); + /* awful kludge to work around parse()'s pre-decrement */ count = (multi || (save_cm && *save_cm == ',')) ? multi + 1 : 0; multi = 0; /* always reset */ @@ -2372,6 +2375,7 @@ dopickup() } if (!OBJ_AT(u.ux, u.uy)) { register struct rm *lev = &levl[u.ux][u.uy]; + if (IS_THRONE(lev->typ)) pline("It must weigh%s a ton!", lev->looted ? " almost" : ""); else if (IS_SINK(lev->typ)) diff --git a/src/invent.c b/src/invent.c index 5670476ab..1e89d406b 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1106,6 +1106,13 @@ register const char *let, *word; if (!flags.invlet_constant) reassign(); + else + /* in case invent is in packorder, force it to be in invlet + order before collecing candidate inventory letters; + if player responds with '?' or '*' it will be changed + back by display_pickinv(), but by then we'll have 'lets' + 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) { if (&bp[foo] == &buf[sizeof buf - 1] @@ -1119,8 +1126,8 @@ register const char *let, *word; || (usegold && otmp->invlet == GOLD_SYM) || (useboulder && otmp->otyp == BOULDER)) { register int otyp = otmp->otyp; - bp[foo++] = otmp->invlet; + bp[foo++] = otmp->invlet; /* clang-format off */ /* *INDENT-OFF* */ /* ugly check: remove inappropriate things */ @@ -1521,9 +1528,9 @@ static NEARDATA const char removeables[] = { ARMOR_CLASS, WEAPON_CLASS, RING_CLASS, AMULET_CLASS, TOOL_CLASS, 0 }; -/* interactive version of getobj - used for Drop, Identify and */ -/* Takeoff (A). Return the number of times fn was called successfully */ -/* If combo is TRUE, we just use this to get a category list */ +/* Interactive version of getobj - used for Drop, Identify, and Takeoff (A). + Return the number of times fn was called successfully. + If combo is TRUE, we just use this to get a category list. */ int ggetobj(word, fn, mx, combo, resultflags) const char *word; @@ -1700,15 +1707,15 @@ unsigned *resultflags; * Walk through the chain starting at objchn and ask for all objects * with olet in olets (if nonNULL) and satisfying ckfn (if nonnull) * whether the action in question (i.e., fn) has to be performed. - * If allflag then no questions are asked. Max gives the max nr of - * objects to be treated. Return the number of objects treated. + * If allflag then no questions are asked. Mx gives the max number + * of objects to be treated. Return the number of objects treated. */ int askchain(objchn, olets, allflag, fn, ckfn, mx, word) struct obj **objchn; -register int allflag, mx; -register const char *olets, *word; /* olets is an Obj Class char array */ -register int FDECL((*fn), (OBJ_P)), FDECL((*ckfn), (OBJ_P)); +int allflag, mx; +const char *olets, *word; /* olets is an Obj Class char array */ +int FDECL((*fn), (OBJ_P)), FDECL((*ckfn), (OBJ_P)); { struct obj *otmp, *otmpo; register char sym, ilet; @@ -1723,11 +1730,17 @@ register int FDECL((*fn), (OBJ_P)), FDECL((*ckfn), (OBJ_P)); nodot = (!strcmp(word, "nodot") || !strcmp(word, "drop") || ident || takeoff || take_out || put_in); ininv = (*objchn == invent); + + /* someday maybe we'll sort by 'olets' too (temporarily replace + flags.packorder and pass SORTLOOT_PACK), but not yet... */ + sortloot(objchn, SORTLOOT_INVLET, FALSE); + first = TRUE; -/* Changed so the askchain is interrogated in the order specified. - * For example, if a person specifies =/ then first all rings will be - * asked about followed by all wands -dgk - */ + /* + * Interrogate in the object class order specified. + * For example, if a person specifies =/ then first all rings + * will be asked about followed by all wands. -dgk + */ nextclass: ilet = 'a' - 1; if (*objchn && (*objchn)->oclass == COIN_CLASS) @@ -1770,9 +1783,10 @@ nextclass: Sprintf(qpfx, "%s: ", word), *qpfx = highc(*qpfx); first = FALSE; } - (void) safe_qbuf( - qbuf, qpfx, "?", otmp, ininv ? safeq_xprname : doname, - ininv ? safeq_shortxprname : ansimpleoname, "item"); + (void) safe_qbuf(qbuf, qpfx, "?", otmp, + ininv ? safeq_xprname : doname, + ininv ? safeq_shortxprname : ansimpleoname, + "item"); sym = (takeoff || ident || otmp->quan < 2L) ? nyaq(qbuf) : nyNaq(qbuf); } else @@ -1784,11 +1798,10 @@ nextclass: to 'none' or 'all'. 2 special cases: cursed loadstones and welded weapons (eg, multiple daggers) will remain as merged unit; done to avoid splitting an object that won't be - droppable (even if we're picking up rather than dropping). - */ - if (!yn_number) + droppable (even if we're picking up rather than dropping). */ + if (!yn_number) { sym = 'n'; - else { + } else { sym = 'y'; if (yn_number < otmp->quan && splittable(otmp)) otmp = splitobj(otmp, yn_number); diff --git a/src/pickup.c b/src/pickup.c index 368508b16..f2642a6ed 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -823,7 +823,7 @@ boolean FDECL((*allow), (OBJ_P)); /* allow function */ return 1; } - if (sorted) { + if (sorted || flags.sortloot != 'n') { sortloot(&olist, (((flags.sortloot == 'f' || (flags.sortloot == 'l' && !(qflags & USE_INVLET))) -- 2.40.0