looting gold

When removing items from a container via menu, list gold as '$'
instead of 'a' when it is the first item.  Requested during beta
testing last year....

When gold isn't first ('sortpack' false, or custom 'inv_order[]'),
it uses the next letter in sequence instead of '$', otherwise it
would be the only item out of sequence.
This commit is contained in:
PatR
2016-03-13 17:45:18 -07:00
parent b3b4953020
commit 529dad8ef1
2 changed files with 19 additions and 14 deletions
+11 -9
View File
@@ -1010,17 +1010,20 @@ change_inv_order(op)
char *op; char *op;
{ {
int oc_sym, num; int oc_sym, num;
char *sp, buf[BUFSZ]; char *sp, buf[QBUFSZ];
num = 0; num = 0;
/* !!!! probably unnecessary with gold as normal inventory */ if (!index(op, GOLD_SYM))
buf[num++] = COIN_CLASS;
for (sp = op; *sp; sp++) { for (sp = op; *sp; sp++) {
oc_sym = def_char_to_objclass(*sp); oc_sym = def_char_to_objclass(*sp);
/* reject bad or duplicate entries */ /* reject bad or duplicate entries */
if (oc_sym == MAXOCLASSES || oc_sym == RANDOM_CLASS if (oc_sym == MAXOCLASSES /* not an object class char */
|| oc_sym == ILLOBJ_CLASS || !index(flags.inv_order, oc_sym) /* VENOM_CLASS, RANDOM_CLASS, and ILLOBJ_CLASS are excluded
|| index(sp + 1, *sp)) because they aren't in def_inv_order[] so don't make it
into flags.inv_order, hence always fail this index() test */
|| !index(flags.inv_order, oc_sym) || index(sp + 1, *sp))
return 0; return 0;
/* retain good ones */ /* retain good ones */
buf[num++] = (char) oc_sym; buf[num++] = (char) oc_sym;
@@ -1029,10 +1032,9 @@ char *op;
/* fill in any omitted classes, using previous ordering */ /* fill in any omitted classes, using previous ordering */
for (sp = flags.inv_order; *sp; sp++) for (sp = flags.inv_order; *sp; sp++)
if (!index(buf, *sp)) { if (!index(buf, *sp))
buf[num++] = *sp; (void) strkitten(&buf[num++], *sp);
buf[num] = '\0'; /* explicitly terminate for next index() */ buf[MAXOCLASSES - 1] = '\0';
}
Strcpy(flags.inv_order, buf); Strcpy(flags.inv_order, buf);
return 1; return 1;
+8 -5
View File
@@ -791,7 +791,7 @@ boolean FDECL((*allow), (OBJ_P)); /* allow function */
struct obj *curr, *last, fake_hero_object, *olist = *olist_p; struct obj *curr, *last, fake_hero_object, *olist = *olist_p;
char *pack; char *pack;
anything any; anything any;
boolean printed_type_name, boolean printed_type_name, first,
sorted = (qflags & INVORDER_SORT) != 0, sorted = (qflags & INVORDER_SORT) != 0,
engulfer = (qflags & INCLUDE_HERO) != 0; engulfer = (qflags & INCLUDE_HERO) != 0;
@@ -843,6 +843,7 @@ boolean FDECL((*allow), (OBJ_P)); /* allow function */
* be called once per object in the list. * be called once per object in the list.
*/ */
pack = flags.inv_order; pack = flags.inv_order;
first = TRUE;
do { do {
printed_type_name = FALSE; printed_type_name = FALSE;
for (curr = olist; curr; curr = FOLLOW(curr, qflags)) { for (curr = olist; curr; curr = FOLLOW(curr, qflags)) {
@@ -868,9 +869,11 @@ boolean FDECL((*allow), (OBJ_P)); /* allow function */
any.a_obj = curr; any.a_obj = curr;
add_menu(win, obj_to_glyph(curr), &any, add_menu(win, obj_to_glyph(curr), &any,
(qflags & USE_INVLET) ? curr->invlet : 0, (qflags & USE_INVLET) ? curr->invlet
: (first && curr->oclass == COIN_CLASS) ? '$' : 0,
def_oc_syms[(int) objects[curr->otyp].oc_class].sym, def_oc_syms[(int) objects[curr->otyp].oc_class].sym,
ATR_NONE, doname_with_price(curr), MENU_UNSELECTED); ATR_NONE, doname_with_price(curr), MENU_UNSELECTED);
first = FALSE;
} }
} }
pack++; pack++;
@@ -2586,9 +2589,9 @@ boolean put_in;
} else if (flags.menu_style == MENU_FULL) { } else if (flags.menu_style == MENU_FULL) {
all_categories = FALSE; all_categories = FALSE;
Sprintf(buf, "%s what type of objects?", action); Sprintf(buf, "%s what type of objects?", action);
mflags = put_in mflags = (ALL_TYPES | BUC_ALLBKNOWN | BUC_UNKNOWN);
? ALL_TYPES | BUC_ALLBKNOWN | BUC_UNKNOWN if (put_in)
: ALL_TYPES | CHOOSE_ALL | BUC_ALLBKNOWN | BUC_UNKNOWN; mflags |= CHOOSE_ALL;
n = query_category(buf, put_in ? invent : current_container->cobj, n = query_category(buf, put_in ? invent : current_container->cobj,
mflags, &pick_list, PICK_ANY); mflags, &pick_list, PICK_ANY);
if (!n) if (!n)