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

View File

@@ -1010,17 +1010,20 @@ change_inv_order(op)
char *op;
{
int oc_sym, num;
char *sp, buf[BUFSZ];
char *sp, buf[QBUFSZ];
num = 0;
/* !!!! probably unnecessary with gold as normal inventory */
if (!index(op, GOLD_SYM))
buf[num++] = COIN_CLASS;
for (sp = op; *sp; sp++) {
oc_sym = def_char_to_objclass(*sp);
/* reject bad or duplicate entries */
if (oc_sym == MAXOCLASSES || oc_sym == RANDOM_CLASS
|| oc_sym == ILLOBJ_CLASS || !index(flags.inv_order, oc_sym)
|| index(sp + 1, *sp))
if (oc_sym == MAXOCLASSES /* not an object class char */
/* VENOM_CLASS, RANDOM_CLASS, and ILLOBJ_CLASS are excluded
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;
/* retain good ones */
buf[num++] = (char) oc_sym;
@@ -1029,10 +1032,9 @@ char *op;
/* fill in any omitted classes, using previous ordering */
for (sp = flags.inv_order; *sp; sp++)
if (!index(buf, *sp)) {
buf[num++] = *sp;
buf[num] = '\0'; /* explicitly terminate for next index() */
}
if (!index(buf, *sp))
(void) strkitten(&buf[num++], *sp);
buf[MAXOCLASSES - 1] = '\0';
Strcpy(flags.inv_order, buf);
return 1;