When you have a polearm as secondary weapon, have a fireassist on,
and press 'f' to fire, the code tries to swapweapon to the polearm.
This failed badly and got stuck in a loop if you were also wearing
a shield - as polearms are two-handed and shield prevents wielding
those.
Add a new "command failed" result, and clear the command queue
in that case. Also make swapweapon and wield actually return
the ECMD flags back to the rhack loop.
#define ECMD_OK 0x00 /* cmd done successfully */
#define ECMD_TIME 0x01 /* cmd took time, uses up a turn */
#define ECMD_CANCEL 0x02 /* cmd canceled by user */
+#define ECMD_FAIL 0x04 /* cmd failed to finish, maybe with a yafm */
/* values returned from getobj() callback functions */
enum getobj_callback_returns {
prefix_seen = 0;
was_m_prefix = FALSE;
}
- if ((res & ECMD_CANCEL)) {
+ if ((res & (ECMD_CANCEL|ECMD_FAIL))) {
/* command was canceled by user, maybe they declined to
- pick an object to act on. */
+ pick an object to act on, or command failed to finish */
reset_cmd_vars(TRUE);
prefix_seen = 0;
cmdq_ec = NULL;
You("cannot wield a two-handed %s while wearing a shield.",
is_sword(wep) ? "sword" : wep->otyp == BATTLE_AXE ? "axe"
: "weapon");
+ res = ECMD_FAIL;
} else if (!retouch_object(&wep, FALSE)) {
res = ECMD_TIME; /* takes a turn even though it doesn't get wielded */
} else {
setuswapwep(oldwep);
untwoweapon();
- return result ? ECMD_TIME : ECMD_OK;
+ return result;
}
/* the #swap command - swap wielded and secondary weapons */
if (u.twoweap && !can_twoweapon())
untwoweapon();
- return result ? ECMD_TIME : ECMD_OK;
+ return result;
}
/* the #quiver command */