diff options
author | Ovahlord <dreadkiller@gmx.de> | 2020-07-07 13:56:16 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-01-21 22:09:06 +0100 |
commit | 7a5529eb58daad9216416c9c632543b1a931ce1f (patch) | |
tree | 57b17d1da4ef153cf33574c9f9110108a86117c5 | |
parent | 92e77e456a86900a673c927053c739ce4d0f4bc3 (diff) |
Core/Events: refactored battleground holiday assignments.
Instead of going with shitty bitmasks we now accept plain battleground ids
instead
(cherry picked from commit 8a82403400ef49415e14530f4b55d55ef38bc74e)
-rw-r--r-- | sql/updates/world/master/2022_01_21_31_world_2020_07_07_00_world.sql | 12 | ||||
-rw-r--r-- | src/server/game/Battlegrounds/BattlegroundMgr.cpp | 15 | ||||
-rw-r--r-- | src/server/game/Battlegrounds/BattlegroundMgr.h | 3 | ||||
-rw-r--r-- | src/server/game/Events/GameEventMgr.cpp | 18 | ||||
-rw-r--r-- | src/server/game/Events/GameEventMgr.h | 6 |
5 files changed, 36 insertions, 18 deletions
diff --git a/sql/updates/world/master/2022_01_21_31_world_2020_07_07_00_world.sql b/sql/updates/world/master/2022_01_21_31_world_2020_07_07_00_world.sql new file mode 100644 index 00000000000..c4fd7462fe0 --- /dev/null +++ b/sql/updates/world/master/2022_01_21_31_world_2020_07_07_00_world.sql @@ -0,0 +1,12 @@ +ALTER TABLE `game_event_battleground_holiday` + CHANGE `eventEntry` `EventEntry` TINYINT(3) UNSIGNED NOT NULL COMMENT 'game_event EventEntry identifier', + CHANGE `bgflag` `BattlegroundID` INT(3) UNSIGNED DEFAULT 0 NOT NULL; + +DELETE FROM `game_event_battleground_holiday`; +-- INSERT INTO `game_event_battleground_holiday` (`EventEntry`, `BattlegroundID`) VALUES +-- (18, 1), +-- (19, 2), +-- (20, 3), +-- (21, 7), +-- (53, 9), +-- (54, 30); diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index 7cca34a4246..4447665b892 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -620,12 +620,17 @@ void BattlegroundMgr::ToggleArenaTesting() sWorld->SendWorldText(m_ArenaTesting ? LANG_DEBUG_ARENA_ON : LANG_DEBUG_ARENA_OFF); } -void BattlegroundMgr::SetHolidayWeekends(uint32 mask) +void BattlegroundMgr::ResetHolidays() { - // The current code supports battlegrounds up to BattlegroundTypeId(31) - for (uint32 bgtype = 1; bgtype < MAX_BATTLEGROUND_TYPE_ID && bgtype < 32; ++bgtype) - if (Battleground* bg = GetBattlegroundTemplate(BattlegroundTypeId(bgtype))) - bg->SetHoliday((mask & (1 << bgtype)) != 0); + for (uint32 i = BATTLEGROUND_AV; i < MAX_BATTLEGROUND_TYPE_ID; i++) + if (Battleground* bg = GetBattlegroundTemplate(BattlegroundTypeId(i))) + bg->SetHoliday(false); +} + +void BattlegroundMgr::SetHolidayActive(uint32 battlegroundId) +{ + if (Battleground* bg = GetBattlegroundTemplate(BattlegroundTypeId(battlegroundId))) + bg->SetHoliday(true); } bool BattlegroundMgr::IsValidQueueId(BattlegroundQueueTypeId bgQueueTypeId) diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.h b/src/server/game/Battlegrounds/BattlegroundMgr.h index 7564c4ebdbb..7653ddd5ba1 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.h +++ b/src/server/game/Battlegrounds/BattlegroundMgr.h @@ -118,7 +118,8 @@ class TC_GAME_API BattlegroundMgr void ToggleArenaTesting(); void ToggleTesting(); - void SetHolidayWeekends(uint32 mask); + void ResetHolidays(); + void SetHolidayActive(uint32 battlegroundId); bool isArenaTesting() const { return m_ArenaTesting; } bool isTesting() const { return m_Testing; } diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index f2f0db87a59..0450104364f 100644 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -875,12 +875,12 @@ void GameEventMgr::LoadFromDB() } } - TC_LOG_INFO("server.loading", "Loading Game Event Battleground Data..."); + TC_LOG_INFO("server.loading", "Loading Game Event Battleground Holiday Data..."); { uint32 oldMSTime = getMSTime(); - // 0 1 - QueryResult result = WorldDatabase.Query("SELECT eventEntry, bgflag FROM game_event_battleground_holiday"); + // 0 1 + QueryResult result = WorldDatabase.Query("SELECT EventEntry, BattlegroundID FROM game_event_battleground_holiday"); if (!result) TC_LOG_INFO("server.loading", ">> Loaded 0 battleground holidays in game events. DB table `game_event_battleground_holiday` is empty."); @@ -1195,10 +1195,10 @@ void GameEventMgr::UpdateEventNPCFlags(uint16 event_id) void GameEventMgr::UpdateBattlegroundSettings() { - uint32 mask = 0; - for (ActiveEvents::const_iterator itr = m_ActiveEvents.begin(); itr != m_ActiveEvents.end(); ++itr) - mask |= mGameEventBattlegroundHolidays[*itr]; - sBattlegroundMgr->SetHolidayWeekends(mask); + sBattlegroundMgr->ResetHolidays(); + + for (uint16 activeEventId : m_ActiveEvents) + sBattlegroundMgr->SetHolidayActive(mGameEventBattlegroundHolidays[activeEventId]); } void GameEventMgr::UpdateEventNPCVendor(uint16 event_id, bool activate) @@ -1811,8 +1811,8 @@ bool IsHolidayActive(HolidayIds id) return false; } -bool IsEventActive(uint16 event_id) +bool IsEventActive(uint16 eventId) { GameEventMgr::ActiveEvents const& ae = sGameEventMgr->GetActiveEventList(); - return ae.find(event_id) != ae.end(); + return ae.find(eventId) != ae.end(); } diff --git a/src/server/game/Events/GameEventMgr.h b/src/server/game/Events/GameEventMgr.h index b889394d848..ba13beb0b59 100644 --- a/src/server/game/Events/GameEventMgr.h +++ b/src/server/game/Events/GameEventMgr.h @@ -156,7 +156,7 @@ class TC_GAME_API GameEventMgr typedef std::pair<ObjectGuid::LowType /*guid*/, uint64 /*npcflag*/> GuidNPCFlagPair; typedef std::list<GuidNPCFlagPair> NPCFlagList; typedef std::vector<NPCFlagList> GameEventNPCFlagMap; - typedef std::vector<uint32> GameEventBitmask; + typedef std::vector<uint32> GameEventBattlegroundMap; GameEventQuestMap mGameEventCreatureQuests; GameEventQuestMap mGameEventGameObjectQuests; GameEventNPCVendorMap mGameEventVendors; @@ -165,7 +165,7 @@ class TC_GAME_API GameEventMgr //GameEventGuidMap mGameEventGameobjectGuids; GameEventIdMap mGameEventPoolIds; GameEventDataMap mGameEvent; - GameEventBitmask mGameEventBattlegroundHolidays; + GameEventBattlegroundMap mGameEventBattlegroundHolidays; QuestIdToEventConditionMap mQuestToEventConditions; GameEventNPCFlagMap mGameEventNPCFlags; ActiveEvents m_ActiveEvents; @@ -179,6 +179,6 @@ class TC_GAME_API GameEventMgr #define sGameEventMgr GameEventMgr::instance() TC_GAME_API bool IsHolidayActive(HolidayIds id); -TC_GAME_API bool IsEventActive(uint16 event_id); +TC_GAME_API bool IsEventActive(uint16 eventId); #endif |