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.
This commit is contained in:
PatR
2015-05-03 01:22:25 -07:00
parent fc567b5ce3
commit 181740e874
+22 -21
View File
@@ -1111,25 +1111,8 @@ register const char *let,*word;
} }
return(allownone ? &zeroobj : (struct obj *) 0); 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
if (!usegold) { select-from-invent before checking whether gold has been picked */
You("cannot %s gold.", word);
return(struct obj *)0;
}
/* Historic note: early Nethack had a bug which was
* first reported for Larn, where trying to drop 2^32-n
* gold pieces was allowed, and did interesting things
* to your money supply. The LRS is the tax bureau
* from Larn.
*/
if (allowcnt == 2 && cnt <= 0) {
if (cnt < 0 || !prezero)
pline_The(
"LRS would be very interested to know you have that much.");
return (struct obj *)0;
}
}
if (ilet == '?' || ilet == '*') { if (ilet == '?' || ilet == '*') {
char *allowed_choices = (ilet == '?') ? lets : (char *)0; char *allowed_choices = (ilet == '?') ? lets : (char *)0;
long ctmp = 0; long ctmp = 0;
@@ -1147,17 +1130,35 @@ register const char *let,*word;
if (ilet == '\033') { if (ilet == '\033') {
if (flags.verbose) if (flags.verbose)
pline1(Never_mind); pline1(Never_mind);
return((struct obj *)0); return (struct obj *)0;
} }
/* 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) {
if (!usegold) {
You("cannot %s gold.", word);
return(struct obj *)0;
}
/* Historic note: early Nethack had a bug which was
* first reported for Larn, where trying to drop 2^32-n
* gold pieces was allowed, and did interesting things
* to your money supply. The LRS is the tax bureau
* from Larn.
*/
if (allowcnt == 2 && cnt <= 0) {
if (cnt < 0 || !prezero)
pline_The(
"LRS would be very interested to know you have that much.");
return (struct obj *)0;
}
}
if (allowcnt == 2 && !strcmp(word,"throw")) { if (allowcnt == 2 && !strcmp(word,"throw")) {
/* 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)
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) {
You("can only throw one item at a time."); You("can only throw one item at a time.");
continue; continue;