# HG changeset patch # User Grumpy7 # Date 1410046533 -7200 # Node ID 45102c9132e1e4d6e05066281b476487e88bfb53 # Parent cc7019a533fc05048c4c4ba8e4b40eff8882e3fc Changed ternary operators to else-if chain for INPUT_CastReady diff -r cc7019a533fc -r 45102c9132e1 Keyboard.cpp --- a/Keyboard.cpp Sat Sep 06 21:45:26 2014 +0200 +++ b/Keyboard.cpp Sun Sep 07 01:35:33 2014 +0200 @@ -705,30 +705,44 @@ } break; case INPUT_CastReady: - if (pCurrentScreen != SCREEN_GAME) - break; - if (pParty->bTurnBasedModeOn && pTurnEngine->turn_stage == TE_MOVEMENT) { - pTurnEngine->field_18 |= TE_FLAG_8; - break; + if (pCurrentScreen != SCREEN_GAME) + break; + if (pParty->bTurnBasedModeOn && pTurnEngine->turn_stage == TE_MOVEMENT) + { + pTurnEngine->field_18 |= TE_FLAG_8; + break; + } + if ( !uActiveCharacter ) + break; + uchar quickSpellNumber = pPlayers[uActiveCharacter]->uQuickSpell; + v9 = pPlayers[uActiveCharacter]->pActiveSkills[quickSpellNumber / 11 + 12]; + bool enoughMana = false; + if ((v9 & 0x100) != 0) + { + enoughMana = pSpellDatas[quickSpellNumber].uMagisterLevelMana < pPlayers[uActiveCharacter]->sMana; + } + else if ((v9 & 0x80) != 0) + { + enoughMana = pSpellDatas[quickSpellNumber].uMasterLevelMana < pPlayers[uActiveCharacter]->sMana; + } + else if ((v9 & 0x40) != 0) + { + enoughMana = pSpellDatas[quickSpellNumber].uExpertLevelMana < pPlayers[uActiveCharacter]->sMana; + } + else + { + enoughMana = pSpellDatas[quickSpellNumber].uNormalLevelMana < pPlayers[uActiveCharacter]->sMana; + } + if ( !pPlayers[uActiveCharacter]->uQuickSpell || bUnderwater || !enoughMana) + { + pPartyActionQueue = pPartyActionQueue; + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Attack, 0, 0); + break; + } + else + pMessageQueue_50C9E8->AddGUIMessage(UIMSG_CastQuickSpell, 0, 0); } - if ( !uActiveCharacter ) - break; - v9 = pPlayers[uActiveCharacter]->pActiveSkills[(unsigned __int8)pPlayers[uActiveCharacter]->uQuickSpell / 11 + 12]; - if ( !pPlayers[uActiveCharacter]->uQuickSpell || bUnderwater - || (( !(HIBYTE(v9) & 1)) ? - ((v9 & 0x80) == 0 ? - ((v9 & 0x40) == 0 ? spell_price = pSpellDatas[pPlayers[uActiveCharacter]->uQuickSpell].uNormalLevelMana : spell_price = pSpellDatas[pPlayers[uActiveCharacter]->uQuickSpell].uExpertLevelMana) : - spell_price = pSpellDatas[pPlayers[uActiveCharacter]->uQuickSpell].uMasterLevelMana) : - spell_price = pSpellDatas[pPlayers[uActiveCharacter]->uQuickSpell].uMagisterLevelMana, - spell_price > pPlayers[uActiveCharacter]->sMana) ) - { - pPartyActionQueue = pPartyActionQueue; - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Attack, 0, 0); - break; - } - else - pMessageQueue_50C9E8->AddGUIMessage(UIMSG_CastQuickSpell, 0, 0); break; case INPUT_Attack: if (pCurrentScreen != SCREEN_GAME)