diff options
-rw-r--r-- | src/common/Asio/IpNetwork.cpp | 1 | ||||
-rw-r--r-- | src/server/game/Scripting/ScriptMgr.h | 7 | ||||
-rw-r--r-- | src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp | 2 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_generic.cpp | 37 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_item.cpp | 98 |
5 files changed, 62 insertions, 83 deletions
diff --git a/src/common/Asio/IpNetwork.cpp b/src/common/Asio/IpNetwork.cpp index 5de167e7a77..9e5ac1f03e5 100644 --- a/src/common/Asio/IpNetwork.cpp +++ b/src/common/Asio/IpNetwork.cpp @@ -104,7 +104,6 @@ Optional<std::size_t> SelectAddressForClient(boost::asio::ip::address const& cli if (address.is_v4() && !externalIpv4Index) externalIpv4Index = i; } - } if (IsInLocalNetwork(clientAddress) || clientAddress.is_loopback()) diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index f20652607b2..fe3fb48df79 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -22,6 +22,7 @@ #include "ObjectGuid.h" #include "Tuples.h" #include "Types.h" +#include <boost/preprocessor/punctuation/remove_parens.hpp> #include <memory> #include <vector> @@ -1339,6 +1340,8 @@ class GenericSpellAndAuraScriptLoader : public SpellScriptLoader using AuraScriptType = typename Trinity::find_type_if_t<Trinity::SpellScripts::is_AuraScript, Ts...>; using ArgsType = typename Trinity::find_type_if_t<Trinity::is_tuple, Ts...>; + static_assert(!std::conjunction_v<std::is_same<SpellScriptType, Trinity::find_type_end>, std::is_same<AuraScriptType, Trinity::find_type_end>>, "At least one of SpellScript/AuraScript arguments must be provided for GenericSpellAndAuraScriptLoader"); + public: GenericSpellAndAuraScriptLoader(char const* name, ArgsType&& args) : SpellScriptLoader(name), _args(std::move(args)) { } @@ -1362,9 +1365,9 @@ private: ArgsType _args; }; -#define RegisterSpellScriptWithArgs(spell_script, script_name, ...) new GenericSpellAndAuraScriptLoader<spell_script, decltype(std::make_tuple(__VA_ARGS__))>(script_name, std::make_tuple(__VA_ARGS__)) +#define RegisterSpellScriptWithArgs(spell_script, script_name, ...) new GenericSpellAndAuraScriptLoader<BOOST_PP_REMOVE_PARENS(spell_script), decltype(std::make_tuple(__VA_ARGS__))>(script_name, std::make_tuple(__VA_ARGS__)) #define RegisterSpellScript(spell_script) RegisterSpellScriptWithArgs(spell_script, #spell_script) -#define RegisterSpellAndAuraScriptPairWithArgs(script_1, script_2, script_name, ...) new GenericSpellAndAuraScriptLoader<script_1, script_2, decltype(std::make_tuple(__VA_ARGS__))>(script_name, std::make_tuple(__VA_ARGS__)) +#define RegisterSpellAndAuraScriptPairWithArgs(script_1, script_2, script_name, ...) new GenericSpellAndAuraScriptLoader<BOOST_PP_REMOVE_PARENS(script_1), BOOST_PP_REMOVE_PARENS(script_2), decltype(std::make_tuple(__VA_ARGS__))>(script_name, std::make_tuple(__VA_ARGS__)) #define RegisterSpellAndAuraScriptPair(script_1, script_2) RegisterSpellAndAuraScriptPairWithArgs(script_1, script_2, #script_1) template <class AI> diff --git a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp index a0cdc280f13..75b55d566d5 100644 --- a/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp +++ b/src/server/scripts/Northrend/FrozenHalls/ForgeOfSouls/boss_bronjahm.cpp @@ -344,5 +344,5 @@ void AddSC_boss_bronjahm() RegisterSpellScriptWithArgs(spell_bronjahm_soulstorm_visual, "spell_bronjahm_soulstorm_channel"); RegisterSpellScriptWithArgs(spell_bronjahm_soulstorm_visual, "spell_bronjahm_soulstorm_visual"); RegisterSpellScript(spell_bronjahm_soulstorm_targeting); - RegisterSpellScript(achievement_bronjahm_soul_power); + new achievement_bronjahm_soul_power(); } diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index cd8fcfb0663..6c6f88e0ba6 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -2200,33 +2200,22 @@ class spell_gen_interrupt : public AuraScript } }; -class spell_gen_increase_stats_buff : public SpellScriptLoader +class spell_gen_increase_stats_buff : public SpellScript { - public: - spell_gen_increase_stats_buff(char const* scriptName) : SpellScriptLoader(scriptName) { } - - class spell_gen_increase_stats_buff_SpellScript : public SpellScript - { - PrepareSpellScript(spell_gen_increase_stats_buff_SpellScript); - - void HandleDummy(SpellEffIndex /*effIndex*/) - { - if (GetHitUnit()->IsInRaidWith(GetCaster())) - GetCaster()->CastSpell(GetCaster(), GetEffectValue() + 1, true); // raid buff - else - GetCaster()->CastSpell(GetHitUnit(), GetEffectValue(), true); // single-target buff - } + PrepareSpellScript(spell_gen_increase_stats_buff); - void Register() override - { - OnEffectHitTarget += SpellEffectFn(spell_gen_increase_stats_buff_SpellScript::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); - } - }; + void HandleDummy(SpellEffIndex /*effIndex*/) + { + if (GetHitUnit()->IsInRaidWith(GetCaster())) + GetCaster()->CastSpell(GetCaster(), GetEffectValue() + 1, true); // raid buff + else + GetCaster()->CastSpell(GetHitUnit(), GetEffectValue(), true); // single-target buff + } - SpellScript* GetSpellScript() const override - { - return new spell_gen_increase_stats_buff_SpellScript(); - } + void Register() override + { + OnEffectHitTarget += SpellEffectFn(spell_gen_increase_stats_buff::HandleDummy, EFFECT_0, SPELL_EFFECT_DUMMY); + } }; enum GenericLifebloom diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index 22a2e8e9676..52baf698325 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -1336,66 +1336,54 @@ enum Heartpierce // Item - 50641: Heartpierce (Heroic) // 71892 - Item - Icecrown 25 Heroic Dagger Proc -template <uint32 EnergySpellId, uint32 ManaSpellId, uint32 RageSpellId, uint32 RPSpellId> -class spell_item_heartpierce : public SpellScriptLoader +template <uint32 Energy, uint32 Mana, uint32 Rage, uint32 RunicPower> +class spell_item_heartpierce : public AuraScript { - public: - spell_item_heartpierce(char const* ScriptName) : SpellScriptLoader(ScriptName) { } + PrepareAuraScript(spell_item_heartpierce); - template <uint32 Energy, uint32 Mana, uint32 Rage, uint32 RunicPower> - class spell_item_heartpierce_AuraScript : public AuraScript + bool Validate(SpellInfo const* /*spellInfo*/) override + { + return ValidateSpellInfo( { - PrepareAuraScript(spell_item_heartpierce_AuraScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return ValidateSpellInfo( - { - Energy, - Mana, - Rage, - RunicPower - }); - } - - void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) - { - PreventDefaultAction(); - Unit* caster = eventInfo.GetActor(); - - uint32 spellId; - switch (caster->GetPowerType()) - { - case POWER_MANA: - spellId = Mana; - break; - case POWER_ENERGY: - spellId = Energy; - break; - case POWER_RAGE: - spellId = Rage; - break; - // Death Knights can't use daggers, but oh well - case POWER_RUNIC_POWER: - spellId = RunicPower; - break; - default: - return; - } - - caster->CastSpell(nullptr, spellId, aurEff); - } + Energy, + Mana, + Rage, + RunicPower + }); + } - void Register() override - { - OnEffectProc += AuraEffectProcFn(spell_item_heartpierce_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); - } - }; + void HandleProc(AuraEffect* aurEff, ProcEventInfo& eventInfo) + { + PreventDefaultAction(); + Unit* caster = eventInfo.GetActor(); - AuraScript* GetAuraScript() const override + uint32 spellId; + switch (caster->GetPowerType()) { - return new spell_item_heartpierce_AuraScript<EnergySpellId, ManaSpellId, RageSpellId, RPSpellId>(); + case POWER_MANA: + spellId = Mana; + break; + case POWER_ENERGY: + spellId = Energy; + break; + case POWER_RAGE: + spellId = Rage; + break; + // Death Knights can't use daggers, but oh well + case POWER_RUNIC_POWER: + spellId = RunicPower; + break; + default: + return; } + + caster->CastSpell(nullptr, spellId, aurEff); + } + + void Register() override + { + OnEffectProc += AuraEffectProcFn(spell_item_heartpierce::HandleProc, EFFECT_0, SPELL_AURA_DUMMY); + } }; enum HourglassSand @@ -5002,8 +4990,8 @@ void AddSC_item_spell_scripts() RegisterSpellScript(spell_item_frozen_shadoweave); RegisterSpellScript(spell_item_gnomish_death_ray); RegisterSpellScript(spell_item_harm_prevention_belt); - new spell_item_heartpierce<SPELL_INVIGORATION_ENERGY, SPELL_INVIGORATION_MANA, SPELL_INVIGORATION_RAGE, SPELL_INVIGORATION_RP>("spell_item_heartpierce"); - new spell_item_heartpierce<SPELL_INVIGORATION_ENERGY_HERO, SPELL_INVIGORATION_MANA_HERO, SPELL_INVIGORATION_RAGE_HERO, SPELL_INVIGORATION_RP_HERO>("spell_item_heartpierce_hero"); + RegisterSpellScriptWithArgs((spell_item_heartpierce<SPELL_INVIGORATION_ENERGY, SPELL_INVIGORATION_MANA, SPELL_INVIGORATION_RAGE, SPELL_INVIGORATION_RP>), "spell_item_heartpierce"); + RegisterSpellScriptWithArgs((spell_item_heartpierce<SPELL_INVIGORATION_ENERGY_HERO, SPELL_INVIGORATION_MANA_HERO, SPELL_INVIGORATION_RAGE_HERO, SPELL_INVIGORATION_RP_HERO>), "spell_item_heartpierce_hero"); RegisterSpellScript(spell_item_hourglass_sand); RegisterSpellScript(spell_item_crystal_spire_of_karabor); RegisterSpellScript(spell_item_make_a_wish); |