From ccff3af92467ee7b183bb2b5cc98f8c6e71adaed Mon Sep 17 00:00:00 2001 From: Shauren Date: Wed, 21 Dec 2022 22:01:54 +0100 Subject: [PATCH] Core/WorldStates: Migrate battleground HolidayWorldState to new system --- .../world/4.3.4/2022_12_21_02_world.sql | 10 ++++++++++ src/server/game/Entities/Player/Player.cpp | 16 ---------------- src/server/game/Entities/Player/Player.h | 1 - src/server/game/Events/GameEventMgr.cpp | 18 ++++-------------- .../game/World/WorldStates/WorldStateMgr.cpp | 4 ++-- 5 files changed, 16 insertions(+), 33 deletions(-) create mode 100644 sql/updates/world/4.3.4/2022_12_21_02_world.sql diff --git a/sql/updates/world/4.3.4/2022_12_21_02_world.sql b/sql/updates/world/4.3.4/2022_12_21_02_world.sql new file mode 100644 index 0000000000..e1f922946c --- /dev/null +++ b/sql/updates/world/4.3.4/2022_12_21_02_world.sql @@ -0,0 +1,10 @@ +DELETE FROM `world_state` WHERE `ID` IN (1941,1942,1943,2851,3695,4273,5360,5361,6306,6436,7671); +INSERT INTO `world_state` (`ID`,`DefaultValue`,`MapIDs`,`AreaIDs`,`ScriptName`,`Comment`) VALUES +(1941,0,NULL,NULL,'','Battleground Call to Arms - Alterac Valley'), +(1942,0,NULL,NULL,'','Battleground Call to Arms - Warsong Gulch'), +(1943,0,NULL,NULL,'','Battleground Call to Arms - Arathi Basin'), +(2851,0,NULL,NULL,'','Battleground Call to Arms - Eye of the Storm'), +(3695,0,NULL,NULL,'','Battleground Call to Arms - Strand of the Ancients'), +(4273,0,NULL,NULL,'','Battleground Call to Arms - Isle of Conquest'), +(5360,0,NULL,NULL,'','Battleground Call to Arms - The Battle for Gilneas'), +(5361,0,NULL,NULL,'','Battleground Call to Arms - Twin Peaks'); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 2ee71a4999..a671b8b869 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -8779,22 +8779,6 @@ void Player::SendInitWorldStates(uint32 zoneId, uint32 areaId) packet.Worldstates.emplace_back(3901, int32(sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID) - sWorld->getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS))); // 8 PreviousSeason 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); - } - } } uint32 Player::GetXPRestBonus(uint32 xp) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index acdf605887..24afc689bb 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -2044,7 +2044,6 @@ class TC_GAME_API Player : public Unit, public GridObject void SendInitWorldStates(uint32 zone, uint32 area); 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 537b6fc7d2..8773b86f71 100644 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -30,7 +30,7 @@ #include "PoolMgr.h" #include "UnitAI.h" #include "World.h" -#include "WorldPacket.h" +#include "WorldStateMgr.h" GameEventMgr* GameEventMgr::instance() { @@ -1581,19 +1581,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) - { - WorldPacket data; - sBattlegroundMgr->BuildUpdateWorldStatePacket(&data, bl->HolidayWorldState, Activate ? 1 : 0); - sWorld->SendGlobalMessage(&data); - } - } - } + 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 764d833f31..b220ae1b30 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);