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)
This commit is contained in:
@@ -501,17 +501,23 @@ namespace Game.BattleGrounds
|
|||||||
Global.WorldMgr.SendWorldText(m_ArenaTesting ? CypherStrings.DebugArenaOn : CypherStrings.DebugArenaOff);
|
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 i = BattlegroundTypeId.AV; i < BattlegroundTypeId.Max; i++)
|
||||||
for (var bgtype = 1; bgtype < (int)BattlegroundTypeId.Max && bgtype < 32; ++bgtype)
|
|
||||||
{
|
{
|
||||||
Battleground bg = GetBattlegroundTemplate((BattlegroundTypeId)bgtype);
|
Battleground bg = GetBattlegroundTemplate(i);
|
||||||
if (bg)
|
if (bg != null)
|
||||||
bg.SetHoliday(Convert.ToBoolean(mask & (1 << bgtype)));
|
bg.SetHoliday(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetHolidayActive(uint battlegroundId)
|
||||||
|
{
|
||||||
|
Battleground bg = GetBattlegroundTemplate((BattlegroundTypeId)battlegroundId);
|
||||||
|
if (bg != null)
|
||||||
|
bg.SetHoliday(true);
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsValidQueueId(BattlegroundQueueTypeId bgQueueTypeId)
|
public bool IsValidQueueId(BattlegroundQueueTypeId bgQueueTypeId)
|
||||||
{
|
{
|
||||||
BattlemasterListRecord battlemasterList = CliDB.BattlemasterListStorage.LookupByKey(bgQueueTypeId.BattlemasterListId);
|
BattlemasterListRecord battlemasterList = CliDB.BattlemasterListStorage.LookupByKey(bgQueueTypeId.BattlemasterListId);
|
||||||
|
|||||||
@@ -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();
|
uint oldMSTime = Time.GetMSTime();
|
||||||
|
|
||||||
// 0 1
|
// 0 1
|
||||||
SQLResult result = DB.World.Query("SELECT eventEntry, bgflag FROM game_event_battleground_holiday");
|
SQLResult result = DB.World.Query("SELECT EventEntry, BattlegroundID FROM game_event_battleground_holiday");
|
||||||
if (result.IsEmpty())
|
if (result.IsEmpty())
|
||||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 Battlegroundholidays in game events. DB table `game_event_battleground_holiday` is empty.");
|
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 Battlegroundholidays in game events. DB table `game_event_battleground_holiday` is empty.");
|
||||||
else
|
else
|
||||||
@@ -836,15 +836,15 @@ namespace Game
|
|||||||
uint count = 0;
|
uint count = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ushort event_id = result.Read<byte>(0);
|
ushort eventId = result.Read<byte>(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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
mGameEventBattlegroundHolidays[event_id] = result.Read<uint>(1);
|
mGameEventBattlegroundHolidays[eventId] = result.Read<uint>(1);
|
||||||
|
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
@@ -1153,11 +1153,10 @@ namespace Game
|
|||||||
|
|
||||||
void UpdateBattlegroundSettings()
|
void UpdateBattlegroundSettings()
|
||||||
{
|
{
|
||||||
uint mask = 0;
|
Global.BattlegroundMgr.ResetHolidays();
|
||||||
foreach (var eventId in m_ActiveEvents)
|
|
||||||
mask |= mGameEventBattlegroundHolidays[eventId];
|
|
||||||
|
|
||||||
Global.BattlegroundMgr.SetHolidayWeekends(mask);
|
foreach (ushort activeEventId in m_ActiveEvents)
|
||||||
|
Global.BattlegroundMgr.SetHolidayActive(mGameEventBattlegroundHolidays[activeEventId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateEventNPCVendor(ushort eventId, bool activate)
|
void UpdateEventNPCVendor(ushort eventId, bool activate)
|
||||||
@@ -1678,10 +1677,10 @@ namespace Game
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsEventActive(ushort event_id)
|
public bool IsEventActive(ushort eventId)
|
||||||
{
|
{
|
||||||
var ae = GetActiveEventList();
|
var ae = GetActiveEventList();
|
||||||
return ae.Contains(event_id);
|
return ae.Contains(eventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ushort> GetActiveEventList() { return m_ActiveEvents; }
|
public List<ushort> GetActiveEventList() { return m_ActiveEvents; }
|
||||||
|
|||||||
Reference in New Issue
Block a user