aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Scripting/ScriptMgr.cpp
diff options
context:
space:
mode:
authorJeremy <Golrag@users.noreply.github.com>2024-03-28 19:29:22 +0100
committerGitHub <noreply@github.com>2024-03-28 19:29:22 +0100
commitbe11f42a16d1fa0482e9572bf54e99e4dedd3c78 (patch)
tree3d33413d7ed5cada34d7ced7f430380731160d5b /src/server/game/Scripting/ScriptMgr.cpp
parent78635f640ee3b632a487a50dcf492ae62c2a0933 (diff)
Core/Battlegrounds: Move to scripts (#29799)
* Introduce new BattlegroundScript class for map/bg specific scripts * Remove all sub, zone specific, battleground classes except Arena * Move all bg zone scripts to new BattlegroundScripts class in script folder * Remove ZoneScript from Battleground class * Remove some unused hooks from Battleground
Diffstat (limited to 'src/server/game/Scripting/ScriptMgr.cpp')
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp65
1 files changed, 43 insertions, 22 deletions
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index 76a51e0795f..e69b64a73fa 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -90,7 +90,7 @@ struct is_script_database_bound<BattlefieldScript>
: std::true_type { };
template<>
-struct is_script_database_bound<BattlegroundScript>
+struct is_script_database_bound<BattlegroundMapScript>
: std::true_type { };
template<>
@@ -754,11 +754,6 @@ template<typename Base>
class ScriptRegistrySwapHooks<BattlefieldScript, Base>
: public UnsupportedScriptRegistrySwapHooks<Base> { };
-/// This hook is responsible for swapping BattlegroundScript's
-template<typename Base>
-class ScriptRegistrySwapHooks<BattlegroundScript, Base>
- : public UnsupportedScriptRegistrySwapHooks<Base> { };
-
/// This hook is responsible for swapping OutdoorPvP's
template<typename Base>
class ScriptRegistrySwapHooks<OutdoorPvPScript, Base>
@@ -826,6 +821,35 @@ private:
bool swapped;
};
+/// This hook is responsible for swapping BattlegroundMapScript's
+template<typename Base>
+class ScriptRegistrySwapHooks<BattlegroundMapScript, Base>
+ : public ScriptRegistrySwapHookBase
+{
+public:
+ ScriptRegistrySwapHooks() : swapped(false) { }
+
+ void BeforeReleaseContext(std::string const& context) final override
+ {
+ auto const bounds = static_cast<Base*>(this)->_ids_of_contexts.equal_range(context);
+ if (bounds.first != bounds.second)
+ swapped = true;
+ }
+
+ void BeforeSwapContext(bool /*initialize*/) override
+ {
+ swapped = false;
+ }
+
+ void BeforeUnload() final override
+ {
+ ASSERT(!swapped);
+ }
+
+private:
+ bool swapped;
+};
+
/// This hook is responsible for swapping SceneScript's
template<typename Base>
class ScriptRegistrySwapHooks<SceneScript, Base>
@@ -1623,6 +1647,14 @@ InstanceScript* ScriptMgr::CreateInstanceData(InstanceMap* map)
return tmpscript->GetInstanceScript(map);
}
+BattlegroundScript* ScriptMgr::CreateBattlegroundData(BattlegroundMap* map)
+{
+ ASSERT(map);
+
+ GET_SCRIPT_RET(BattlegroundMapScript, map->GetScriptId(), tmpscript, NULL);
+ return tmpscript->GetBattlegroundScript(map);
+}
+
bool ScriptMgr::OnQuestAccept(Player* player, Item* item, Quest const* quest)
{
ASSERT(player);
@@ -1726,13 +1758,6 @@ Battlefield* ScriptMgr::CreateBattlefield(uint32 scriptId, Map* map)
return tmpscript->GetBattlefield(map);
}
-Battleground* ScriptMgr::CreateBattleground(BattlegroundTypeId /*typeId*/)
-{
- /// @todo Implement script-side battlegrounds.
- ABORT();
- return nullptr;
-}
-
OutdoorPvP* ScriptMgr::CreateOutdoorPvP(uint32 scriptId, Map* map)
{
GET_SCRIPT_RET(OutdoorPvPScript, scriptId, tmpscript, nullptr);
@@ -2582,6 +2607,11 @@ BattlegroundMapScript::BattlegroundMapScript(char const* name, uint32 mapId)
BattlegroundMapScript::~BattlegroundMapScript() = default;
+BattlegroundScript* BattlegroundMapScript::GetBattlegroundScript(BattlegroundMap* /*map*/) const
+{
+ return nullptr;
+}
+
ItemScript::ItemScript(char const* name)
: ScriptObject(name)
{
@@ -2702,14 +2732,6 @@ BattlefieldScript::BattlefieldScript(char const* name)
BattlefieldScript::~BattlefieldScript() = default;
-BattlegroundScript::BattlegroundScript(char const* name)
- : ScriptObject(name)
-{
- ScriptRegistry<BattlegroundScript>::Instance()->AddScript(this);
-}
-
-BattlegroundScript::~BattlegroundScript() = default;
-
OutdoorPvPScript::OutdoorPvPScript(char const* name)
: ScriptObject(name)
{
@@ -3247,7 +3269,6 @@ template class TC_GAME_API ScriptRegistry<CreatureScript>;
template class TC_GAME_API ScriptRegistry<GameObjectScript>;
template class TC_GAME_API ScriptRegistry<AreaTriggerScript>;
template class TC_GAME_API ScriptRegistry<BattlefieldScript>;
-template class TC_GAME_API ScriptRegistry<BattlegroundScript>;
template class TC_GAME_API ScriptRegistry<OutdoorPvPScript>;
template class TC_GAME_API ScriptRegistry<CommandScript>;
template class TC_GAME_API ScriptRegistry<WeatherScript>;