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
@@ -79,7 +79,7 @@ namespace Game.Maps
Log.outDebug(LogFilter.Maps, "InstanceSaveManager.AddInstanceSave: mapid = {0}, instanceid = {1}", mapId, instanceId);
InstanceSave save = new InstanceSave(mapId, instanceId, difficulty, entranceId, resetTime, canReset);
InstanceSave save = new(mapId, instanceId, difficulty, entranceId, resetTime, canReset);
if (!load)
save.SaveToDB();
@@ -94,7 +94,7 @@ namespace Game.Maps
public void DeleteInstanceFromDB(uint instanceid)
{
SQLTransaction trans = new SQLTransaction();
SQLTransaction trans = new();
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_INSTANCE_BY_INSTANCE);
stmt.AddValue(0, instanceid);
@@ -187,10 +187,10 @@ namespace Game.Maps
// get the current reset times for normal instances (these may need to be updated)
// these are only kept in memory for InstanceSaves that are loaded later
// resettime = 0 in the DB for raid/heroic instances so those are skipped
Dictionary<uint, Tuple<uint, long>> instResetTime = new Dictionary<uint, Tuple<uint, long>>();
Dictionary<uint, Tuple<uint, long>> instResetTime = new();
// index instance ids by map/difficulty pairs for fast reset warning send
MultiMap<uint, uint> mapDiffResetInstances = new MultiMap<uint, uint>();
MultiMap<uint, uint> mapDiffResetInstances = new();
SQLResult result = DB.Characters.Query("SELECT id, map, difficulty, resettime FROM instance ORDER BY id ASC");
if (!result.IsEmpty())
@@ -420,7 +420,7 @@ namespace Game.Maps
bool shouldDelete = true;
var pList = pair.Value.m_playerList;
List<Player> temp = new List<Player>(); // list of expired binds that should be unbound
List<Player> temp = new(); // list of expired binds that should be unbound
foreach (var player in pList)
{
InstanceBind bind = player.GetBoundInstance(pair.Value.GetMapId(), pair.Value.GetDifficultyID());
@@ -499,7 +499,7 @@ namespace Game.Maps
return;
// delete them from the DB, even if not loaded
SQLTransaction trans = new SQLTransaction();
SQLTransaction trans = new();
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_EXPIRED_CHAR_INSTANCE_BY_MAP_DIFF);
stmt.AddValue(0, mapid);
@@ -634,10 +634,10 @@ namespace Game.Maps
// used during global instance resets
public bool lock_instLists;
// fast lookup by instance id
Dictionary<uint, InstanceSave> m_instanceSaveById = new Dictionary<uint, InstanceSave>();
Dictionary<uint, InstanceSave> m_instanceSaveById = new();
// fast lookup for reset times (always use existed functions for access/set)
Dictionary<ulong, long> m_resetTimeByMapDifficulty = new Dictionary<ulong, long>();
MultiMap<long, InstResetEvent> m_resetTimeQueue = new MultiMap<long, InstResetEvent>();
Dictionary<ulong, long> m_resetTimeByMapDifficulty = new();
MultiMap<long, InstResetEvent> m_resetTimeQueue = new();
}
public class InstanceSave
@@ -766,8 +766,8 @@ namespace Game.Maps
m_toDelete = toDelete;
}
public List<Player> m_playerList = new List<Player>();
public List<Group> m_groupList = new List<Group>();
public List<Player> m_playerList = new();
public List<Group> m_groupList = new();
long m_resetTime;
uint m_instanceid;
uint m_mapid;
+18 -18
View File
@@ -221,7 +221,7 @@ namespace Game.Maps
if (_instanceSpawnGroups.Empty())
return;
Dictionary<uint, states> newStates = new Dictionary<uint, states>();
Dictionary<uint, states> newStates = new();
foreach (var info in _instanceSpawnGroups)
{
if (!newStates.ContainsKey(info.SpawnGroupId))
@@ -473,7 +473,7 @@ namespace Game.Maps
{
OUT_SAVE_INST_DATA();
StringBuilder saveStream = new StringBuilder();
StringBuilder saveStream = new();
WriteSaveDataHeaders(saveStream);
WriteSaveDataBossStates(saveStream);
@@ -682,7 +682,7 @@ namespace Game.Maps
if (unit == null)
return;
InstanceEncounterEngageUnit encounterEngageMessage = new InstanceEncounterEngageUnit();
InstanceEncounterEngageUnit encounterEngageMessage = new();
encounterEngageMessage.Unit = unit.GetGUID();
encounterEngageMessage.TargetFramePriority = priority;
instance.SendToPlayers(encounterEngageMessage);
@@ -691,7 +691,7 @@ namespace Game.Maps
if (!unit)
return;
InstanceEncounterDisengageUnit encounterDisengageMessage = new InstanceEncounterDisengageUnit();
InstanceEncounterDisengageUnit encounterDisengageMessage = new();
encounterDisengageMessage.Unit = unit.GetGUID();
instance.SendToPlayers(encounterDisengageMessage);
break;
@@ -699,7 +699,7 @@ namespace Game.Maps
if (!unit)
return;
InstanceEncounterChangePriority encounterChangePriorityMessage = new InstanceEncounterChangePriority();
InstanceEncounterChangePriority encounterChangePriorityMessage = new();
encounterChangePriorityMessage.Unit = unit.GetGUID();
encounterChangePriorityMessage.TargetFramePriority = priority;
instance.SendToPlayers(encounterChangePriorityMessage);
@@ -711,7 +711,7 @@ namespace Game.Maps
void SendEncounterStart(uint inCombatResCount = 0, uint maxInCombatResCount = 0, uint inCombatResChargeRecovery = 0, uint nextCombatResChargeTime = 0)
{
InstanceEncounterStart encounterStartMessage = new InstanceEncounterStart();
InstanceEncounterStart encounterStartMessage = new();
encounterStartMessage.InCombatResCount = inCombatResCount;
encounterStartMessage.MaxInCombatResCount = maxInCombatResCount;
encounterStartMessage.CombatResChargeRecovery = inCombatResChargeRecovery;
@@ -727,7 +727,7 @@ namespace Game.Maps
public void SendBossKillCredit(uint encounterId)
{
BossKill bossKillCreditMessage = new BossKill();
BossKill bossKillCreditMessage = new();
bossKillCreditMessage.DungeonEncounterID = encounterId;
instance.SendToPlayers(bossKillCreditMessage);
@@ -905,16 +905,16 @@ namespace Game.Maps
public virtual void WriteSaveDataMore(StringBuilder data) { }
public InstanceMap instance;
List<char> headers = new List<char>();
Dictionary<uint, BossInfo> bosses = new Dictionary<uint, BossInfo>();
MultiMap<uint, DoorInfo> doors = new MultiMap<uint, DoorInfo>();
Dictionary<uint, MinionInfo> minions = new Dictionary<uint, MinionInfo>();
Dictionary<uint, uint> _creatureInfo = new Dictionary<uint, uint>();
Dictionary<uint, uint> _gameObjectInfo = new Dictionary<uint, uint>();
Dictionary<uint, ObjectGuid> _objectGuids = new Dictionary<uint, ObjectGuid>();
List<char> headers = new();
Dictionary<uint, BossInfo> bosses = new();
MultiMap<uint, DoorInfo> doors = new();
Dictionary<uint, MinionInfo> minions = new();
Dictionary<uint, uint> _creatureInfo = new();
Dictionary<uint, uint> _gameObjectInfo = new();
Dictionary<uint, ObjectGuid> _objectGuids = new();
uint completedEncounters;
List<InstanceSpawnGroupInfo> _instanceSpawnGroups = new List<InstanceSpawnGroupInfo>();
List<uint> _activatedAreaTriggers = new List<uint>();
List<InstanceSpawnGroupInfo> _instanceSpawnGroups = new();
List<uint> _activatedAreaTriggers = new();
uint _entranceId;
uint _temporaryEntranceId;
uint _combatResurrectionTimer;
@@ -984,8 +984,8 @@ namespace Game.Maps
public EncounterState state;
public List<ObjectGuid>[] door = new List<ObjectGuid>[(int)DoorType.Max];
public List<ObjectGuid> minion = new List<ObjectGuid>();
public List<AreaBoundary> boundary = new List<AreaBoundary>();
public List<ObjectGuid> minion = new();
public List<AreaBoundary> boundary = new();
}
class DoorInfo
{
+4 -4
View File
@@ -194,7 +194,7 @@ namespace Game.Maps
Log.outDebug(LogFilter.Maps, "MapInstanced.CreateInstance: {0} map instance {1} for {2} created with difficulty {3}", save != null ? "" : "new ", InstanceId, GetId(), difficulty);
InstanceMap map = new InstanceMap(GetId(), GetGridExpiry(), InstanceId, difficulty, this);
InstanceMap map = new(GetId(), GetGridExpiry(), InstanceId, difficulty, this);
Cypher.Assert(map.IsDungeon());
map.LoadRespawnTimes();
@@ -220,7 +220,7 @@ namespace Game.Maps
{
Log.outDebug(LogFilter.Maps, "MapInstanced.CreateBattleground: map bg {0} for {1} created.", InstanceId, GetId());
BattlegroundMap map = new BattlegroundMap(GetId(), (uint)GetGridExpiry(), InstanceId, this, Difficulty.None);
BattlegroundMap map = new(GetId(), (uint)GetGridExpiry(), InstanceId, this, Difficulty.None);
Cypher.Assert(map.IsBattlegroundOrArena());
map.SetBG(bg);
bg.SetBgMap(map);
@@ -234,7 +234,7 @@ namespace Game.Maps
{
lock (_mapLock)
{
GarrisonMap map = new GarrisonMap(GetId(), GetGridExpiry(), instanceId, this, owner.GetGUID());
GarrisonMap map = new(GetId(), GetGridExpiry(), instanceId, this, owner.GetGUID());
Cypher.Assert(map.IsGarrison());
m_InstancedMaps[instanceId] = map;
@@ -279,7 +279,7 @@ namespace Game.Maps
public Dictionary<uint, Map> GetInstancedMaps() { return m_InstancedMaps; }
Dictionary<uint, Map> m_InstancedMaps = new Dictionary<uint, Map>();
Dictionary<uint, Map> m_InstancedMaps = new();
}
public class InstanceTemplate