From 181740e874d43f8b22d16238de5bff80727957d1 Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 3 May 2015 01:22:25 -0700 Subject: [PATCH] fix "gold wield inconsistency" 'w$' reported "you can't wield gold" but 'w*$', choosing from inventory and picking gold, let you wield gold. The old code checked whether gold had been picked before checking whether '?' or '*' had been picked to request selection from inventory. This wasn't an issue with 3.4.3's !GOLDINV configuration (but probably was for anyone who explicitly switched to GOLDINV) because getobj()'s callers only inserted gold into inventory when they intended to accept it as a valid choice. Fix is just to swap two adjacent 'if' blocks in getobj() so that '*' is processed before the test of whether '$' has been chosen. Most of the diff is indentation and other minor reformatting. --- src/invent.c | 63 ++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/src/invent.c b/src/invent.c index a23c92166..7b3861e62 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1111,7 +1111,30 @@ register const char *let,*word; } return(allownone ? &zeroobj : (struct obj *) 0); } - if(ilet == def_oc_syms[COIN_CLASS].sym) { + /* since gold is now kept in inventory, we need to do processing for + select-from-invent before checking whether gold has been picked */ + if (ilet == '?' || ilet == '*') { + char *allowed_choices = (ilet == '?') ? lets : (char *)0; + long ctmp = 0; + + if (ilet == '?' && !*lets && *altlets) + allowed_choices = altlets; + ilet = display_pickinv(allowed_choices, TRUE, + allowcnt ? &ctmp : (long *)0); + if (!ilet) continue; + if (allowcnt && ctmp >= 0) { + cnt = ctmp; + if (!cnt) prezero = TRUE; + allowcnt = 2; + } + if (ilet == '\033') { + if (flags.verbose) + pline1(Never_mind); + return (struct obj *)0; + } + /* they typed a letter (not a space) at the prompt */ + } + if (ilet == def_oc_syms[COIN_CLASS].sym) { if (!usegold) { You("cannot %s gold.", word); return(struct obj *)0; @@ -1124,43 +1147,21 @@ register const char *let,*word; */ if (allowcnt == 2 && cnt <= 0) { if (cnt < 0 || !prezero) - pline_The( - "LRS would be very interested to know you have that much."); + pline_The( + "LRS would be very interested to know you have that much."); return (struct obj *)0; } - } - if(ilet == '?' || ilet == '*') { - char *allowed_choices = (ilet == '?') ? lets : (char *)0; - long ctmp = 0; - - if (ilet == '?' && !*lets && *altlets) - allowed_choices = altlets; - ilet = display_pickinv(allowed_choices, TRUE, - allowcnt ? &ctmp : (long *)0); - if(!ilet) continue; - if (allowcnt && ctmp >= 0) { - cnt = ctmp; - if (!cnt) prezero = TRUE; - allowcnt = 2; - } - if(ilet == '\033') { - if(flags.verbose) - pline1(Never_mind); - return((struct obj *)0); - } - /* they typed a letter (not a space) at the prompt */ - } - if(allowcnt == 2 && !strcmp(word,"throw")) { + if (allowcnt == 2 && !strcmp(word,"throw")) { /* permit counts for throwing gold, but don't accept * counts for other things since the throw code will * split off a single item anyway */ if (ilet != def_oc_syms[COIN_CLASS].sym) - allowcnt = 1; - if(cnt == 0 && prezero) return((struct obj *)0); - if(cnt > 1) { - You("can only throw one item at a time."); - continue; + allowcnt = 1; + if (cnt == 0 && prezero) return (struct obj *)0; + if (cnt > 1) { + You("can only throw one item at a time."); + continue; } } context.botl = 1; /* May have changed the amount of money */