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
+1 -1
View File
@@ -57,7 +57,7 @@ namespace Game.Chat
return false;
}
ArenaTeam arena = new ArenaTeam();
ArenaTeam arena = new();
if (!arena.Create(target.GetGUID(), type, name, 4293102085, 101, 4293253939, 4, 4284049911))
{
@@ -415,7 +415,7 @@ namespace Game.Chat
string factionName = factionEntry != null ? factionEntry.Name[loc] : "#Not found#";
ReputationRank rank = target.GetReputationMgr().GetRank(factionEntry);
string rankName = handler.GetCypherString(ReputationMgr.ReputationRankStrIndex[(int)rank]);
StringBuilder ss = new StringBuilder();
StringBuilder ss = new();
if (handler.GetSession() != null)
ss.AppendFormat("{0} - |cffffffff|Hfaction:{0}|h[{1} {2}]|h|r", faction.Id, factionName, loc);
else
@@ -495,7 +495,7 @@ namespace Game.Chat
if (args.Empty())
return false;
List<DeletedInfo> foundList = new List<DeletedInfo>();
List<DeletedInfo> foundList = new();
if (!GetDeletedCharacterInfoList(foundList, args.NextString()))
return false;
@@ -518,7 +518,7 @@ namespace Game.Chat
[Command("list", RBACPermissions.CommandCharacterDeletedList, true)]
static bool HandleCharacterDeletedListCommand(StringArguments args, CommandHandler handler)
{
List<DeletedInfo> foundList = new List<DeletedInfo>();
List<DeletedInfo> foundList = new();
if (!GetDeletedCharacterInfoList(foundList, args.NextString()))
return false;
@@ -545,7 +545,7 @@ namespace Game.Chat
string newCharName = args.NextString();
uint newAccount = args.NextUInt32();
List<DeletedInfo> foundList = new List<DeletedInfo>();
List<DeletedInfo> foundList = new();
if (!GetDeletedCharacterInfoList(foundList, searchString))
return false;
+7 -7
View File
@@ -542,7 +542,7 @@ namespace Game.Chat
target.DestroyForNearbyPlayers(); // Force new SMSG_UPDATE_OBJECT:CreateObject
else
{
MoveUpdate moveUpdate = new MoveUpdate();
MoveUpdate moveUpdate = new();
moveUpdate.Status = target.m_movementInfo;
target.SendMessageToSet(moveUpdate, true);
}
@@ -775,7 +775,7 @@ namespace Game.Chat
return false;
Map map = handler.GetSession().GetPlayer().GetMap();
Position pos = new Position(x, y, z, o);
Position pos = new(x, y, z, o);
Creature creature = Creature.CreateCreature(entry, map, pos, id);
if (!creature)
@@ -1075,7 +1075,7 @@ namespace Game.Chat
string name = "test";
byte code = args.NextByte();
ChannelNotify packet = new ChannelNotify();
ChannelNotify packet = new();
packet.Type = (ChatNotify)code;
packet.Channel = name;
handler.GetSession().SendPacket(packet);
@@ -1090,7 +1090,7 @@ namespace Game.Chat
string msg = "testtest";
byte type = args.NextByte();
ChatPkt data = new ChatPkt();
ChatPkt data = new();
data.Initialize((ChatMsg)type, Language.Universal, handler.GetSession().GetPlayer(), handler.GetSession().GetPlayer(), msg, 0, "chan");
handler.GetSession().SendPacket(data);
return true;
@@ -1111,7 +1111,7 @@ namespace Game.Chat
static bool HandleDebugSendLargePacketCommand(StringArguments args, CommandHandler handler)
{
const string stuffingString = "This is a dummy string to push the packet's size beyond 128000 bytes. ";
StringBuilder ss = new StringBuilder();
StringBuilder ss = new();
while (ss.Length < 128000)
ss.Append(stuffingString);
handler.SendSysMessage(ss.ToString());
@@ -1171,7 +1171,7 @@ namespace Game.Chat
if (args.Empty())
return false;
PhaseShift phaseShift = new PhaseShift();
PhaseShift phaseShift = new();
if (uint.TryParse(args.NextString(), out uint terrain))
phaseShift.AddVisibleMapId(terrain, null);
@@ -1198,7 +1198,7 @@ namespace Game.Chat
int failArg1 = args.NextInt32();
int failArg2 = args.NextInt32();
CastFailed castFailed = new CastFailed();
CastFailed castFailed = new();
castFailed.CastID = ObjectGuid.Empty;
castFailed.SpellID = 133;
castFailed.Reason = (SpellCastResult)failNum;
@@ -366,7 +366,7 @@ namespace Game.Chat
Player player = handler.GetSession().GetPlayer();
List<WorldObject> creatureList = new List<WorldObject>();
List<WorldObject> creatureList = new();
if (!player.GetMap().SpawnGroupSpawn(groupId, ignoreRespawn, force, creatureList))
{
handler.SendSysMessage(CypherStrings.SpawngroupBadgroup, groupId);
@@ -407,7 +407,7 @@ namespace Game.Chat
}
else
{
StringBuilder eventFilter = new StringBuilder();
StringBuilder eventFilter = new();
eventFilter.Append(" AND (eventEntry IS NULL ");
bool initString = true;
+1 -1
View File
@@ -45,7 +45,7 @@ namespace Game.Chat
return true;
}
Guild guild = new Guild();
Guild guild = new();
if (!guild.Create(target, guildname))
{
handler.SendSysMessage(CypherStrings.GuildNotCreated);
+1 -1
View File
@@ -577,7 +577,7 @@ namespace Game.Chat.Commands
if (!args.Empty())
range = args.NextUInt32();
List<RespawnInfo> respawns = new List<RespawnInfo>();
List<RespawnInfo> respawns = new();
Locale locale = handler.GetSession().GetSessionDbcLocale();
string stringOverdue = Global.ObjectMgr.GetCypherString(CypherStrings.ListRespawnsOverdue, locale);
string stringCreature = Global.ObjectMgr.GetCypherString(CypherStrings.ListRespawnsCreatures, locale);
+5 -5
View File
@@ -267,7 +267,7 @@ namespace Game.Chat
// send faction in "id - [faction] rank reputation [visible] [at war] [own team] [unknown] [invisible] [inactive]" format
// or "id - [faction] [no reputation]" format
StringBuilder ss = new StringBuilder();
StringBuilder ss = new();
if (handler.GetSession() != null)
ss.AppendFormat("{0} - |cffffffff|Hfaction:{0}|h[{1}]|h|r", factionEntry.Id, name);
else
@@ -772,7 +772,7 @@ namespace Game.Chat
string namePart = args.NextString().ToLower();
StringBuilder reply = new StringBuilder();
StringBuilder reply = new();
uint count = 0;
bool limitReached = false;
@@ -924,7 +924,7 @@ namespace Game.Chat
return true;
}
StringBuilder ss = new StringBuilder();
StringBuilder ss = new();
ss.Append(mapInfo.Id + " - [" + name + ']');
if (mapInfo.IsContinent())
@@ -1141,7 +1141,7 @@ namespace Game.Chat
uint rank = learn && learnSpellInfo != null ? learnSpellInfo.GetRank() : spellInfo.GetRank();
// send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
StringBuilder ss = new StringBuilder();
StringBuilder ss = new();
if (handler.GetSession() != null)
ss.Append(spellInfo.Id + " - |cffffffff|Hspell:" + spellInfo.Id + "|h[" + name);
else
@@ -1215,7 +1215,7 @@ namespace Game.Chat
uint rank = learn && learnSpellInfo != null ? learnSpellInfo.GetRank() : spellInfo.GetRank();
// send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
StringBuilder ss = new StringBuilder();
StringBuilder ss = new();
if (handler.GetSession() != null)
ss.Append(id + " - |cffffffff|Hspell:" + id + "|h[" + name);
else
+6 -6
View File
@@ -62,7 +62,7 @@ namespace Game.Chat
player.GetPosition(out x, out y, out z);
// path
PathGenerator path = new PathGenerator(target);
PathGenerator path = new(target);
path.SetUseStraightPath(useStraightPath);
bool result = path.CalculatePath(x, y, z, false, useStraightLine);
@@ -125,7 +125,7 @@ namespace Game.Chat
handler.SendSysMessage("Calc [{0:D2}, {1:D2}]", tilex, tiley);
// navmesh poly . navmesh tile location
Detour.dtQueryFilter filter = new Detour.dtQueryFilter();
Detour.dtQueryFilter filter = new();
float[] nothing = new float[3];
ulong polyRef = 0;
if (Detour.dtStatusFailed(navmeshquery.findNearestPoly(location, extents, filter, ref polyRef, ref nothing)))
@@ -138,8 +138,8 @@ namespace Game.Chat
handler.SendSysMessage("Dt [??, ??] (invalid poly, probably no tile loaded)");
else
{
Detour.dtMeshTile tile = new Detour.dtMeshTile();
Detour.dtPoly poly = new Detour.dtPoly();
Detour.dtMeshTile tile = new();
Detour.dtPoly poly = new();
if (Detour.dtStatusSucceed(navmesh.getTileAndPolyByRef(polyRef, ref tile, ref poly)))
{
if (tile != null)
@@ -231,7 +231,7 @@ namespace Game.Chat
WorldObject obj = handler.GetPlayer();
// Get Creatures
List<Unit> creatureList = new List<Unit>();
List<Unit> creatureList = new();
var go_check = new AnyUnitInObjectRangeCheck(obj, radius);
var go_search = new UnitListSearcher(obj, creatureList, go_check);
@@ -248,7 +248,7 @@ namespace Game.Chat
obj.GetPosition(out gx, out gy, out gz);
foreach (var creature in creatureList)
{
PathGenerator path = new PathGenerator(creature);
PathGenerator path = new(creature);
path.CalculatePath(gx, gy, gz);
++paths;
}
+8 -8
View File
@@ -80,7 +80,7 @@ namespace Game.Chat
if (count == 0)
count = 1;
List<uint> bonusListIDs = new List<uint>();
List<uint> bonusListIDs = new();
var bonuses = args.NextString();
// semicolon separated bonuslist ids (parse them after all arguments are extracted by strtok!)
@@ -121,7 +121,7 @@ namespace Game.Chat
uint noSpaceForCount = 0;
// check space and find places
List<ItemPosCount> dest = new List<ItemPosCount>();
List<ItemPosCount> dest = new();
InventoryResult msg = playerTarget.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, itemId, (uint)count, out noSpaceForCount);
if (msg != InventoryResult.Ok) // convert to possible store amount
count -= (int)noSpaceForCount;
@@ -175,7 +175,7 @@ namespace Game.Chat
return false;
}
List<uint> bonusListIDs = new List<uint>();
List<uint> bonusListIDs = new();
var bonuses = args.NextString();
// semicolon separated bonuslist ids (parse them after all arguments are extracted by strtok!)
@@ -203,7 +203,7 @@ namespace Game.Chat
if (template.Value.GetItemSet() == itemSetId)
{
found = true;
List<ItemPosCount> dest = new List<ItemPosCount>();
List<ItemPosCount> dest = new();
InventoryResult msg = playerTarget.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, template.Value.GetId(), 1);
if (msg == InventoryResult.Ok)
{
@@ -565,7 +565,7 @@ namespace Game.Chat
// melee damage by specific school
if (string.IsNullOrEmpty(spellStr))
{
DamageInfo dmgInfo = new DamageInfo(attacker, target, damage_, null, schoolmask, DamageEffectType.SpellDirect, WeaponAttackType.BaseAttack);
DamageInfo dmgInfo = new(attacker, target, damage_, null, schoolmask, DamageEffectType.SpellDirect, WeaponAttackType.BaseAttack);
attacker.CalcAbsorbResist(dmgInfo);
if (dmgInfo.GetDamage() == 0)
@@ -591,7 +591,7 @@ namespace Game.Chat
if (spellInfo == null)
return false;
SpellNonMeleeDamage damageInfo = new SpellNonMeleeDamage(attacker, target, spellInfo, new Networking.Packets.SpellCastVisual(spellInfo.GetSpellXSpellVisualId(attacker), 0), spellInfo.SchoolMask);
SpellNonMeleeDamage damageInfo = new(attacker, target, spellInfo, new Networking.Packets.SpellCastVisual(spellInfo.GetSpellXSpellVisualId(attacker), 0), spellInfo.SchoolMask);
damageInfo.damage = damage_;
attacker.DealDamageMods(damageInfo.target, ref damageInfo.damage, ref damageInfo.absorb);
target.DealSpellDamage(damageInfo, true);
@@ -886,7 +886,7 @@ namespace Game.Chat
}
CellCoord cellCoord = GridDefines.ComputeCellCoord(obj.GetPositionX(), obj.GetPositionY());
Cell cell = new Cell(cellCoord);
Cell cell = new(cellCoord);
uint zoneId, areaId;
obj.GetZoneAndAreaId(out zoneId, out areaId);
@@ -1957,7 +1957,7 @@ namespace Game.Chat
Cell.VisitGridObjects(player, worker, player.GetGridActivationRange());
// Now handle any that had despawned, but had respawn time logged.
List<RespawnInfo> data = new List<RespawnInfo>();
List<RespawnInfo> data = new();
player.GetMap().GetRespawnInfo(data, SpawnObjectTypeMask.All, 0);
if (!data.Empty())
{
+4 -4
View File
@@ -191,8 +191,8 @@ namespace Game.Chat
if (handler.NeedReportToTarget(target))
target.SendSysMessage(CypherStrings.YoursSpellflatidChanged, handler.GetNameLink(), spellflatid, val, mark);
SetSpellModifier packet = new SetSpellModifier(ServerOpcodes.SetFlatSpellModifier);
SpellModifierInfo spellMod = new SpellModifierInfo();
SetSpellModifier packet = new(ServerOpcodes.SetFlatSpellModifier);
SpellModifierInfo spellMod = new();
spellMod.ModIndex = op;
SpellModifierData modData;
modData.ClassIndex = spellflatid;
@@ -601,7 +601,7 @@ namespace Game.Chat
Global.CharacterCacheStorage.UpdateCharacterGender(target.GetGUID(), (byte)gender);
// Generate random customizations
List<ChrCustomizationChoice> customizations = new List<ChrCustomizationChoice>();
List<ChrCustomizationChoice> customizations = new();
var options = Global.DB2Mgr.GetCustomiztionOptions(target.GetRace(), gender);
WorldSession worldSession = target.GetSession();
@@ -620,7 +620,7 @@ namespace Game.Chat
continue;
ChrCustomizationChoiceRecord choiceEntry = choicesForOption[0];
ChrCustomizationChoice choice = new ChrCustomizationChoice();
ChrCustomizationChoice choice = new();
choice.ChrCustomizationOptionID = option.Id;
choice.ChrCustomizationChoiceID = choiceEntry.Id;
customizations.Add(choice);
+3 -3
View File
@@ -446,7 +446,7 @@ namespace Game.Chat
Player player = handler.GetSession().GetPlayer();
List<WorldObject> creatureList = new List<WorldObject>();
List<WorldObject> creatureList = new();
if (!player.GetMap().SpawnGroupSpawn(groupId, ignoreRespawn, force, creatureList))
{
handler.SendSysMessage(CypherStrings.SpawngroupBadgroup, groupId);
@@ -719,7 +719,7 @@ namespace Game.Chat
uint vendor_entry = vendor.GetEntry();
VendorItem vItem = new VendorItem();
VendorItem vItem = new();
vItem.item = itemId;
vItem.maxcount = maxcount;
vItem.incrtime = incrtime;
@@ -807,7 +807,7 @@ namespace Game.Chat
return false;
Player chr = handler.GetSession().GetPlayer();
FormationInfo group_member = new FormationInfo();
FormationInfo group_member = new();
group_member.follow_angle = (creature.GetAngle(chr) - chr.GetOrientation()) * 180 / MathFunctions.PI;
group_member.follow_dist = (float)Math.Sqrt(Math.Pow(chr.GetPositionX() - creature.GetPositionX(), 2) + Math.Pow(chr.GetPositionY() - creature.GetPositionY(), 2));
group_member.leaderGUID = leaderGUID;
+1 -1
View File
@@ -52,7 +52,7 @@ namespace Game.Chat
}
// Everything looks OK, create new pet
Pet pet = new Pet(player, PetType.Hunter);
Pet pet = new(player, PetType.Hunter);
if (!pet.CreateBaseAtCreature(creatureTarget))
{
handler.SendSysMessage("Error 1");
+1 -1
View File
@@ -101,7 +101,7 @@ namespace Game.Chat
case QuestObjectiveType.Item:
{
uint curItemCount = player.GetItemCount((uint)obj.ObjectID, true);
List<ItemPosCount> dest = new List<ItemPosCount>();
List<ItemPosCount> dest = new();
InventoryResult msg = player.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, (uint)obj.ObjectID, (uint)(obj.Amount - curItemCount));
if (msg == InventoryResult.Ok)
{
+1 -1
View File
@@ -292,7 +292,7 @@ namespace Game.Chat.Commands
if (checkParams && handler.HasLowerSecurityAccount(null, accountId, true))
return null;
RBACCommandData data = new RBACCommandData();
RBACCommandData data = new();
if (rdata == null)
{
+9 -9
View File
@@ -54,10 +54,10 @@ namespace Game.Chat.Commands
return false;
// from console show not existed sender
MailSender sender = new MailSender(MailMessageType.Normal, handler.GetSession() ? handler.GetSession().GetPlayer().GetGUID().GetCounter() : 0, MailStationery.Gm);
MailSender sender = new(MailMessageType.Normal, handler.GetSession() ? handler.GetSession().GetPlayer().GetGUID().GetCounter() : 0, MailStationery.Gm);
// @todo Fix poor design
SQLTransaction trans = new SQLTransaction();
SQLTransaction trans = new();
new MailDraft(subject, text)
.SendMailTo(trans, new MailReceiver(target, targetGuid.GetCounter()), sender);
@@ -95,10 +95,10 @@ namespace Game.Chat.Commands
return false;
// extract items
List<KeyValuePair<uint, uint>> items = new List<KeyValuePair<uint, uint>>();
List<KeyValuePair<uint, uint>> items = new();
// get all tail string
StringArguments tail = new StringArguments(args.NextString(""));
StringArguments tail = new(args.NextString(""));
// get from tail next item str
StringArguments itemStr;
@@ -143,12 +143,12 @@ namespace Game.Chat.Commands
}
// from console show not existed sender
MailSender sender = new MailSender(MailMessageType.Normal, handler.GetSession() ? handler.GetSession().GetPlayer().GetGUID().GetCounter() : 0, MailStationery.Gm);
MailSender sender = new(MailMessageType.Normal, handler.GetSession() ? handler.GetSession().GetPlayer().GetGUID().GetCounter() : 0, MailStationery.Gm);
// fill mail
MailDraft draft = new MailDraft(subject, text);
MailDraft draft = new(subject, text);
SQLTransaction trans = new SQLTransaction();
SQLTransaction trans = new();
foreach (var pair in items)
{
@@ -202,9 +202,9 @@ namespace Game.Chat.Commands
return false;
// from console show not existed sender
MailSender sender = new MailSender(MailMessageType.Normal, handler.GetSession() ? handler.GetSession().GetPlayer().GetGUID().GetCounter() : 0, MailStationery.Gm);
MailSender sender = new(MailMessageType.Normal, handler.GetSession() ? handler.GetSession().GetPlayer().GetGUID().GetCounter() : 0, MailStationery.Gm);
SQLTransaction trans = new SQLTransaction();
SQLTransaction trans = new();
new MailDraft(subject, text)
.AddMoney((uint)money)
+2 -2
View File
@@ -90,7 +90,7 @@ namespace Game.Chat
return false;
}
GameTele tele = new GameTele();
GameTele tele = new();
tele.posX = player.GetPositionX();
tele.posY = player.GetPositionY();
tele.posZ = player.GetPositionZ();
@@ -232,7 +232,7 @@ namespace Game.Chat
if (!result.IsEmpty())
{
WorldLocation loc = new WorldLocation(result.Read<ushort>(0), result.Read<float>(2), result.Read<float>(3), result.Read<float>(4), 0.0f);
WorldLocation loc = new(result.Read<ushort>(0), result.Read<float>(2), result.Read<float>(3), result.Read<float>(4), 0.0f);
uint zoneId = result.Read<ushort>(1);
Player.SavePositionInDB(loc, zoneId, targetGuid, null);
+3 -3
View File
@@ -760,7 +760,7 @@ namespace Game.Chat.Commands
Player chr = handler.GetSession().GetPlayer();
Map map = chr.GetMap();
Position pos = new Position(x, y, z, chr.GetOrientation());
Position pos = new(x, y, z, chr.GetOrientation());
Creature creature = Creature.CreateCreature(id, map, pos);
if (!creature)
@@ -826,7 +826,7 @@ namespace Game.Chat.Commands
Player chr = handler.GetSession().GetPlayer();
Map map = chr.GetMap();
Position pos = new Position(x, y, z, chr.GetOrientation());
Position pos = new(x, y, z, chr.GetOrientation());
Creature creature = Creature.CreateCreature(1, map, pos);
if (!creature)
@@ -881,7 +881,7 @@ namespace Game.Chat.Commands
Player chr = handler.GetSession().GetPlayer();
Map map = chr.GetMap();
Position pos = new Position(x, y, z, o);
Position pos = new(x, y, z, o);
Creature creature = Creature.CreateCreature(1, map, pos);
if (!creature)