aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-07-11 16:15:07 +0200
committerShauren <shauren.trinity@gmail.com>2022-07-11 16:15:07 +0200
commit020166649dd5afb94dddbfcc990d4bb51e231ab1 (patch)
treeda12cbd9de8fe174d74fb52a8fd26964f30a2b08 /src
parent36ff703df55704265a28e28f4ea9f9cdcb54e85c (diff)
Core/WorldStates: Migrate battleground HolidayWorldState to new system
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Player/Player.cpp16
-rw-r--r--src/server/game/Entities/Player/Player.h1
-rw-r--r--src/server/game/Events/GameEventMgr.cpp20
-rw-r--r--src/server/game/World/WorldStates/WorldStateMgr.cpp4
4 files changed, 6 insertions, 35 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 35e777be790..da8b1b74883 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -9232,22 +9232,6 @@ void Player::SendInitWorldStates(uint32 zoneId, uint32 areaId)
packet.Worldstates.emplace_back(3901, previousArenaSeason);
SendDirectMessage(packet.Write());
- SendBGWeekendWorldStates();
-}
-
-void Player::SendBGWeekendWorldStates() const
-{
- for (uint32 i = 1; i < sBattlemasterListStore.GetNumRows(); ++i)
- {
- BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(i);
- if (bl && bl->HolidayWorldState)
- {
- if (BattlegroundMgr::IsBGWeekend((BattlegroundTypeId)bl->ID))
- SendUpdateWorldState(bl->HolidayWorldState, 1);
- else
- SendUpdateWorldState(bl->HolidayWorldState, 0);
- }
- }
}
void Player::SetBindPoint(ObjectGuid guid) const
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index efa7e7ef760..d12f15ce881 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -2352,7 +2352,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void SendInitWorldStates(uint32 zoneId, uint32 areaId);
void SendUpdateWorldState(uint32 variable, uint32 value, bool hidden = false) const;
void SendDirectMessage(WorldPacket const* data) const;
- void SendBGWeekendWorldStates() const;
void SendAurasForTarget(Unit* target) const;
diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp
index 5dc3630af91..daf0a510deb 100644
--- a/src/server/game/Events/GameEventMgr.cpp
+++ b/src/server/game/Events/GameEventMgr.cpp
@@ -32,7 +32,7 @@
#include "PoolMgr.h"
#include "StringConvert.h"
#include "World.h"
-#include "WorldStatePackets.h"
+#include "WorldStateMgr.h"
GameEventMgr* GameEventMgr::instance()
{
@@ -1550,21 +1550,9 @@ void GameEventMgr::UpdateWorldStates(uint16 event_id, bool Activate)
{
GameEventData const& event = mGameEvent[event_id];
if (event.holiday_id != HOLIDAY_NONE)
- {
- BattlegroundTypeId bgTypeId = BattlegroundMgr::WeekendHolidayIdToBGType(event.holiday_id);
- if (bgTypeId != BATTLEGROUND_TYPE_NONE)
- {
- BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(bgTypeId);
- if (bl && bl->HolidayWorldState)
- {
- WorldPackets::WorldState::UpdateWorldState worldstate;
- worldstate.VariableID = bl->HolidayWorldState;
- worldstate.Value = Activate;
- //worldstate.Hidden = false;
- sWorld->SendGlobalMessage(worldstate.Write());
- }
- }
- }
+ if (BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(BattlegroundMgr::WeekendHolidayIdToBGType(event.holiday_id)))
+ if (bl->HolidayWorldState)
+ sWorldStateMgr->SetValue(bl->HolidayWorldState, Activate ? 1 : 0, false, nullptr);
}
GameEventMgr::GameEventMgr() : isSystemInit(false)
diff --git a/src/server/game/World/WorldStates/WorldStateMgr.cpp b/src/server/game/World/WorldStates/WorldStateMgr.cpp
index 03bd704584d..a09e9e82977 100644
--- a/src/server/game/World/WorldStates/WorldStateMgr.cpp
+++ b/src/server/game/World/WorldStates/WorldStateMgr.cpp
@@ -156,7 +156,7 @@ int32 WorldStateMgr::GetValue(int32 worldStateId, Map const* map) const
return 0;
}
- if (worldStateTemplate->MapIds.find(map->GetId()) == worldStateTemplate->MapIds.end())
+ if (!map || worldStateTemplate->MapIds.find(map->GetId()) == worldStateTemplate->MapIds.end())
return 0;
return map->GetWorldStateValue(worldStateId);
@@ -186,7 +186,7 @@ void WorldStateMgr::SetValue(int32 worldStateId, int32 value, bool hidden, Map*
return;
}
- if (worldStateTemplate->MapIds.find(map->GetId()) == worldStateTemplate->MapIds.end())
+ if (!map || worldStateTemplate->MapIds.find(map->GetId()) == worldStateTemplate->MapIds.end())
return;
map->SetWorldStateValue(worldStateId, value, hidden);