From 49523a74a4c28e5ae17f9a8352aa8224b765b7d8 Mon Sep 17 00:00:00 2001 From: Carbenium Date: Mon, 22 Jun 2020 16:10:34 +0200 Subject: Battlefields: Move BF scripts out of game This commit introduces the usual script interface for battlefields. (cherry picked from commit f7faf20254a120a90b8ee8eb55a284a6351aabc3) --- src/server/game/Scripting/ScriptMgr.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/server/game/Scripting/ScriptMgr.cpp') diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 038aa13a952..6eb82ae349a 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -84,6 +84,10 @@ template<> struct is_script_database_bound : std::true_type { }; +template<> +struct is_script_database_bound + : std::true_type { }; + template<> struct is_script_database_bound : std::true_type { }; @@ -724,6 +728,11 @@ class ScriptRegistrySwapHooks AreaTrigger, AreaTriggerEntityScript, Base > { }; +/// This hook is responsible for swapping BattlefieldScripts +template +class ScriptRegistrySwapHooks + : public UnsupportedScriptRegistrySwapHooks { }; + /// This hook is responsible for swapping BattlegroundScript's template class ScriptRegistrySwapHooks @@ -1720,6 +1729,12 @@ bool ScriptMgr::OnAreaTrigger(Player* player, AreaTriggerEntry const* trigger, b return entered ? tmpscript->OnTrigger(player, trigger) : tmpscript->OnExit(player, trigger); } +Battlefield* ScriptMgr::CreateBattlefield(uint32 scriptId) +{ + GET_SCRIPT_RET(BattlefieldScript, scriptId, tmpscript, nullptr); + return tmpscript->GetBattlefield(); +} + Battleground* ScriptMgr::CreateBattleground(BattlegroundTypeId /*typeId*/) { /// @todo Implement script-side battlegrounds. @@ -2437,6 +2452,12 @@ bool OnlyOnceAreaTriggerScript::OnTrigger(Player* player, AreaTriggerEntry const void OnlyOnceAreaTriggerScript::ResetAreaTriggerDone(InstanceScript* script, uint32 triggerId) { script->ResetAreaTriggerDone(triggerId); } void OnlyOnceAreaTriggerScript::ResetAreaTriggerDone(Player const* player, AreaTriggerEntry const* trigger) { if (InstanceScript* instance = player->GetInstanceScript()) ResetAreaTriggerDone(instance, trigger->ID); } +BattlefieldScript::BattlefieldScript(char const* name) + : ScriptObject(name) +{ + ScriptRegistry::Instance()->AddScript(this); +} + BattlegroundScript::BattlegroundScript(char const* name) : ScriptObject(name) { @@ -2557,6 +2578,7 @@ template class TC_GAME_API ScriptRegistry; template class TC_GAME_API ScriptRegistry; template class TC_GAME_API ScriptRegistry; template class TC_GAME_API ScriptRegistry; +template class TC_GAME_API ScriptRegistry; template class TC_GAME_API ScriptRegistry; template class TC_GAME_API ScriptRegistry; template class TC_GAME_API ScriptRegistry; -- cgit v1.2.3