aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Maps/Map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Maps/Map.cpp')
-rw-r--r--src/server/game/Maps/Map.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index b603d704f97..aa0f35abf15 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -17,6 +17,8 @@
#include "Map.h"
#include "Battleground.h"
+#include "BattlegroundMgr.h"
+#include "BattlegroundScript.h"
#include "CellImpl.h"
#include "CharacterPackets.h"
#include "Containers.h"
@@ -3385,7 +3387,7 @@ TeamId InstanceMap::GetTeamIdInInstance() const
/* ******* Battleground Instance Maps ******* */
BattlegroundMap::BattlegroundMap(uint32 id, time_t expiry, uint32 InstanceId, Difficulty spawnMode)
- : Map(id, expiry, InstanceId, spawnMode), m_bg(nullptr)
+ : Map(id, expiry, InstanceId, spawnMode), m_bg(nullptr), _battlegroundScript(nullptr), _scriptId(0)
{
//lets initialize visibility distance for BG/Arenas
BattlegroundMap::InitVisibilityDistance();
@@ -3408,6 +3410,36 @@ void BattlegroundMap::InitVisibilityDistance()
m_VisibilityNotifyPeriod = IsBattleArena() ? World::GetVisibilityNotifyPeriodInArenas() : World::GetVisibilityNotifyPeriodInBG();
}
+std::string const& BattlegroundMap::GetScriptName() const
+{
+ return sObjectMgr->GetScriptName(_scriptId);
+}
+
+void BattlegroundMap::InitScriptData()
+{
+ if (_battlegroundScript)
+ return;
+
+ ASSERT(GetBG(), "Battleground not set yet!");
+
+ if (BattlegroundScriptTemplate const* scriptTemplate = sBattlegroundMgr->FindBattlegroundScriptTemplate(GetId(), GetBG()->GetTypeID()))
+ {
+ _scriptId = scriptTemplate->ScriptId;
+ _battlegroundScript.reset(sScriptMgr->CreateBattlegroundData(this));
+ }
+
+ // Make sure every battleground has a default script
+ if (!_battlegroundScript)
+ {
+ if (IsBattleArena())
+ _battlegroundScript = std::make_unique<ArenaScript>(this);
+ else
+ _battlegroundScript = std::make_unique<BattlegroundScript>(this);
+ }
+
+ _battlegroundScript->OnInit();
+}
+
TransferAbortParams BattlegroundMap::CannotEnter(Player* player)
{
if (player->GetMapRef().getTarget() == this)
@@ -3451,6 +3483,12 @@ void BattlegroundMap::RemoveAllPlayers()
player->TeleportTo(player->GetBattlegroundEntryPoint());
}
+void BattlegroundMap::Update(uint32 diff)
+{
+ Map::Update(diff);
+ _battlegroundScript->OnUpdate(diff);
+}
+
AreaTrigger* Map::GetAreaTrigger(ObjectGuid const& guid)
{
return _objectsStore.Find<AreaTrigger>(guid);