Fix fire auto-swapweaponing to polearm
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.
This commit is contained in:
@@ -543,6 +543,7 @@ enum bodypart_types {
|
||||
#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 {
|
||||
|
||||
@@ -3976,9 +3976,9 @@ rhack(char *cmd)
|
||||
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;
|
||||
|
||||
@@ -168,6 +168,7 @@ ready_weapon(struct obj *wep)
|
||||
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 {
|
||||
@@ -420,7 +421,7 @@ dowield(void)
|
||||
setuswapwep(oldwep);
|
||||
untwoweapon();
|
||||
|
||||
return result ? ECMD_TIME : ECMD_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* the #swap command - swap wielded and secondary weapons */
|
||||
@@ -466,7 +467,7 @@ doswapweapon(void)
|
||||
if (u.twoweap && !can_twoweapon())
|
||||
untwoweapon();
|
||||
|
||||
return result ? ECMD_TIME : ECMD_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* the #quiver command */
|
||||
|
||||
Reference in New Issue
Block a user