diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index b6532198c..356663258 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -1432,11 +1432,11 @@ void PerformPrimaryAction() bool SpellHasActorTarget() { - int spl = Players[MyPlayerId]._pRSpell; + spell_id spl = Players[MyPlayerId]._pRSpell; if (spl == SPL_TOWN || spl == SPL_TELEPORT) return false; - if (IsAnyOf(spl, SPL_FIREWALL, SPL_LIGHTWALL) && pcursmonst != -1) { + if (IsWallSpell(spl) && pcursmonst != -1) { cursPosition = Monsters[pcursmonst].position.tile; } diff --git a/Source/player.cpp b/Source/player.cpp index 59943973d..510e132dc 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -3477,7 +3477,7 @@ void CheckPlrSpell(bool isShiftHeld, spell_id spellID, spell_type spellType) return; } - if (spellID == SPL_FIREWALL || spellID == SPL_LIGHTWALL) { + if (IsWallSpell(spellID)) { LastMouseButtonAction = MouseActionType::Spell; Direction sd = GetDirection(myPlayer.position.tile, cursPosition); sl = GetSpellLevel(MyPlayerId, spellID); diff --git a/Source/spells.cpp b/Source/spells.cpp index 680e83bc8..3bb748a73 100644 --- a/Source/spells.cpp +++ b/Source/spells.cpp @@ -108,6 +108,11 @@ void PlacePlayer(int pnum) } // namespace +bool IsWallSpell(spell_id spl) +{ + return spl == SPL_FIREWALL || spl == SPL_LIGHTWALL; +} + int GetManaAmount(Player &player, spell_id sn) { int ma; // mana amount @@ -218,10 +223,10 @@ SpellCheckResult CheckSpell(int id, spell_id sn, spell_type st, bool manaonly) return SpellCheckResult::Success; } -void CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int spllvl) +void CastSpell(int id, spell_id spl, int sx, int sy, int dx, int dy, int spllvl) { Direction dir = Players[id]._pdir; - if (spl == SPL_FIREWALL || spl == SPL_LIGHTWALL) { + if (IsWallSpell(spl)) { dir = Players[id].tempDirection; } diff --git a/Source/spells.h b/Source/spells.h index 63a35a11c..94b918ff0 100644 --- a/Source/spells.h +++ b/Source/spells.h @@ -16,6 +16,7 @@ enum class SpellCheckResult : uint8_t { Fail_Busy, }; +bool IsWallSpell(spell_id spl); int GetManaAmount(Player &player, spell_id sn); void UseMana(int id, spell_id sn); SpellCheckResult CheckSpell(int id, spell_id sn, spell_type st, bool manaonly); @@ -28,7 +29,7 @@ SpellCheckResult CheckSpell(int id, spell_id sn, spell_type st, bool manaonly); * @param player The player whose readied spell is to be checked. */ void EnsureValidReadiedSpell(Player &player); -void CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int spllvl); +void CastSpell(int id, spell_id spl, int sx, int sy, int dx, int dy, int spllvl); /** * @param pnum player index