From cb58698045f317daec55c5c508d38da23248ad12 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 27 Feb 2022 23:44:42 -0500 Subject: [PATCH] Core/Events: refactored battleground holiday assignments. Instead of going with shitty bitmasks we now accept plain battleground ids instead Port From (https://github.com/TrinityCore/TrinityCore/commit/7a5529eb58daad9216416c9c632543b1a931ce1f) --- .../Game/BattleGrounds/BattleGroundManager.cs | 18 ++++++++----- Source/Game/Events/GameEventManager.cs | 25 +++++++++---------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/Source/Game/BattleGrounds/BattleGroundManager.cs b/Source/Game/BattleGrounds/BattleGroundManager.cs index ddde247a3..ec16d68dc 100644 --- a/Source/Game/BattleGrounds/BattleGroundManager.cs +++ b/Source/Game/BattleGrounds/BattleGroundManager.cs @@ -501,17 +501,23 @@ namespace Game.BattleGrounds Global.WorldMgr.SendWorldText(m_ArenaTesting ? CypherStrings.DebugArenaOn : CypherStrings.DebugArenaOff); } - public void SetHolidayWeekends(uint mask) + public void ResetHolidays() { - // The current code supports battlegrounds up to BattlegroundTypeId(31) - for (var bgtype = 1; bgtype < (int)BattlegroundTypeId.Max && bgtype < 32; ++bgtype) + for (var i = BattlegroundTypeId.AV; i < BattlegroundTypeId.Max; i++) { - Battleground bg = GetBattlegroundTemplate((BattlegroundTypeId)bgtype); - if (bg) - bg.SetHoliday(Convert.ToBoolean(mask & (1 << bgtype))); + Battleground bg = GetBattlegroundTemplate(i); + if (bg != null) + bg.SetHoliday(false); } } + public void SetHolidayActive(uint battlegroundId) + { + Battleground bg = GetBattlegroundTemplate((BattlegroundTypeId)battlegroundId); + if (bg != null) + bg.SetHoliday(true); + } + public bool IsValidQueueId(BattlegroundQueueTypeId bgQueueTypeId) { BattlemasterListRecord battlemasterList = CliDB.BattlemasterListStorage.LookupByKey(bgQueueTypeId.BattlemasterListId); diff --git a/Source/Game/Events/GameEventManager.cs b/Source/Game/Events/GameEventManager.cs index 8642f84b3..62f8749d6 100644 --- a/Source/Game/Events/GameEventManager.cs +++ b/Source/Game/Events/GameEventManager.cs @@ -823,12 +823,12 @@ namespace Game } } - Log.outInfo(LogFilter.ServerLoading, "Loading Game Event BattlegroundData..."); + Log.outInfo(LogFilter.ServerLoading, "Loading Game Event Battleground Holiday Data..."); { uint oldMSTime = Time.GetMSTime(); - // 0 1 - SQLResult result = DB.World.Query("SELECT eventEntry, bgflag FROM game_event_battleground_holiday"); + // 0 1 + SQLResult result = DB.World.Query("SELECT EventEntry, BattlegroundID FROM game_event_battleground_holiday"); if (result.IsEmpty()) Log.outInfo(LogFilter.ServerLoading, "Loaded 0 Battlegroundholidays in game events. DB table `game_event_battleground_holiday` is empty."); else @@ -836,15 +836,15 @@ namespace Game uint count = 0; do { - ushort event_id = result.Read(0); + ushort eventId = result.Read(0); - if (event_id >= mGameEvent.Length) + if (eventId >= mGameEvent.Length) { - Log.outError(LogFilter.Sql, "`game_event_battleground_holiday` game event id ({0}) not exist in `game_event`", event_id); + Log.outError(LogFilter.Sql, "`game_event_battleground_holiday` game event id ({0}) not exist in `game_event`", eventId); continue; } - mGameEventBattlegroundHolidays[event_id] = result.Read(1); + mGameEventBattlegroundHolidays[eventId] = result.Read(1); ++count; } @@ -1153,11 +1153,10 @@ namespace Game void UpdateBattlegroundSettings() { - uint mask = 0; - foreach (var eventId in m_ActiveEvents) - mask |= mGameEventBattlegroundHolidays[eventId]; + Global.BattlegroundMgr.ResetHolidays(); - Global.BattlegroundMgr.SetHolidayWeekends(mask); + foreach (ushort activeEventId in m_ActiveEvents) + Global.BattlegroundMgr.SetHolidayActive(mGameEventBattlegroundHolidays[activeEventId]); } void UpdateEventNPCVendor(ushort eventId, bool activate) @@ -1678,10 +1677,10 @@ namespace Game return false; } - public bool IsEventActive(ushort event_id) + public bool IsEventActive(ushort eventId) { var ae = GetActiveEventList(); - return ae.Contains(event_id); + return ae.Contains(eventId); } public List GetActiveEventList() { return m_ActiveEvents; }