another pass at "gold wield inconsistency"
Handle !fixinv by forcing gold to have slot '$' all the time; that particular type of object is 'fixed' regardless of user preference. Also add a couple of checks for non-'$' gold when selecting from inventory, just in case the issue of multiple gold stacks reappears.
This commit is contained in:
55
src/invent.c
55
src/invent.c
@@ -425,8 +425,8 @@ struct obj *obj;
|
|||||||
goto added;
|
goto added;
|
||||||
}
|
}
|
||||||
/* didn't merge, so insert into chain */
|
/* didn't merge, so insert into chain */
|
||||||
|
assigninvlet(obj);
|
||||||
if (flags.invlet_constant || !prev) {
|
if (flags.invlet_constant || !prev) {
|
||||||
if (flags.invlet_constant) assigninvlet(obj);
|
|
||||||
obj->nobj = invent; /* insert at beginning */
|
obj->nobj = invent; /* insert at beginning */
|
||||||
invent = obj;
|
invent = obj;
|
||||||
if (flags.invlet_constant) reorder_invent();
|
if (flags.invlet_constant) reorder_invent();
|
||||||
@@ -1134,7 +1134,14 @@ register const char *let,*word;
|
|||||||
}
|
}
|
||||||
/* they typed a letter (not a space) at the prompt */
|
/* they typed a letter (not a space) at the prompt */
|
||||||
}
|
}
|
||||||
if (ilet == def_oc_syms[COIN_CLASS].sym) {
|
/* find the item which was picked */
|
||||||
|
for (otmp = invent; otmp; otmp = otmp->nobj)
|
||||||
|
if (otmp->invlet == ilet) break;
|
||||||
|
/* some items have restrictions */
|
||||||
|
if (ilet == def_oc_syms[COIN_CLASS].sym
|
||||||
|
/* guard against the [hypothetical] chace of having more
|
||||||
|
than one invent slot of gold and picking the non-'$' one */
|
||||||
|
|| (otmp && otmp->oclass == COIN_CLASS)) {
|
||||||
if (!usegold) {
|
if (!usegold) {
|
||||||
You("cannot %s gold.", word);
|
You("cannot %s gold.", word);
|
||||||
return(struct obj *)0;
|
return(struct obj *)0;
|
||||||
@@ -1156,7 +1163,8 @@ register const char *let,*word;
|
|||||||
/* permit counts for throwing gold, but don't accept
|
/* permit counts for throwing gold, but don't accept
|
||||||
* counts for other things since the throw code will
|
* counts for other things since the throw code will
|
||||||
* split off a single item anyway */
|
* split off a single item anyway */
|
||||||
if (ilet != def_oc_syms[COIN_CLASS].sym)
|
if (ilet != def_oc_syms[COIN_CLASS].sym
|
||||||
|
&& !(otmp && otmp->oclass == COIN_CLASS))
|
||||||
allowcnt = 1;
|
allowcnt = 1;
|
||||||
if (cnt == 0 && prezero) return (struct obj *)0;
|
if (cnt == 0 && prezero) return (struct obj *)0;
|
||||||
if (cnt > 1) {
|
if (cnt > 1) {
|
||||||
@@ -1166,8 +1174,9 @@ register const char *let,*word;
|
|||||||
}
|
}
|
||||||
context.botl = 1; /* May have changed the amount of money */
|
context.botl = 1; /* May have changed the amount of money */
|
||||||
savech(ilet);
|
savech(ilet);
|
||||||
for (otmp = invent; otmp; otmp = otmp->nobj)
|
/* [we used to set otmp (by finding ilet in invent) here, but
|
||||||
if (otmp->invlet == ilet) break;
|
that's been moved above so that otmp can be checked earlier] */
|
||||||
|
/* verify the chosen object */
|
||||||
if(!otmp) {
|
if(!otmp) {
|
||||||
You("don't have that object.");
|
You("don't have that object.");
|
||||||
if (in_doagain) return((struct obj *) 0);
|
if (in_doagain) return((struct obj *) 0);
|
||||||
@@ -2958,23 +2967,33 @@ free_invbuf()
|
|||||||
invbufsiz = 0;
|
invbufsiz = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* give consecutive letters to every item in inventory (for !fixinv mode) */
|
/* give consecutive letters to every item in inventory (for !fixinv mode);
|
||||||
|
gold is always forced to '$' slot at head of list */
|
||||||
void
|
void
|
||||||
reassign()
|
reassign()
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
register struct obj *obj;
|
struct obj *obj, *prevobj, *goldobj;
|
||||||
|
|
||||||
for(obj = invent, i = 0; obj; obj = obj->nobj, i++) {
|
/* first, remove [first instance of] gold from invent, if present */
|
||||||
if (obj->oclass == COIN_CLASS && obj->invlet == GOLD_SYM)
|
prevobj = goldobj = 0;
|
||||||
--i; /* keep $ instead of using up i'th letter */
|
for (obj = invent; obj; prevobj = obj, obj = obj->nobj)
|
||||||
else
|
if (obj->oclass == COIN_CLASS) {
|
||||||
if (i < 52)
|
goldobj = obj;
|
||||||
obj->invlet = (i < 26) ? ('a'+i) : ('A'+i-26);
|
if (prevobj)
|
||||||
else if (obj->oclass == COIN_CLASS)
|
prevobj->nobj = goldobj->nobj;
|
||||||
obj->invlet = GOLD_SYM;
|
else
|
||||||
else
|
invent = goldobj->nobj;
|
||||||
obj->invlet = NOINVSYM;
|
break;
|
||||||
|
}
|
||||||
|
/* second, re-letter the rest of the list */
|
||||||
|
for (obj = invent, i = 0; obj; obj = obj->nobj, i++)
|
||||||
|
obj->invlet = (i < 26) ? ('a'+i) : (i < 52) ? ('A'+i-26) : NOINVSYM;
|
||||||
|
/* third, assign gold the "letter" '$' and re-insert it at head */
|
||||||
|
if (goldobj) {
|
||||||
|
goldobj->invlet = GOLD_SYM;
|
||||||
|
goldobj->nobj = invent;
|
||||||
|
invent = goldobj;
|
||||||
}
|
}
|
||||||
if (i >= 52) i = 52 - 1;
|
if (i >= 52) i = 52 - 1;
|
||||||
lastinvnr = i;
|
lastinvnr = i;
|
||||||
|
|||||||
Reference in New Issue
Block a user