mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 15:40:45 +01:00
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
This commit is contained in:
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user