Core: SOme code cleanup, more to follow.

This commit is contained in:
hondacrx
2021-03-20 22:48:48 -04:00
parent 62f554f2e0
commit 62ec699ec6
318 changed files with 5080 additions and 5125 deletions
+25 -25
View File
@@ -187,7 +187,7 @@ namespace Game.BattleGrounds
{
m_LastPlayerPositionBroadcast = 0;
BattlegroundPlayerPositions playerPositions = new BattlegroundPlayerPositions();
BattlegroundPlayerPositions playerPositions = new();
for (var i =0; i < _playerPositions.Count; ++i)
{
var playerPosition = _playerPositions[i];
@@ -349,7 +349,7 @@ namespace Game.BattleGrounds
{
uint countdownMaxForBGType = IsArena() ? BattlegroundConst.ArenaCountdownMax : BattlegroundConst.BattlegroundCountdownMax;
StartTimer timer = new StartTimer();
StartTimer timer = new();
timer.Type = TimerType.Pvp;
timer.TimeRemaining = countdownMaxForBGType - (GetElapsedTime() / 1000);
timer.TotalTime = countdownMaxForBGType;
@@ -568,8 +568,8 @@ namespace Game.BattleGrounds
return;
}
BroadcastTextBuilder builder = new BroadcastTextBuilder(null, msgType, id, Gender.Male, target);
LocalizedPacketDo localizer = new LocalizedPacketDo(builder);
BroadcastTextBuilder builder = new(null, msgType, id, Gender.Male, target);
LocalizedPacketDo localizer = new(builder);
BroadcastWorker(localizer);
}
@@ -634,7 +634,7 @@ namespace Game.BattleGrounds
public void UpdateWorldState(uint variable, uint value, bool hidden = false)
{
UpdateWorldState worldstate = new UpdateWorldState();
UpdateWorldState worldstate = new();
worldstate.VariableID = variable;
worldstate.Value = (int)value;
worldstate.Hidden = hidden;
@@ -643,7 +643,7 @@ namespace Game.BattleGrounds
public void UpdateWorldState(uint variable, bool value, bool hidden = false)
{
UpdateWorldState worldstate = new UpdateWorldState();
UpdateWorldState worldstate = new();
worldstate.VariableID = variable;
worldstate.Value = value ? 1 : 0;
worldstate.Hidden = hidden;
@@ -699,7 +699,7 @@ namespace Game.BattleGrounds
//we must set it this way, because end time is sent in packet!
SetRemainingTime(BattlegroundConst.AutocloseBattleground);
PVPMatchComplete pvpMatchComplete = new PVPMatchComplete();
PVPMatchComplete pvpMatchComplete = new();
pvpMatchComplete.Winner = (byte)GetWinner();
pvpMatchComplete.Duration = (int)Math.Max(0, (GetElapsedTime() - (int)BattlegroundStartTimeIntervals.Delay2m) / Time.InMilliseconds);
pvpMatchComplete.LogData.HasValue = true;
@@ -905,7 +905,7 @@ namespace Game.BattleGrounds
Global.BattlegroundMgr.ScheduleQueueUpdate(0, bgQueueTypeId, GetBracketId());
}
// Let others know
BattlegroundPlayerLeft playerLeft = new BattlegroundPlayerLeft();
BattlegroundPlayerLeft playerLeft = new();
playerLeft.Guid = guid;
SendPacketToTeam(team, playerLeft, player);
}
@@ -989,7 +989,7 @@ namespace Game.BattleGrounds
ObjectGuid guid = player.GetGUID();
Team team = player.GetBGTeam();
BattlegroundPlayer bp = new BattlegroundPlayer();
BattlegroundPlayer bp = new();
bp.OfflineRemoveTime = 0;
bp.Team = team;
bp.ActiveSpec = (int)player.GetPrimarySpecialization();
@@ -999,11 +999,11 @@ namespace Game.BattleGrounds
UpdatePlayersCountByTeam(team, false); // +1 player
BattlegroundPlayerJoined playerJoined = new BattlegroundPlayerJoined();
BattlegroundPlayerJoined playerJoined = new();
playerJoined.Guid = player.GetGUID();
SendPacketToTeam(team, playerJoined, player);
PVPMatchInitialize pvpMatchInitialize = new PVPMatchInitialize();
PVPMatchInitialize pvpMatchInitialize = new();
pvpMatchInitialize.MapID = GetMapId();
switch (GetStatus())
{
@@ -1057,7 +1057,7 @@ namespace Game.BattleGrounds
player.CastSpell(player, BattlegroundConst.SpellPreparation, true); // reduces all mana cost of spells.
uint countdownMaxForBGType = IsArena() ? BattlegroundConst.ArenaCountdownMax : BattlegroundConst.BattlegroundCountdownMax;
StartTimer timer = new StartTimer();
StartTimer timer = new();
timer.Type = TimerType.Pvp;
timer.TimeRemaining = countdownMaxForBGType - (GetElapsedTime() / 1000);
timer.TotalTime = countdownMaxForBGType;
@@ -1346,7 +1346,7 @@ namespace Game.BattleGrounds
if (!map)
return false;
Quaternion rotation = new Quaternion(rotation0, rotation1, rotation2, rotation3);
Quaternion rotation = new(rotation0, rotation1, rotation2, rotation3);
// Temporally add safety check for bad spawns and send log (object rotations need to be rechecked in sniff)
if (rotation0 == 0 && rotation1 == 0 && rotation2 == 0 && rotation3 == 0)
{
@@ -1485,7 +1485,7 @@ namespace Game.BattleGrounds
return null;
}
Position pos = new Position(x, y, z, o);
Position pos = new(x, y, z, o);
Creature creature = Creature.CreateCreature(entry, map, pos);
if (!creature)
@@ -1581,8 +1581,8 @@ namespace Game.BattleGrounds
if (entry == 0)
return;
CypherStringChatBuilder builder = new CypherStringChatBuilder(null, msgType, entry, source);
LocalizedPacketDo localizer = new LocalizedPacketDo(builder);
CypherStringChatBuilder builder = new(null, msgType, entry, source);
LocalizedPacketDo localizer = new(builder);
BroadcastWorker(localizer);
}
@@ -1591,8 +1591,8 @@ namespace Game.BattleGrounds
if (entry == 0)
return;
CypherStringChatBuilder builder = new CypherStringChatBuilder(null, msgType, entry, source, args);
LocalizedPacketDo localizer = new LocalizedPacketDo(builder);
CypherStringChatBuilder builder = new(null, msgType, entry, source, args);
LocalizedPacketDo localizer = new(builder);
BroadcastWorker(localizer);
}
@@ -1724,7 +1724,7 @@ namespace Game.BattleGrounds
BlockMovement(player);
PVPMatchStatisticsMessage pvpMatchStatistics = new PVPMatchStatisticsMessage();
PVPMatchStatisticsMessage pvpMatchStatistics = new();
BuildPvPLogDataPacket(out pvpMatchStatistics.Data);
player.SendPacket(pvpMatchStatistics);
}
@@ -2025,11 +2025,11 @@ namespace Game.BattleGrounds
}
#region Fields
protected Dictionary<ObjectGuid, BattlegroundScore> PlayerScores = new Dictionary<ObjectGuid, BattlegroundScore>(); // Player scores
protected Dictionary<ObjectGuid, BattlegroundScore> PlayerScores = new(); // Player scores
// Player lists, those need to be accessible by inherited classes
Dictionary<ObjectGuid, BattlegroundPlayer> m_Players = new Dictionary<ObjectGuid, BattlegroundPlayer>();
Dictionary<ObjectGuid, BattlegroundPlayer> m_Players = new();
// Spirit Guide guid + Player list GUIDS
MultiMap<ObjectGuid, ObjectGuid> m_ReviveQueue = new MultiMap<ObjectGuid, ObjectGuid>();
MultiMap<ObjectGuid, ObjectGuid> m_ReviveQueue = new();
// these are important variables used for starting messages
BattlegroundEventFlags m_Events;
@@ -2071,8 +2071,8 @@ namespace Game.BattleGrounds
uint m_LastPlayerPositionBroadcast;
// Player lists
List<ObjectGuid> m_ResurrectQueue = new List<ObjectGuid>(); // Player GUID
List<ObjectGuid> m_OfflineQueue = new List<ObjectGuid>(); // Player GUID
List<ObjectGuid> m_ResurrectQueue = new(); // Player GUID
List<ObjectGuid> m_OfflineQueue = new(); // Player GUID
// Invited counters are useful for player invitation to BG - do not allow, if BG is started to one faction to have 2 more players than another faction
// Invited counters will be changed only when removing already invited player from queue, removing player from Battleground and inviting player to BG
@@ -2099,7 +2099,7 @@ namespace Game.BattleGrounds
BattlegroundTemplate _battlegroundTemplate;
PvpDifficultyRecord _pvpDifficultyEntry;
List<BattlegroundPlayerPosition> _playerPositions = new List<BattlegroundPlayerPosition>();
List<BattlegroundPlayerPosition> _playerPositions = new();
#endregion
}
@@ -85,7 +85,7 @@ namespace Game.BattleGrounds
// update scheduled queues
if (!m_QueueUpdateScheduler.Empty())
{
List<ScheduledQueueUpdate> scheduled = new List<ScheduledQueueUpdate>();
List<ScheduledQueueUpdate> scheduled = new();
Extensions.Swap(ref scheduled, ref m_QueueUpdateScheduler);
for (byte i = 0; i < scheduled.Count; i++)
@@ -379,7 +379,7 @@ namespace Game.BattleGrounds
continue;
}
BattlegroundTemplate bgTemplate = new BattlegroundTemplate();
BattlegroundTemplate bgTemplate = new();
bgTemplate.Id = bgTypeId;
float dist = result.Read<float>(3);
bgTemplate.MaxStartDistSq = dist * dist;
@@ -439,7 +439,7 @@ namespace Game.BattleGrounds
if (bgTemplate == null)
return;
BattlefieldList battlefieldList = new BattlefieldList();
BattlefieldList battlefieldList = new();
battlefieldList.BattlemasterGuid = guid;
battlefieldList.BattlemasterListID = (int)bgTypeId;
battlefieldList.MinLevel = bgTemplate.GetMinLevel();
@@ -471,7 +471,7 @@ namespace Game.BattleGrounds
if (time == 0xFFFFFFFF)
time = 0;
AreaSpiritHealerTime areaSpiritHealerTime = new AreaSpiritHealerTime();
AreaSpiritHealerTime areaSpiritHealerTime = new();
areaSpiritHealerTime.HealerGuid = guid;
areaSpiritHealerTime.TimeLeft = time;
@@ -556,7 +556,7 @@ namespace Game.BattleGrounds
public void ScheduleQueueUpdate(uint arenaMatchmakerRating, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundBracketId bracket_id)
{
//we will use only 1 number created of bgTypeId and bracket_id
ScheduledQueueUpdate scheduleId = new ScheduledQueueUpdate(arenaMatchmakerRating, bgQueueTypeId, bracket_id);
ScheduledQueueUpdate scheduleId = new(arenaMatchmakerRating, bgQueueTypeId, bracket_id);
if (!m_QueueUpdateScheduler.Contains(scheduleId))
m_QueueUpdateScheduler.Add(scheduleId);
}
@@ -700,7 +700,7 @@ namespace Game.BattleGrounds
BattlegroundTemplate bgTemplate = GetBattlegroundTemplateByTypeId(bgTypeId);
if (bgTemplate != null)
{
Dictionary<BattlegroundTypeId, float> selectionWeights = new Dictionary<BattlegroundTypeId, float>();
Dictionary<BattlegroundTypeId, float> selectionWeights = new();
foreach (var mapId in bgTemplate.BattlemasterEntry.MapId)
{
@@ -780,12 +780,12 @@ namespace Game.BattleGrounds
return _battlegroundMapTemplates.LookupByKey(mapId);
}
Dictionary<BattlegroundTypeId, BattlegroundData> bgDataStore = new Dictionary<BattlegroundTypeId, BattlegroundData>();
Dictionary<BattlegroundQueueTypeId, BattlegroundQueue> m_BattlegroundQueues = new Dictionary<BattlegroundQueueTypeId, BattlegroundQueue>();
MultiMap<BattlegroundQueueTypeId, Battleground> m_BGFreeSlotQueue = new MultiMap<BattlegroundQueueTypeId, Battleground>();
Dictionary<uint, BattlegroundTypeId> mBattleMastersMap = new Dictionary<uint, BattlegroundTypeId>();
Dictionary<BattlegroundTypeId, BattlegroundTemplate> _battlegroundTemplates = new Dictionary<BattlegroundTypeId, BattlegroundTemplate>();
Dictionary<uint, BattlegroundTemplate> _battlegroundMapTemplates = new Dictionary<uint, BattlegroundTemplate>();
Dictionary<BattlegroundTypeId, BattlegroundData> bgDataStore = new();
Dictionary<BattlegroundQueueTypeId, BattlegroundQueue> m_BattlegroundQueues = new();
MultiMap<BattlegroundQueueTypeId, Battleground> m_BGFreeSlotQueue = new();
Dictionary<uint, BattlegroundTypeId> mBattleMastersMap = new();
Dictionary<BattlegroundTypeId, BattlegroundTemplate> _battlegroundTemplates = new();
Dictionary<uint, BattlegroundTemplate> _battlegroundMapTemplates = new();
struct ScheduledQueueUpdate
{
@@ -820,7 +820,7 @@ namespace Game.BattleGrounds
return ArenaMatchmakerRating.GetHashCode() ^ QueueId.GetHashCode() ^ BracketId.GetHashCode();
}
}
List<ScheduledQueueUpdate> m_QueueUpdateScheduler = new List<ScheduledQueueUpdate>();
List<ScheduledQueueUpdate> m_QueueUpdateScheduler = new();
uint m_NextRatedArenaUpdate;
uint m_UpdateTimer;
bool m_ArenaTesting;
@@ -835,7 +835,7 @@ namespace Game.BattleGrounds
m_ClientBattlegroundIds[i] = new List<uint>();
}
public Dictionary<uint, Battleground> m_Battlegrounds = new Dictionary<uint, Battleground>();
public Dictionary<uint, Battleground> m_Battlegrounds = new();
public List<uint>[] m_ClientBattlegroundIds = new List<uint>[(int)BattlegroundBracketId.Max];
public Battleground Template;
}
@@ -62,7 +62,7 @@ namespace Game.BattleGrounds
BattlegroundBracketId bracketId = bracketEntry.GetBracketId();
// create new ginfo
GroupQueueInfo ginfo = new GroupQueueInfo();
GroupQueueInfo ginfo = new();
ginfo.BgTypeId = BgTypeId;
ginfo.ArenaType = ArenaType;
ginfo.ArenaTeamId = arenateamid;
@@ -105,7 +105,7 @@ namespace Game.BattleGrounds
if (!member)
continue; // this should never happen
PlayerQueueInfo pl_info = new PlayerQueueInfo();
PlayerQueueInfo pl_info = new();
pl_info.LastOnlineTime = lastOnlineTime;
pl_info.GroupInfo = ginfo;
@@ -116,7 +116,7 @@ namespace Game.BattleGrounds
}
else
{
PlayerQueueInfo pl_info = new PlayerQueueInfo();
PlayerQueueInfo pl_info = new();
pl_info.LastOnlineTime = lastOnlineTime;
pl_info.GroupInfo = ginfo;
@@ -409,10 +409,10 @@ namespace Game.BattleGrounds
player.SetInviteForBattlegroundQueueType(bgQueueTypeId, ginfo.IsInvitedToBGInstanceGUID);
// create remind invite events
BGQueueInviteEvent inviteEvent = new BGQueueInviteEvent(player.GetGUID(), ginfo.IsInvitedToBGInstanceGUID, bgTypeId, ginfo.ArenaType, ginfo.RemoveInviteTime);
BGQueueInviteEvent inviteEvent = new(player.GetGUID(), ginfo.IsInvitedToBGInstanceGUID, bgTypeId, ginfo.ArenaType, ginfo.RemoveInviteTime);
m_events.AddEvent(inviteEvent, m_events.CalculateTime(BattlegroundConst.InvitationRemindTime));
// create automatic remove events
BGQueueRemoveEvent removeEvent = new BGQueueRemoveEvent(player.GetGUID(), ginfo.IsInvitedToBGInstanceGUID, bgQueueTypeId, ginfo.RemoveInviteTime);
BGQueueRemoveEvent removeEvent = new(player.GetGUID(), ginfo.IsInvitedToBGInstanceGUID, bgQueueTypeId, ginfo.RemoveInviteTime);
m_events.AddEvent(removeEvent, m_events.CalculateTime(BattlegroundConst.InviteAcceptWaitTime));
uint queueSlot = player.GetBattlegroundQueueIndex(bgQueueTypeId);
@@ -968,7 +968,7 @@ namespace Game.BattleGrounds
BattlegroundQueueTypeId m_queueId;
Dictionary<ObjectGuid, PlayerQueueInfo> m_QueuedPlayers = new Dictionary<ObjectGuid, PlayerQueueInfo>();
Dictionary<ObjectGuid, PlayerQueueInfo> m_QueuedPlayers = new();
/// <summary>
/// This two dimensional array is used to store All queued groups
@@ -986,7 +986,7 @@ namespace Game.BattleGrounds
uint[][] m_SumOfWaitTimes = new uint[SharedConst.BGTeamsCount][];
// Event handler
EventSystem m_events = new EventSystem();
EventSystem m_events = new();
SelectionPool[] m_SelectionPools = new SelectionPool[SharedConst.BGTeamsCount];
// class to select and invite groups to bg
@@ -1042,7 +1042,7 @@ namespace Game.BattleGrounds
}
public uint GetPlayerCount() { return PlayerCount; }
public List<GroupQueueInfo> SelectedGroups = new List<GroupQueueInfo>();
public List<GroupQueueInfo> SelectedGroups = new();
uint PlayerCount;
}
@@ -1142,7 +1142,7 @@ namespace Game.BattleGrounds
/// </summary>
public class GroupQueueInfo
{
public Dictionary<ObjectGuid, PlayerQueueInfo> Players = new Dictionary<ObjectGuid, PlayerQueueInfo>(); // player queue info map
public Dictionary<ObjectGuid, PlayerQueueInfo> Players = new(); // player queue info map
public Team Team; // Player team (ALLIANCE/HORDE)
public BattlegroundTypeId BgTypeId; // Battleground type id
public bool IsRated; // rated
@@ -636,7 +636,7 @@ namespace Game.BattleGrounds.Zones
int teamIndex = GetTeamIndexByTeamId(player.GetTeam());
// Is there any occupied node for this team?
List<byte> nodes = new List<byte>();
List<byte> nodes = new();
for (byte i = 0; i < ABBattlegroundNodes.DynamicNodesCount; ++i)
if (m_Nodes[i] == ABNodeStatus.Occupied + teamIndex)
nodes.Add(i);
@@ -298,7 +298,7 @@ namespace Game.BattleGrounds.Zones
Player p = Global.ObjAccessor.FindPlayer(pair.Key);
if (p)
{
UpdateData data = new UpdateData(p.GetMapId());
UpdateData data = new(p.GetMapId());
GetBGObject(i).BuildValuesUpdateBlockForPlayer(data, p);
UpdateObject pkt;
@@ -1029,7 +1029,7 @@ namespace Game.BattleGrounds.Zones
{
if (!BgObjects[SAObjectTypes.BoatOne].IsEmpty() || !BgObjects[SAObjectTypes.BoatTwo].IsEmpty())
{
UpdateData transData = new UpdateData(player.GetMapId());
UpdateData transData = new(player.GetMapId());
if (!BgObjects[SAObjectTypes.BoatOne].IsEmpty())
GetBGObject(SAObjectTypes.BoatOne).BuildCreateUpdateBlockForPlayer(transData, player);
@@ -1046,7 +1046,7 @@ namespace Game.BattleGrounds.Zones
{
if (!BgObjects[SAObjectTypes.BoatOne].IsEmpty() || !BgObjects[SAObjectTypes.BoatTwo].IsEmpty())
{
UpdateData transData = new UpdateData(player.GetMapId());
UpdateData transData = new(player.GetMapId());
if (!BgObjects[SAObjectTypes.BoatOne].IsEmpty())
GetBGObject(SAObjectTypes.BoatOne).BuildOutOfRangeUpdateBlock(transData);
if (!BgObjects[SAObjectTypes.BoatTwo].IsEmpty())
@@ -1143,7 +1143,7 @@ namespace Game.BattleGrounds.Zones
bool SignaledRoundTwoHalfMin;
// for know if second round has been init
bool InitSecondRound;
Dictionary<uint/*id*/, uint/*timer*/> DemoliserRespawnList = new Dictionary<uint, uint>();
Dictionary<uint/*id*/, uint/*timer*/> DemoliserRespawnList = new();
// Achievement: Defense of the Ancients
bool _gateDestroyed;