diff --git a/Source/Framework/Realm/RealmManager.cs b/Source/Framework/Realm/RealmManager.cs index 059b9e2c0..02ee5c9ef 100644 --- a/Source/Framework/Realm/RealmManager.cs +++ b/Source/Framework/Realm/RealmManager.cs @@ -55,16 +55,16 @@ public class RealmManager : Singleton build.MinorVersion = result.Read(1); build.BugfixVersion = result.Read(2); string hotfixVersion = result.Read(3); - if (hotfixVersion.Length < build.HotfixVersion.Length) + if (!hotfixVersion.IsEmpty() && hotfixVersion.Length < build.HotfixVersion.Length) build.HotfixVersion = hotfixVersion.ToCharArray(); build.Build = result.Read(4); string win64AuthSeedHexStr = result.Read(5); - if (win64AuthSeedHexStr.Length == build.Win64AuthSeed.Length * 2) + if (!win64AuthSeedHexStr.IsEmpty() && win64AuthSeedHexStr.Length == build.Win64AuthSeed.Length * 2) build.Win64AuthSeed = win64AuthSeedHexStr.ToByteArray(); string mac64AuthSeedHexStr = result.Read(6); - if (mac64AuthSeedHexStr.Length == build.Mac64AuthSeed.Length * 2) + if (!mac64AuthSeedHexStr.IsEmpty() && mac64AuthSeedHexStr.Length == build.Mac64AuthSeed.Length * 2) build.Mac64AuthSeed = mac64AuthSeedHexStr.ToByteArray(); _builds.Add(build); diff --git a/Source/Game/AI/ScriptedAI/ScriptedEscortAI.cs b/Source/Game/AI/ScriptedAI/ScriptedEscortAI.cs index 083bb18e3..f1c939a05 100644 --- a/Source/Game/AI/ScriptedAI/ScriptedEscortAI.cs +++ b/Source/Game/AI/ScriptedAI/ScriptedEscortAI.cs @@ -312,7 +312,7 @@ namespace Game.AI UpdateEscortAI(diff); } - void UpdateEscortAI(uint diff) + public virtual void UpdateEscortAI(uint diff) { if (!UpdateVictim()) return; @@ -505,7 +505,7 @@ namespace Game.AI return false; int size = WaypointList.Count; - Escort_Waypoint waypoint = new Escort_Waypoint(0, 0, 0, 0, 0); + Escort_Waypoint waypoint; do { waypoint = WaypointList.First(); diff --git a/Source/Game/AI/SmartScripts/SmartAI.cs b/Source/Game/AI/SmartScripts/SmartAI.cs index c21732b67..15db5d788 100644 --- a/Source/Game/AI/SmartScripts/SmartAI.cs +++ b/Source/Game/AI/SmartScripts/SmartAI.cs @@ -448,17 +448,6 @@ namespace Game.AI MovepointReached(Data); } - void RemoveAuras() - { - //fixme: duplicated logic in CreatureAI._EnterEvadeMode (could use RemoveAllAurasExceptType) - foreach (var pair in me.GetAppliedAuras()) - { - Aura aura = pair.Value.GetBase(); - if (!aura.IsPassive() && !aura.HasEffectType(AuraType.ControlVehicle) && !aura.HasEffectType(AuraType.CloneCaster) && aura.GetCasterGUID() != me.GetGUID()) - me.RemoveAura(pair); - } - } - public override void EnterEvadeMode(EvadeReason why = EvadeReason.Other) { if (mEvadeDisabled) diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 9c5bcdc9f..54735e625 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -1583,7 +1583,7 @@ namespace Game.AI if (!IsSmart()) break; - WorldObject target = null; + WorldObject target; /*if (e.GetTargetType() == SmartTargets.CreatureRange || e.GetTargetType() == SmartTargets.CreatureGuid || e.GetTargetType() == SmartTargets.CreatureDistance || e.GetTargetType() == SmartTargets.GameobjectRange || diff --git a/Source/Game/Accounts/AccountManager.cs b/Source/Game/Accounts/AccountManager.cs index 76caa883e..9b763d054 100644 --- a/Source/Game/Accounts/AccountManager.cs +++ b/Source/Game/Accounts/AccountManager.cs @@ -189,9 +189,7 @@ namespace Game public AccountOpResult ChangeEmail(uint accountId, string newEmail) { - string username; - - if (!GetName(accountId, out username)) + if (!GetName(accountId, out _)) return AccountOpResult.NameNotExist; // account doesn't exist if (newEmail.Length > MaxEmailLength) @@ -207,9 +205,7 @@ namespace Game public AccountOpResult ChangeRegEmail(uint accountId, string newEmail) { - string username; - - if (!GetName(accountId, out username)) + if (!GetName(accountId, out _)) return AccountOpResult.NameNotExist; // account doesn't exist if (newEmail.Length > MaxEmailLength) diff --git a/Source/Game/Achievements/AchievementManager.cs b/Source/Game/Achievements/AchievementManager.cs index 5d562a40d..f66993ac1 100644 --- a/Source/Game/Achievements/AchievementManager.cs +++ b/Source/Game/Achievements/AchievementManager.cs @@ -425,7 +425,7 @@ namespace Game.Achievements SendPacket(achievementData); } - public void SendAchievementInfo(Player receiver, uint achievementId = 0) + public void SendAchievementInfo(Player receiver) { RespondInspectAchievements inspectedAchievements = new RespondInspectAchievements(); inspectedAchievements.Player = _owner.GetGUID(); diff --git a/Source/Game/AuctionHouse/AuctionManager.cs b/Source/Game/AuctionHouse/AuctionManager.cs index 27e71f9d6..1f5d2c0c2 100644 --- a/Source/Game/AuctionHouse/AuctionManager.cs +++ b/Source/Game/AuctionHouse/AuctionManager.cs @@ -79,12 +79,12 @@ namespace Game if (!item) return; - uint bidderAccId = 0; + uint bidderAccId; ObjectGuid bidderGuid = ObjectGuid.Create(HighGuid.Player, auction.bidder); Player bidder = Global.ObjAccessor.FindPlayer(bidderGuid); // data for gm.log string bidderName = ""; - bool logGmTrade = false; + bool logGmTrade; if (bidder) { @@ -428,8 +428,7 @@ namespace Game public bool RemoveAuction(AuctionEntry auction) { Global.ScriptMgr.OnAuctionRemove(this, auction); - - return AuctionsMap.TryRemove(auction.Id, out AuctionEntry removedItem); + return AuctionsMap.TryRemove(auction.Id, out _); } public void Update() diff --git a/Source/Game/BattleFields/BattleField.cs b/Source/Game/BattleFields/BattleField.cs index e1f6eb4b1..2599f0b1b 100644 --- a/Source/Game/BattleFields/BattleField.cs +++ b/Source/Game/BattleFields/BattleField.cs @@ -1125,7 +1125,7 @@ namespace Game.BattleFields { capturePoint.SetRespawnTime(0); // not save respawn time capturePoint.Delete(); - capturePoint = null; + capturePoint.Dispose(); } m_capturePointGUID.Clear(); } @@ -1176,7 +1176,7 @@ namespace Game.BattleFields if (MathFunctions.fuzzyEq(fact_diff, 0.0f)) return false; - Team Challenger = 0; + Team Challenger; float maxDiff = m_maxSpeed * diff; if (fact_diff < 0) diff --git a/Source/Game/BattleFields/Zones/WinterGrasp.cs b/Source/Game/BattleFields/Zones/WinterGrasp.cs index ea7d275d5..c6cd3befd 100644 --- a/Source/Game/BattleFields/Zones/WinterGrasp.cs +++ b/Source/Game/BattleFields/Zones/WinterGrasp.cs @@ -527,7 +527,7 @@ namespace Game.BattleFields public override void OnGameObjectCreate(GameObject go) { - uint workshopId = 0; + uint workshopId; switch (go.GetEntry()) { diff --git a/Source/Game/BattleGrounds/BattleGround.cs b/Source/Game/BattleGrounds/BattleGround.cs index 1d2b45e4e..1511ed56d 100644 --- a/Source/Game/BattleGrounds/BattleGround.cs +++ b/Source/Game/BattleGrounds/BattleGround.cs @@ -674,7 +674,7 @@ namespace Game.BattleGrounds SetWinner(BattlegroundTeamId.Neutral); } - PreparedStatement stmt = null; + PreparedStatement stmt; ulong battlegroundId = 1; if (IsBattleground() && WorldConfig.GetBoolValue(WorldCfg.BattlegroundStoreStatisticsEnable)) { diff --git a/Source/Game/BattleGrounds/Zones/ArathiBasin.cs b/Source/Game/BattleGrounds/Zones/ArathiBasin.cs index 54b033c66..3ebd7d7a6 100644 --- a/Source/Game/BattleGrounds/Zones/ArathiBasin.cs +++ b/Source/Game/BattleGrounds/Zones/ArathiBasin.cs @@ -428,7 +428,7 @@ namespace Game.BattleGrounds.Zones return; source.RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.EnterPvpCombat); - uint sound = 0; + uint sound; // If node is neutral, change to contested if (m_Nodes[node] == ABNodeStatus.Neutral) { diff --git a/Source/Game/BattleGrounds/Zones/EyeofStorm.cs b/Source/Game/BattleGrounds/Zones/EyeofStorm.cs index d18635218..dec8994b3 100644 --- a/Source/Game/BattleGrounds/Zones/EyeofStorm.cs +++ b/Source/Game/BattleGrounds/Zones/EyeofStorm.cs @@ -163,7 +163,7 @@ namespace Game.BattleGrounds.Zones void CheckSomeoneJoinedPo() { - GameObject obj = null; + GameObject obj; for (byte i = 0; i < EotSPoints.PointsMax; ++i) { obj = GetBgMap().GetGameObject(BgObjects[EotSObjectTypes.TowerCapFelReaver + i]); @@ -203,7 +203,8 @@ namespace Game.BattleGrounds.Zones //reset current point counts for (byte i = 0; i < 2 * EotSPoints.PointsMax; ++i) m_CurrentPointPlayersCount[i] = 0; - GameObject obj = null; + + GameObject obj; for (byte i = 0; i < EotSPoints.PointsMax; ++i) { obj = GetBgMap().GetGameObject(BgObjects[EotSObjectTypes.TowerCapFelReaver + i]); @@ -255,7 +256,7 @@ namespace Game.BattleGrounds.Zones //point is fully horde's m_PointBarStatus[point] = EotSProgressBarConsts.ProgressBarHordeControlled; - uint pointOwnerTeamId = 0; + uint pointOwnerTeamId; //find which team should own this point if (m_PointBarStatus[point] <= EotSProgressBarConsts.ProgressBarNeutralLow) pointOwnerTeamId = (uint)Team.Horde; @@ -871,8 +872,7 @@ namespace Game.BattleGrounds.Zones public override WorldSafeLocsEntry GetClosestGraveYard(Player player) { - uint g_id = 0; - + uint g_id; switch (player.GetTeam()) { case Team.Alliance: @@ -884,11 +884,8 @@ namespace Game.BattleGrounds.Zones default: return null; } - WorldSafeLocsEntry entry = null; - WorldSafeLocsEntry nearestEntry = null; - entry = Global.ObjectMgr.GetWorldSafeLoc(g_id); - nearestEntry = entry; - + WorldSafeLocsEntry entry = Global.ObjectMgr.GetWorldSafeLoc(g_id); + WorldSafeLocsEntry nearestEntry = entry; if (entry == null) { Log.outError(LogFilter.Battleground, "BattlegroundEY: The main team graveyard could not be found. The graveyard system will not be operational!"); diff --git a/Source/Game/BattleGrounds/Zones/StrandofAncients.cs b/Source/Game/BattleGrounds/Zones/StrandofAncients.cs index 858270d05..13f4b3038 100644 --- a/Source/Game/BattleGrounds/Zones/StrandofAncients.cs +++ b/Source/Game/BattleGrounds/Zones/StrandofAncients.cs @@ -702,7 +702,7 @@ namespace Game.BattleGrounds.Zones public override WorldSafeLocsEntry GetClosestGraveYard(Player player) { - uint safeloc = 0; + uint safeloc; if (player.GetTeamId() == Attackers) safeloc = SAMiscConst.GYEntries[SAGraveyards.BeachGy]; @@ -820,9 +820,9 @@ namespace Game.BattleGrounds.Zones } AddSpiritGuide(i + SACreatureTypes.Max, sg.Loc.GetPositionX(), sg.Loc.GetPositionY(), sg.Loc.GetPositionZ(), SAMiscConst.GYOrientation[i], GraveyardStatus[i]); - uint npc = 0; - int flag = 0; + uint npc; + int flag; switch (i) { case SAGraveyards.LeftCapturableGy: diff --git a/Source/Game/BattlePets/BattlePetManager.cs b/Source/Game/BattlePets/BattlePetManager.cs index 330a84ce2..10866d132 100644 --- a/Source/Game/BattlePets/BattlePetManager.cs +++ b/Source/Game/BattlePets/BattlePetManager.cs @@ -474,18 +474,14 @@ namespace Game.BattlePets { public void CalculateStats() { - float health = 0.0f; - float power = 0.0f; - float speed = 0.0f; - // get base breed stats var breedState = _battlePetBreedStates.LookupByKey(PacketInfo.Breed); if (breedState == null) // non existing breed id return; - health = breedState[BattlePetState.StatStamina]; - power = breedState[BattlePetState.StatPower]; - speed = breedState[BattlePetState.StatSpeed]; + float health = breedState[BattlePetState.StatStamina]; + float power = breedState[BattlePetState.StatPower]; + float speed = breedState[BattlePetState.StatSpeed]; // modify stats depending on species - not all pets have this var speciesState = _battlePetSpeciesStates.LookupByKey(PacketInfo.Species); diff --git a/Source/Game/BlackMarket/BlackMarketManager.cs b/Source/Game/BlackMarket/BlackMarketManager.cs index 66daab0d8..2e7b6d67b 100644 --- a/Source/Game/BlackMarket/BlackMarketManager.cs +++ b/Source/Game/BlackMarket/BlackMarketManager.cs @@ -213,12 +213,12 @@ namespace Game.BlackMarket if (entry.GetMailSent()) return; - uint bidderAccId = 0; + uint bidderAccId; ObjectGuid bidderGuid = ObjectGuid.Create(HighGuid.Player, entry.GetBidder()); Player bidder = Global.ObjAccessor.FindConnectedPlayer(bidderGuid); // data for gm.log string bidderName = ""; - bool logGmTrade = false; + bool logGmTrade; if (bidder) { diff --git a/Source/Game/Chat/CommandHandler.cs b/Source/Game/Chat/CommandHandler.cs index f06e0a17e..f008325ca 100644 --- a/Source/Game/Chat/CommandHandler.cs +++ b/Source/Game/Chat/CommandHandler.cs @@ -273,13 +273,11 @@ namespace Game.Chat public string ExtractKeyFromLink(StringArguments args, params string[] linkType) { - int throwaway; - return ExtractKeyFromLink(args, linkType, out throwaway); + return ExtractKeyFromLink(args, linkType, out _); } public string ExtractKeyFromLink(StringArguments args, string[] linkType, out int found_idx) { - string throwaway; - return ExtractKeyFromLink(args, linkType, out found_idx, out throwaway); + return ExtractKeyFromLink(args, linkType, out found_idx, out _); } public string ExtractKeyFromLink(StringArguments args, string[] linkType, out int found_idx, out string something1) { @@ -378,14 +376,11 @@ namespace Game.Chat } public bool ExtractPlayerTarget(StringArguments args, out Player player) { - ObjectGuid guid; - string name; - return ExtractPlayerTarget(args, out player, out guid, out name); + return ExtractPlayerTarget(args, out player, out _, out _); } public bool ExtractPlayerTarget(StringArguments args, out Player player, out ObjectGuid playerGuid) { - string name; - return ExtractPlayerTarget(args, out player, out playerGuid, out name); + return ExtractPlayerTarget(args, out player, out playerGuid, out _); } public bool ExtractPlayerTarget(StringArguments args, out Player player, out ObjectGuid playerGuid, out string playerName) @@ -496,9 +491,7 @@ namespace Game.Chat // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r // number or [name] Shift-click form |color|Htalent:talent_id, rank|h[name]|h|r // number or [name] Shift-click form |color|Htrade:spell_id, skill_id, max_value, cur_value|h[name]|h|r - int type = 0; - string param1Str = null; - string idS = ExtractKeyFromLink(args, spellKeys, out type, out param1Str); + string idS = ExtractKeyFromLink(args, spellKeys, out int type, out string param1Str); if (string.IsNullOrEmpty(idS)) return 0; diff --git a/Source/Game/Chat/Commands/AccountCommands.cs b/Source/Game/Chat/Commands/AccountCommands.cs index 2a8c15cf7..7420ee994 100644 --- a/Source/Game/Chat/Commands/AccountCommands.cs +++ b/Source/Game/Chat/Commands/AccountCommands.cs @@ -521,9 +521,10 @@ namespace Game.Chat } string targetAccountName = ""; - uint targetAccountId = 0; - AccountTypes targetSecurity = 0; - uint gm = 0; + uint targetAccountId; + AccountTypes targetSecurity; + uint gm; + string arg1 = args.NextString(); string arg2 = args.NextString(); string arg3 = args.NextString(); diff --git a/Source/Game/Chat/Commands/BanCommands.cs b/Source/Game/Chat/Commands/BanCommands.cs index 4acf26e7d..4caf94940 100644 --- a/Source/Game/Chat/Commands/BanCommands.cs +++ b/Source/Game/Chat/Commands/BanCommands.cs @@ -133,8 +133,7 @@ namespace Game.Chat.Commands } break; case BanMode.IP: - IPAddress address; - if (!IPAddress.TryParse(nameOrIP, out address)) + if (!IPAddress.TryParse(nameOrIP, out _)) return false; break; } @@ -143,7 +142,7 @@ namespace Game.Chat.Commands switch (Global.WorldMgr.BanAccount(mode, nameOrIP, durationStr, reasonStr, author)) { case BanReturn.Success: - if (!uint.TryParse(durationStr, out uint tempValue) || tempValue > 0) + if (duration > 0) { if (WorldConfig.GetBoolValue(WorldCfg.ShowBanInWorld)) Global.WorldMgr.SendWorldText(CypherStrings.BanAccountYoubannedmessageWorld, author, nameOrIP, Time.secsToTimeString(Time.TimeStringToSecs(durationStr)), reasonStr); @@ -654,8 +653,7 @@ namespace Game.Chat.Commands } break; case BanMode.IP: - IPAddress address; - if (!IPAddress.TryParse(nameOrIP, out address)) + if (!IPAddress.TryParse(nameOrIP, out _)) return false; break; } diff --git a/Source/Game/Chat/Commands/CharacterCommands.cs b/Source/Game/Chat/Commands/CharacterCommands.cs index 7e65ed62f..0a90609fa 100644 --- a/Source/Game/Chat/Commands/CharacterCommands.cs +++ b/Source/Game/Chat/Commands/CharacterCommands.cs @@ -277,8 +277,7 @@ namespace Game.Chat ObjectGuid targetGuid; string targetName; - Player playerNotUsed; - if (!handler.ExtractPlayerTarget(new StringArguments(playerNameStr), out playerNotUsed, out targetGuid, out targetName)) + if (!handler.ExtractPlayerTarget(new StringArguments(playerNameStr), out _, out targetGuid, out targetName)) return false; CharacterCacheEntry characterInfo = Global.CharacterCacheStorage.GetCharacterCacheByGuid(targetGuid); diff --git a/Source/Game/Chat/Commands/GameObjectCommands.cs b/Source/Game/Chat/Commands/GameObjectCommands.cs index d8b18eda8..7064d7114 100644 --- a/Source/Game/Chat/Commands/GameObjectCommands.cs +++ b/Source/Game/Chat/Commands/GameObjectCommands.cs @@ -393,11 +393,6 @@ namespace Game.Chat [Command("info", RBACPermissions.CommandGobjectInfo)] static bool HandleGameObjectInfoCommand(StringArguments args, CommandHandler handler) { - uint entry = 0; - GameObjectTypes type = 0; - uint displayId = 0; - uint lootId = 0; - if (args.Empty()) return false; @@ -405,6 +400,7 @@ namespace Game.Chat if (param1.IsEmpty()) return false; + uint entry; if (param1.Equals("guid")) { string cValue = handler.ExtractKeyFromLink(args, "Hgameobject"); @@ -429,10 +425,10 @@ namespace Game.Chat if (gameObjectInfo == null) return false; - type = gameObjectInfo.type; - displayId = gameObjectInfo.displayId; + GameObjectTypes type = gameObjectInfo.type; + uint displayId = gameObjectInfo.displayId; string name = gameObjectInfo.name; - lootId = gameObjectInfo.GetLootId(); + uint lootId = gameObjectInfo.GetLootId(); handler.SendSysMessage(CypherStrings.GoinfoEntry, entry); handler.SendSysMessage(CypherStrings.GoinfoType, type); diff --git a/Source/Game/Chat/Commands/GoCommands.cs b/Source/Game/Chat/Commands/GoCommands.cs index 7e756bd33..bdf379044 100644 --- a/Source/Game/Chat/Commands/GoCommands.cs +++ b/Source/Game/Chat/Commands/GoCommands.cs @@ -262,8 +262,8 @@ namespace Game.Chat.Commands return false; } - float x, y, z = 0; - uint mapId = 0; + float x, y, z; + uint mapId; var poiData = Global.ObjectMgr.GetQuestPOIData(questID); if (poiData != null) diff --git a/Source/Game/Chat/Commands/GroupCommands.cs b/Source/Game/Chat/Commands/GroupCommands.cs index 319d620f9..78e16d2ef 100644 --- a/Source/Game/Chat/Commands/GroupCommands.cs +++ b/Source/Game/Chat/Commands/GroupCommands.cs @@ -125,9 +125,9 @@ namespace Game.Chat [Command("leader", RBACPermissions.CommandGroupLeader)] static bool HandleGroupLeaderCommand(StringArguments args, CommandHandler handler) { - Player player = null; - Group group = null; - ObjectGuid guid = ObjectGuid.Empty; + Player player; + Group group; + ObjectGuid guid; string nameStr = args.NextString(); if (!handler.GetPlayerGroupAndGUIDByName(nameStr, out player, out group, out guid)) @@ -151,12 +151,11 @@ namespace Game.Chat [Command("disband", RBACPermissions.CommandGroupDisband)] static bool HandleGroupDisbandCommand(StringArguments args, CommandHandler handler) { - Player player = null; - Group group = null; - ObjectGuid guid = ObjectGuid.Empty; + Player player; + Group group; string nameStr = args.NextString(); - if (!handler.GetPlayerGroupAndGUIDByName(nameStr, out player, out group, out guid)) + if (!handler.GetPlayerGroupAndGUIDByName(nameStr, out player, out group, out _)) return false; if (!group) @@ -172,9 +171,9 @@ namespace Game.Chat [Command("remove", RBACPermissions.CommandGroupRemove)] static bool HandleGroupRemoveCommand(StringArguments args, CommandHandler handler) { - Player player = null; - Group group = null; - ObjectGuid guid = ObjectGuid.Empty; + Player player; + Group group; + ObjectGuid guid; string nameStr = args.NextString(); if (!handler.GetPlayerGroupAndGUIDByName(nameStr, out player, out group, out guid)) @@ -196,16 +195,14 @@ namespace Game.Chat if (args.Empty()) return false; - Player playerSource = null; - Player playerTarget = null; - Group groupSource = null; - Group groupTarget = null; - ObjectGuid guidSource = ObjectGuid.Empty; - ObjectGuid guidTarget = ObjectGuid.Empty; + Player playerSource; + Player playerTarget; + Group groupSource; + Group groupTarget; string nameplgrStr = args.NextString(); string nameplStr = args.NextString(); - if (!handler.GetPlayerGroupAndGUIDByName(nameplgrStr, out playerSource, out groupSource, out guidSource, true)) + if (!handler.GetPlayerGroupAndGUIDByName(nameplgrStr, out playerSource, out groupSource, out _, true)) return false; if (!groupSource) @@ -214,7 +211,7 @@ namespace Game.Chat return false; } - if (!handler.GetPlayerGroupAndGUIDByName(nameplStr, out playerTarget, out groupTarget, out guidTarget, true)) + if (!handler.GetPlayerGroupAndGUIDByName(nameplStr, out playerTarget, out groupTarget, out _, true)) return false; if (groupTarget || playerTarget.GetGroup() == groupSource) @@ -243,7 +240,7 @@ namespace Game.Chat ObjectGuid guidTarget; string nameTarget; string zoneName = ""; - string onlineState = ""; + string onlineState; // Parse the guid to uint32... ObjectGuid parseGUID = ObjectGuid.Create(HighGuid.Player, args.NextUInt64()); diff --git a/Source/Game/Chat/Commands/GuildCommands.cs b/Source/Game/Chat/Commands/GuildCommands.cs index 5a01a96c3..885ed3100 100644 --- a/Source/Game/Chat/Commands/GuildCommands.cs +++ b/Source/Game/Chat/Commands/GuildCommands.cs @@ -99,7 +99,7 @@ namespace Game.Chat static bool HandleGuildUninviteCommand(StringArguments args, CommandHandler handler) { Player target; - ObjectGuid targetGuid = ObjectGuid.Empty; + ObjectGuid targetGuid; if (!handler.ExtractPlayerTarget(args, out target, out targetGuid)) return false; @@ -126,8 +126,7 @@ namespace Game.Chat Player target; ObjectGuid targetGuid; - string target_name; - if (!handler.ExtractPlayerTarget(new StringArguments(nameStr), out target, out targetGuid, out target_name)) + if (!handler.ExtractPlayerTarget(new StringArguments(nameStr), out target, out targetGuid, out _)) return false; ulong guildId = target ? target.GetGuildId() : Global.CharacterCacheStorage.GetCharacterGuildIdByGuid(targetGuid); diff --git a/Source/Game/Chat/Commands/InstanceCommands.cs b/Source/Game/Chat/Commands/InstanceCommands.cs index 57d0df206..052274514 100644 --- a/Source/Game/Chat/Commands/InstanceCommands.cs +++ b/Source/Game/Chat/Commands/InstanceCommands.cs @@ -220,7 +220,6 @@ namespace Game.Chat string param1 = args.NextString(); string param2 = args.NextString(); - uint encounterId = 0; Player player = null; // Character name must be provided when using this from console. @@ -257,7 +256,7 @@ namespace Game.Chat return false; } - if (!uint.TryParse(param1, out encounterId)) + if (!uint.TryParse(param1, out uint encounterId)) return false; if (encounterId > map.GetInstanceScript().GetEncounterCount()) diff --git a/Source/Game/Chat/Commands/LFGCommands.cs b/Source/Game/Chat/Commands/LFGCommands.cs index 90ea4e7fb..f109d5e4f 100644 --- a/Source/Game/Chat/Commands/LFGCommands.cs +++ b/Source/Game/Chat/Commands/LFGCommands.cs @@ -30,10 +30,8 @@ namespace Game.Chat [Command("player", RBACPermissions.CommandLfgPlayer, true)] static bool HandleLfgPlayerInfoCommand(StringArguments args, CommandHandler handler) { - Player target = null; - string playerName; - ObjectGuid guid; - if (!handler.ExtractPlayerTarget(args, out target, out guid, out playerName)) + Player target; + if (!handler.ExtractPlayerTarget(args, out target)) return false; GetPlayerInfo(handler, target); @@ -46,7 +44,7 @@ namespace Game.Chat if (args.Empty()) return false; - Player playerTarget = null; + Player playerTarget; ObjectGuid guidTarget; string nameTarget; diff --git a/Source/Game/Chat/Commands/MiscCommands.cs b/Source/Game/Chat/Commands/MiscCommands.cs index 0a31002e2..f41d702fc 100644 --- a/Source/Game/Chat/Commands/MiscCommands.cs +++ b/Source/Game/Chat/Commands/MiscCommands.cs @@ -125,7 +125,7 @@ namespace Game.Chat [CommandNonGroup("gps", RBACPermissions.CommandGps)] static bool HandleGPSCommand(StringArguments args, CommandHandler handler) { - WorldObject obj = null; + WorldObject obj; if (!args.Empty()) { HighGuid guidHigh = 0; @@ -604,8 +604,7 @@ namespace Game.Chat // to point where player stay (if loaded) WorldLocation loc; - bool in_flight; - if (!Player.LoadPositionFromDB(out loc, out in_flight, targetGuid)) + if (!Player.LoadPositionFromDB(out loc, out _, targetGuid)) return false; // stop flight if need @@ -809,7 +808,7 @@ namespace Game.Chat [CommandNonGroup("distance", RBACPermissions.CommandDistance)] static bool HandleGetDistanceCommand(StringArguments args, CommandHandler handler) { - WorldObject obj = null; + WorldObject obj; if (!args.Empty()) { @@ -935,10 +934,9 @@ namespace Game.Chat [CommandNonGroup("kick", RBACPermissions.CommandKick, true)] static bool Kick(StringArguments args, CommandHandler handler) { - Player target = null; + Player target; string playerName; - ObjectGuid guid; - if (!handler.ExtractPlayerTarget(args, out target, out guid, out playerName)) + if (!handler.ExtractPlayerTarget(args, out target, out _, out playerName)) return false; if (handler.GetSession() != null && target == handler.GetSession().GetPlayer()) @@ -990,7 +988,7 @@ namespace Game.Chat if (string.IsNullOrEmpty(loc)) location_str = loc; - Player player = null; + Player player; ObjectGuid targetGUID; if (!handler.ExtractPlayerTarget(args, out player, out targetGUID)) return false; @@ -1285,7 +1283,7 @@ namespace Game.Chat Player target; ObjectGuid targetGuid; string targetName; - PreparedStatement stmt = null; + PreparedStatement stmt; // To make sure we get a target, we convert our guid to an omniversal... ObjectGuid parseGUID = ObjectGuid.Create(HighGuid.Player, args.NextUInt64()); @@ -1334,7 +1332,7 @@ namespace Game.Chat // Account data print variables string userName = handler.GetCypherString(CypherStrings.Error); - uint accId = 0; + uint accId; ulong lowguid = targetGuid.GetCounter(); string eMail = handler.GetCypherString(CypherStrings.Error); string regMail = handler.GetCypherString(CypherStrings.Error); @@ -1362,10 +1360,10 @@ namespace Game.Chat Class classid; Gender gender; LocaleConstant locale = handler.GetSessionDbcLocale(); - uint totalPlayerTime = 0; - uint level = 0; + uint totalPlayerTime; + uint level; string alive = handler.GetCypherString(CypherStrings.Error); - ulong money = 0; + ulong money; uint xp = 0; uint xptotal = 0; @@ -1691,7 +1689,7 @@ namespace Game.Chat return false; PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.UPD_MUTE_TIME); - string muteBy = ""; + string muteBy; if (handler.GetSession() != null) muteBy = handler.GetSession().GetPlayerName(); else @@ -1875,7 +1873,7 @@ namespace Game.Chat break; case MovementGeneratorType.Chase: { - Unit target = null; + Unit target; if (unit.IsTypeId(TypeId.Player)) target = ((ChaseMovementGenerator)movementGenerator).Target; else @@ -1891,7 +1889,7 @@ namespace Game.Chat } case MovementGeneratorType.Follow: { - Unit target = null; + Unit target; if (unit.IsTypeId(TypeId.Player)) target = ((FollowMovementGenerator)movementGenerator).Target; else diff --git a/Source/Game/Chat/Commands/ModifyCommands.cs b/Source/Game/Chat/Commands/ModifyCommands.cs index d2ca53a13..2bb95f974 100644 --- a/Source/Game/Chat/Commands/ModifyCommands.cs +++ b/Source/Game/Chat/Commands/ModifyCommands.cs @@ -31,9 +31,8 @@ namespace Game.Chat [Command("hp", RBACPermissions.CommandModifyHp)] static bool HandleModifyHPCommand(StringArguments args, CommandHandler handler) { - int hp, hpmax = 0; Player target = handler.GetSelectedPlayerOrSelf(); - if (CheckModifyResources(args, handler, target, out hp, out hpmax)) + if (CheckModifyResources(args, handler, target, out int hp, out int hpmax)) { NotifyModification(handler, target, CypherStrings.YouChangeHp, CypherStrings.YoursHpChanged, hp, hpmax); target.SetMaxHealth((uint)hpmax); @@ -390,9 +389,8 @@ namespace Game.Chat if (!uint.TryParse(factionTxt, out uint factionId)) return false; - int amount = 0; string rankTxt = args.NextString(); - if (factionId == 0 || !int.TryParse(rankTxt, out amount)) + if (factionId == 0 || !int.TryParse(rankTxt, out int amount)) return false; if ((amount == 0) && !(amount < 0) && !rankTxt.IsNumber()) diff --git a/Source/Game/Chat/Commands/NPCCommands.cs b/Source/Game/Chat/Commands/NPCCommands.cs index cd341661f..04e5b1594 100644 --- a/Source/Game/Chat/Commands/NPCCommands.cs +++ b/Source/Game/Chat/Commands/NPCCommands.cs @@ -113,7 +113,7 @@ namespace Game.Chat [Command("move", RBACPermissions.CommandNpcMove)] static bool Move(StringArguments args, CommandHandler handler) { - ulong lowguid = 0; + ulong lowguid; Creature creature = handler.GetSelectedCreature(); if (!creature) @@ -812,7 +812,7 @@ namespace Game.Chat if (string.IsNullOrEmpty(guid_str)) return false; - ulong lowguid = 0; + ulong lowguid; Creature creature = null; if (!string.IsNullOrEmpty(dontdel_str)) @@ -980,7 +980,7 @@ namespace Game.Chat mtype = MovementGeneratorType.Random; Creature creature = handler.GetSelectedCreature(); - ulong guidLow = 0; + ulong guidLow; if (creature) guidLow = creature.GetSpawnId(); diff --git a/Source/Game/Chat/Commands/RbacCommands.cs b/Source/Game/Chat/Commands/RbacCommands.cs index 8f68fd57c..9be1405a3 100644 --- a/Source/Game/Chat/Commands/RbacCommands.cs +++ b/Source/Game/Chat/Commands/RbacCommands.cs @@ -225,7 +225,7 @@ namespace Game.Chat.Commands string param3 = args.NextString(); int realmId = -1; - uint accountId = 0; + uint accountId; string accountName; uint id = 0; RBACData rdata = null; diff --git a/Source/Game/Chat/Commands/SendCommands.cs b/Source/Game/Chat/Commands/SendCommands.cs index 60a819775..590ef812f 100644 --- a/Source/Game/Chat/Commands/SendCommands.cs +++ b/Source/Game/Chat/Commands/SendCommands.cs @@ -118,8 +118,7 @@ namespace Game.Chat.Commands return false; } - uint itemCount = 0; - if (string.IsNullOrEmpty(itemCountStr) || !uint.TryParse(itemCountStr, out itemCount)) + if (string.IsNullOrEmpty(itemCountStr) || !uint.TryParse(itemCountStr, out uint itemCount)) itemCount = 1; if (itemCount < 1 || (item_proto.GetMaxCount() > 0 && itemCount > item_proto.GetMaxCount())) diff --git a/Source/Game/Chat/Commands/ServerCommands.cs b/Source/Game/Chat/Commands/ServerCommands.cs index b430a25a1..fd9e86c6e 100644 --- a/Source/Game/Chat/Commands/ServerCommands.cs +++ b/Source/Game/Chat/Commands/ServerCommands.cs @@ -115,7 +115,7 @@ namespace Game.Chat uint playerAmountLimit = Global.WorldMgr.GetPlayerAmountLimit(); AccountTypes allowedAccountType = Global.WorldMgr.GetPlayerSecurityLimit(); - string secName = ""; + string secName; switch (allowedAccountType) { case AccountTypes.Player: diff --git a/Source/Game/Chat/Commands/TicketCommands.cs b/Source/Game/Chat/Commands/TicketCommands.cs index 41376e184..53bbe83d8 100644 --- a/Source/Game/Chat/Commands/TicketCommands.cs +++ b/Source/Game/Chat/Commands/TicketCommands.cs @@ -440,7 +440,7 @@ namespace Game.Chat.Commands } // Get security level of player, whom this ticket is assigned to - AccountTypes security = AccountTypes.Player; + AccountTypes security; Player assignedPlayer = ticket.GetAssignedPlayer(); if (assignedPlayer && assignedPlayer.IsInWorld) security = assignedPlayer.GetSession().GetSecurity(); diff --git a/Source/Game/Chat/Commands/WPCommands.cs b/Source/Game/Chat/Commands/WPCommands.cs index 8ba4cbcb1..76e82956b 100644 --- a/Source/Game/Chat/Commands/WPCommands.cs +++ b/Source/Game/Chat/Commands/WPCommands.cs @@ -33,7 +33,7 @@ namespace Game.Chat.Commands { // optional string path_number = null; - uint pathid = 0; + uint pathid; if (!args.Empty()) path_number = args.NextString(); @@ -108,7 +108,7 @@ namespace Game.Chat.Commands return false; string arg_id = args.NextString(); - uint id = 0; + uint id; if (show == "add") { if (!uint.TryParse(arg_id, out id)) @@ -624,7 +624,7 @@ namespace Game.Chat.Commands // second arg: GUID (optional, if a creature is selected) string guid_str = args.NextString(); - uint pathid = 0; + uint pathid; Creature target = handler.GetSelectedCreature(); // Did player provide a PathID? diff --git a/Source/Game/Collision/Maps/MapTree.cs b/Source/Game/Collision/Maps/MapTree.cs index 3f62e39ac..a0b513669 100644 --- a/Source/Game/Collision/Maps/MapTree.cs +++ b/Source/Game/Collision/Maps/MapTree.cs @@ -324,7 +324,7 @@ namespace Game.Collision public bool GetObjectHitPos(Vector3 pPos1, Vector3 pPos2, out Vector3 pResultHitPos, float pModifyDist) { - bool result = false; + bool result; float maxDist = (pPos2 - pPos1).magnitude(); // valid map coords should *never ever* produce float overflow, but this would produce NaNs too Cypher.Assert(maxDist < float.MaxValue); @@ -344,7 +344,7 @@ namespace Game.Collision { if ((pResultHitPos - pPos1).magnitude() > -pModifyDist) { - pResultHitPos = pResultHitPos + dir * pModifyDist; + pResultHitPos += dir * pModifyDist; } else { @@ -353,7 +353,7 @@ namespace Game.Collision } else { - pResultHitPos = pResultHitPos + dir * pModifyDist; + pResultHitPos += dir * pModifyDist; } result = true; } diff --git a/Source/Game/Collision/Models/WorldModel.cs b/Source/Game/Collision/Models/WorldModel.cs index 41357f667..e7b09c375 100644 --- a/Source/Game/Collision/Models/WorldModel.cs +++ b/Source/Game/Collision/Models/WorldModel.cs @@ -196,7 +196,6 @@ namespace Game.Collision void SetLiquidData(WmoLiquid liquid) { iLiquid = liquid; - liquid = null; } public bool ReadFromFile(BinaryReader reader) diff --git a/Source/Scripts/Northrend/IcecrownCitadel/IcecrownCitadel.cs b/Source/Scripts/Northrend/IcecrownCitadel/IcecrownCitadel.cs index 8a1ae7731..06b2423fe 100644 --- a/Source/Scripts/Northrend/IcecrownCitadel/IcecrownCitadel.cs +++ b/Source/Scripts/Northrend/IcecrownCitadel/IcecrownCitadel.cs @@ -861,7 +861,7 @@ namespace Scripts.Northrend.IcecrownCitadel } } - void UpdateEscortAI(uint diff) + public override void UpdateEscortAI(uint diff) { if (_wipeCheckTimer <= diff) _wipeCheckTimer = 0; @@ -1029,7 +1029,7 @@ namespace Scripts.Northrend.IcecrownCitadel { IsUndead = true; me.SetDeathState(DeathState.JustRespawned); - uint newEntry = 0; + uint newEntry; switch (me.GetEntry()) { case CreatureIds.CaptainArnath: @@ -1367,7 +1367,7 @@ namespace Scripts.Northrend.IcecrownCitadel _events.ScheduleEvent(EventTypes.SoulMissile, RandomHelper.URand(1000, 6000)); } - void Update(uint diff) + public override void UpdateAI(uint diff) { if (_events.Empty()) return; @@ -1427,7 +1427,7 @@ namespace Scripts.Northrend.IcecrownCitadel void HandleEvent(uint effIndex) { PreventHitDefaultEffect(effIndex); - uint trapId = 0; + uint trapId; switch (GetSpellInfo().GetEffect(effIndex).MiscValue) { case AwakenWard1: diff --git a/Source/Scripts/World/NpcSpecial.cs b/Source/Scripts/World/NpcSpecial.cs index b0d2804ff..96185d9c4 100644 --- a/Source/Scripts/World/NpcSpecial.cs +++ b/Source/Scripts/World/NpcSpecial.cs @@ -983,8 +983,7 @@ namespace Scripts.World.NpcSpecial if (Coordinates.Empty()) return; - uint patientEntry = 0; - + uint patientEntry; switch (me.GetEntry()) { case CreatureIds.DoctorAlliance: