command prefix handling

Investigating github issue #664 by argrath turned up a more
significant problem.  Prefixes other than 'm' preceding commands
that don't use a prefix didn't get rejected but didn't do anything.

Fixes #664
This commit is contained in:
PatR
2022-02-06 11:51:00 -08:00
parent 4ee1c66f8f
commit cfd753dd12
3 changed files with 27 additions and 20 deletions

View File

@@ -150,7 +150,7 @@ static int
ready_weapon(struct obj *wep)
{
/* Separated function so swapping works easily */
int res = 0;
int res = ECMD_OK;
boolean was_twoweap = u.twoweap, had_wep = (uwep != 0);
if (!wep) {
@@ -158,21 +158,21 @@ ready_weapon(struct obj *wep)
if (uwep) {
You("are empty %s.", body_part(HANDED));
setuwep((struct obj *) 0);
res++;
res = ECMD_TIME;
} else
You("are already empty %s.", body_part(HANDED));
} else if (wep->otyp == CORPSE && cant_wield_corpse(wep)) {
/* hero must have been life-saved to get here; use a turn */
res++; /* corpse won't be wielded */
res = ECMD_TIME; /* corpse won't be wielded */
} else if (uarms && bimanual(wep)) {
You("cannot wield a two-handed %s while wearing a shield.",
is_sword(wep) ? "sword" : wep->otyp == BATTLE_AXE ? "axe"
: "weapon");
} else if (!retouch_object(&wep, FALSE)) {
res++; /* takes a turn even though it doesn't get wielded */
res = ECMD_TIME; /* takes a turn even though it doesn't get wielded */
} else {
/* Weapon WILL be wielded after this point */
res++;
res = ECMD_TIME;
if (will_weld(wep)) {
const char *tmp = xname(wep), *thestr = "The ";