diff --git a/Framework/Configuration/ConfigManager.cs b/Framework/Configuration/ConfigManager.cs index 0f2285f7c..79c548ab8 100644 --- a/Framework/Configuration/ConfigManager.cs +++ b/Framework/Configuration/ConfigManager.cs @@ -44,7 +44,7 @@ namespace Framework.Configuration foreach (var line in ConfigContent) { lineCounter++; - if (line.StartsWith("#") || line.StartsWith("-") || string.IsNullOrEmpty(line)) + if (string.IsNullOrEmpty(line) || line.StartsWith("#") || line.StartsWith("-")) continue; var configOption = new StringArray(line, '='); diff --git a/Framework/Cryptography/PacketCrypt.cs b/Framework/Cryptography/PacketCrypt.cs index 757419799..4ca841033 100644 --- a/Framework/Cryptography/PacketCrypt.cs +++ b/Framework/Cryptography/PacketCrypt.cs @@ -50,8 +50,6 @@ namespace Framework.Cryptography public void Initialize(byte[] sessionKey, byte[] serverSeed, byte[] clientSeed) { - IsInitialized = false; - if (IsInitialized) throw new InvalidOperationException("PacketCrypt already initialized!"); diff --git a/Framework/Database/DatabaseLoader.cs b/Framework/Database/DatabaseLoader.cs index a1348a9a3..f4f7c74e9 100644 --- a/Framework/Database/DatabaseLoader.cs +++ b/Framework/Database/DatabaseLoader.cs @@ -51,7 +51,7 @@ namespace Framework.Database Log.outInfo(LogFilter.ServerLoading, "Database \"{0}\" does not exist, do you want to create it? [yes (default) / no]: ", name); string answer = Console.ReadLine(); - if (string.IsNullOrEmpty(answer) && answer[0] != 'y') + if (string.IsNullOrEmpty(answer) || answer[0] != 'y') return false; Log.outInfo(LogFilter.ServerLoading, "Creating database \"{0}\"...", name); diff --git a/Framework/Dynamic/TaskScheduler.cs b/Framework/Dynamic/TaskScheduler.cs index c545436de..7ec3badbd 100644 --- a/Framework/Dynamic/TaskScheduler.cs +++ b/Framework/Dynamic/TaskScheduler.cs @@ -482,8 +482,7 @@ namespace Framework.Dynamic public void ModifyIf(Func filter) { List cache = new List(); - container.Where(filter); - foreach (var task in container.ToList()) + foreach (var task in container.Where(filter)) { if (filter(task)) { diff --git a/Framework/GameMath/AxisAlignedBox.cs b/Framework/GameMath/AxisAlignedBox.cs index 5dde34b72..b853bc3ff 100644 --- a/Framework/GameMath/AxisAlignedBox.cs +++ b/Framework/GameMath/AxisAlignedBox.cs @@ -131,12 +131,12 @@ namespace Framework.GameMath vertices[0] = _lo; vertices[1] = new Vector3(_hi.X, _lo.Y, _lo.Z); vertices[2] = new Vector3(_hi.X, _hi.Y, _lo.Z); - vertices[4] = new Vector3(_lo.X, _hi.Y, _lo.Z); + vertices[3] = new Vector3(_lo.X, _hi.Y, _lo.Z); - vertices[5] = new Vector3(_lo.X, _lo.Y, _hi.Z); - vertices[6] = new Vector3(_hi.X, _lo.Y, _hi.Z); - vertices[7] = _hi; - vertices[8] = new Vector3(_lo.X, _hi.Y, _hi.Z); + vertices[4] = new Vector3(_lo.X, _lo.Y, _hi.Z); + vertices[5] = new Vector3(_hi.X, _lo.Y, _hi.Z); + vertices[6] = _hi; + vertices[7] = new Vector3(_lo.X, _hi.Y, _hi.Z); return vertices; } diff --git a/Framework/Realm/Realm.cs b/Framework/Realm/Realm.cs index c09327f16..3aa5975d4 100644 --- a/Framework/Realm/Realm.cs +++ b/Framework/Realm/Realm.cs @@ -26,7 +26,7 @@ public class Realm : IEquatable { Name = name; NormalizedName = name; - NormalizedName.Replace(" ", ""); + NormalizedName = NormalizedName.Replace(" ", ""); } public IPEndPoint GetAddressForClient(IPAddress clientAddr) diff --git a/Game/Arenas/Arena.cs b/Game/Arenas/Arena.cs index d8744b24b..e2fd49056 100644 --- a/Game/Arenas/Arena.cs +++ b/Game/Arenas/Arena.cs @@ -162,8 +162,8 @@ namespace Game.Arenas if (winner != 0) { - winnerMatchmakerChange = winnerArenaTeam.WonAgainst(winnerMatchmakerRating, loserMatchmakerRating, winnerChange); - loserMatchmakerChange = loserArenaTeam.LostAgainst(loserMatchmakerRating, winnerMatchmakerRating, loserChange); + winnerMatchmakerChange = winnerArenaTeam.WonAgainst(winnerMatchmakerRating, loserMatchmakerRating, ref winnerChange); + loserMatchmakerChange = loserArenaTeam.LostAgainst(loserMatchmakerRating, winnerMatchmakerRating, ref loserChange); Log.outDebug(LogFilter.Arena, "match Type: {0} --- Winner: old rating: {1}, rating gain: {2}, old MMR: {3}, MMR gain: {4} --- Loser: old rating: {5}, " + "rating loss: {6}, old MMR: {7}, MMR loss: {8} ---", GetArenaType(), winnerTeamRating, winnerChange, winnerMatchmakerRating, winnerMatchmakerChange, diff --git a/Game/Arenas/ArenaTeam.cs b/Game/Arenas/ArenaTeam.cs index 7f30fc5e0..2862b0419 100644 --- a/Game/Arenas/ArenaTeam.cs +++ b/Game/Arenas/ArenaTeam.cs @@ -588,7 +588,7 @@ namespace Game.Arenas } } - public int WonAgainst(uint ownMMRating, uint opponentMMRating, int ratingChange) + public int WonAgainst(uint ownMMRating, uint opponentMMRating, ref int ratingChange) { // Called when the team has won // Change in Matchmaker rating @@ -608,7 +608,7 @@ namespace Game.Arenas return mod; } - public int LostAgainst(uint ownMMRating, uint opponentMMRating, int ratingChange) + public int LostAgainst(uint ownMMRating, uint opponentMMRating, ref int ratingChange) { // Called when the team has lost // Change in Matchmaker Rating diff --git a/Game/Chat/Commands/CheatCommands.cs b/Game/Chat/Commands/CheatCommands.cs index 93b343881..8380fceed 100644 --- a/Game/Chat/Commands/CheatCommands.cs +++ b/Game/Chat/Commands/CheatCommands.cs @@ -27,7 +27,7 @@ namespace Game.Chat.Commands [Command("god", RBACPermissions.CommandCheatGod)] static bool HandleGodModeCheat(StringArguments args, CommandHandler handler) { - if (handler.GetSession() == null && handler.GetSession().GetPlayer()) + if (handler.GetSession() == null || handler.GetSession().GetPlayer()) return false; string argstr = args.NextString(); @@ -53,7 +53,7 @@ namespace Game.Chat.Commands [Command("casttime", RBACPermissions.CommandCheatCasttime)] static bool HandleCasttimeCheat(StringArguments args, CommandHandler handler) { - if (handler.GetSession() == null && handler.GetSession().GetPlayer()) + if (handler.GetSession() == null || handler.GetSession().GetPlayer()) return false; string argstr = args.NextString(); @@ -80,7 +80,7 @@ namespace Game.Chat.Commands [Command("cooldown", RBACPermissions.CommandCheatCooldown)] static bool HandleCoolDownCheat(StringArguments args, CommandHandler handler) { - if (handler.GetSession() == null && handler.GetSession().GetPlayer()) + if (handler.GetSession() == null || handler.GetSession().GetPlayer()) return false; string argstr = args.NextString(); @@ -107,7 +107,7 @@ namespace Game.Chat.Commands [Command("power", RBACPermissions.CommandCheatPower)] static bool HandlePowerCheat(StringArguments args, CommandHandler handler) { - if (handler.GetSession() == null && handler.GetSession().GetPlayer()) + if (handler.GetSession() == null || handler.GetSession().GetPlayer()) return false; string argstr = args.NextString(); @@ -152,7 +152,7 @@ namespace Game.Chat.Commands [Command("waterwalk", RBACPermissions.CommandCheatWaterwalk)] static bool HandleWaterWalkCheat(StringArguments args, CommandHandler handler) { - if (handler.GetSession() == null && handler.GetSession().GetPlayer()) + if (handler.GetSession() == null || handler.GetSession().GetPlayer()) return false; string argstr = args.NextString(); diff --git a/Game/Collision/Maps/MapTree.cs b/Game/Collision/Maps/MapTree.cs index 8ea1bd286..0a88d47c2 100644 --- a/Game/Collision/Maps/MapTree.cs +++ b/Game/Collision/Maps/MapTree.cs @@ -227,7 +227,7 @@ namespace Game.Collision } static uint packTileID(uint tileX, uint tileY) { return tileX << 16 | tileY; } - static void unpackTileID(uint ID, uint tileX, uint tileY) { tileX = ID >> 16; tileY = ID & 0xFF; } + static void unpackTileID(uint ID, ref uint tileX, ref uint tileY) { tileX = ID >> 16; tileY = ID & 0xFF; } public static bool CanLoadMap(string vmapPath, uint mapID, uint tileX, uint tileY) { string fullname = vmapPath + VMapManager.getMapFileName(mapID); diff --git a/Game/DataStorage/DB2Manager.cs b/Game/DataStorage/DB2Manager.cs index 6d8dafaea..68116f0c0 100644 --- a/Game/DataStorage/DB2Manager.cs +++ b/Game/DataStorage/DB2Manager.cs @@ -612,9 +612,6 @@ namespace Game.DataStorage return 0.0f; CurveRecord curve = CliDB.CurveStorage.LookupByKey(curveId); - if (points.Empty()) - return 0.0f; - switch (DetermineCurveType(curve, points)) { case CurveInterpolationMode.Linear: diff --git a/Game/Entities/Item/Item.cs b/Game/Entities/Item/Item.cs index a81764d2f..584e76214 100644 --- a/Game/Entities/Item/Item.cs +++ b/Game/Entities/Item/Item.cs @@ -705,7 +705,7 @@ namespace Game.Entities public void SetState(ItemUpdateState state, Player forplayer = null) { - if (uState == ItemUpdateState.New && uState == ItemUpdateState.Removed) + if (uState == ItemUpdateState.New && state == ItemUpdateState.Removed) { // pretend the item never existed if (forplayer) diff --git a/Game/Entities/Item/ItemTemplate.cs b/Game/Entities/Item/ItemTemplate.cs index 2c90a3d75..2ed5104c5 100644 --- a/Game/Entities/Item/ItemTemplate.cs +++ b/Game/Entities/Item/ItemTemplate.cs @@ -192,7 +192,7 @@ namespace Game.Entities float avgDamage = dps * GetDelay() * 0.001f; minDamage = (GetStatScalingFactor() * -0.5f + 1.0f) * avgDamage; - maxDamage = (float)Math.Floor((avgDamage * (GetStatScalingFactor() * 0.5f + 1.0f) + 0.5f)); + maxDamage = (float)Math.Floor(avgDamage * (GetStatScalingFactor() * 0.5f + 1.0f) + 0.5f); } public bool IsUsableByLootSpecialization(Player player) diff --git a/Game/Entities/Player/Player.Quest.cs b/Game/Entities/Player/Player.Quest.cs index 6760d4620..b53ce1889 100644 --- a/Game/Entities/Player/Player.Quest.cs +++ b/Game/Entities/Player/Player.Quest.cs @@ -164,9 +164,6 @@ namespace Game.Entities if (eventList.Empty()) return; - if (eventList.Empty()) - return; - foreach (uint questId in eventList) { uint questBit = Global.DB2Mgr.GetQuestUniqueBitFlag(questId); diff --git a/Game/Entities/Unit/Unit.Spells.cs b/Game/Entities/Unit/Unit.Spells.cs index 14386290c..314ea42a5 100644 --- a/Game/Entities/Unit/Unit.Spells.cs +++ b/Game/Entities/Unit/Unit.Spells.cs @@ -1836,7 +1836,7 @@ namespace Game.Entities } } - if (!IsTriggeredAtSpellProcEvent(target, triggerData.aura, procSpell, procFlag, procExtra, attType, isVictim, active, triggerData.spellProcEvent)) + if (!IsTriggeredAtSpellProcEvent(target, triggerData.aura, procSpell, procFlag, procExtra, attType, isVictim, active, ref triggerData.spellProcEvent)) continue; // do checks using conditions table @@ -2415,7 +2415,7 @@ namespace Game.Entities } } - bool IsTriggeredAtSpellProcEvent(Unit victim, Aura aura, SpellInfo procSpell, ProcFlags procFlag, ProcFlagsExLegacy procExtra, WeaponAttackType attType, bool isVictim, bool active, SpellProcEventEntry spellProcEvent) + bool IsTriggeredAtSpellProcEvent(Unit victim, Aura aura, SpellInfo procSpell, ProcFlags procFlag, ProcFlagsExLegacy procExtra, WeaponAttackType attType, bool isVictim, bool active, ref SpellProcEventEntry spellProcEvent) { SpellInfo spellInfo = aura.GetSpellInfo(); diff --git a/Game/Garrisons/GarrisonManager.cs b/Game/Garrisons/GarrisonManager.cs index 1cee58371..d58e5e605 100644 --- a/Game/Garrisons/GarrisonManager.cs +++ b/Game/Garrisons/GarrisonManager.cs @@ -269,7 +269,7 @@ namespace Game.Garrisons } List genericTraits = genericTraitsTemp.Except(forcedTraits).ToList(); - genericTraits.AddRange(genericTraits); + genericTraits.AddRange(traitList); genericTraits.Sort((GarrAbilityRecord a1, GarrAbilityRecord a2) => { int e1 = (int)(a1.Flags & GarrisonAbilityFlags.Exclusive); diff --git a/Game/Garrisons/GarrisonMap.cs b/Game/Garrisons/GarrisonMap.cs index 009195f64..c73e61b2a 100644 --- a/Game/Garrisons/GarrisonMap.cs +++ b/Game/Garrisons/GarrisonMap.cs @@ -34,7 +34,7 @@ namespace Game.Garrisons public override void LoadGridObjects(Grid grid, Cell cell) { - LoadGridObjects(grid, cell); + base.LoadGridObjects(grid, cell); GarrisonGridLoader loader = new GarrisonGridLoader(grid, this, cell); loader.LoadN(); diff --git a/Game/Loot/Loot.cs b/Game/Loot/Loot.cs index ea91f16ff..9096bc63d 100644 --- a/Game/Loot/Loot.cs +++ b/Game/Loot/Loot.cs @@ -184,7 +184,7 @@ namespace Game.Loots if (_difficultyBonusTreeMod != 0) { List bonusListIDs = Global.DB2Mgr.GetItemBonusTree(generatedLoot.itemid, _difficultyBonusTreeMod); - generatedLoot.BonusListIDs.AddRange(generatedLoot.BonusListIDs); + generatedLoot.BonusListIDs.AddRange(bonusListIDs); } lootItems.Add(generatedLoot); count -= proto.GetMaxStackSize(); @@ -767,7 +767,7 @@ namespace Game.Loots if (!fi.is_looted && !item.is_looted) { LootItemData lootItem = new LootItemData(); - lootItem.LootListID = (byte)(items.Count + fi.index + 1); + lootItem.LootListID = (byte)(fi.index + 1); lootItem.UIType = slotType; lootItem.Quantity = item.count; lootItem.Loot = new ItemInstance(item); @@ -786,7 +786,7 @@ namespace Game.Loots if (!ci.is_looted && !item.is_looted) { LootItemData lootItem = new LootItemData(); - lootItem.LootListID = (byte)(items.Count + ci.index + 1); + lootItem.LootListID = (byte)(ci.index + 1); lootItem.Quantity = item.count; lootItem.Loot = new ItemInstance(item); diff --git a/Game/Maps/Cell.cs b/Game/Maps/Cell.cs index 992e88200..e4065949d 100644 --- a/Game/Maps/Cell.cs +++ b/Game/Maps/Cell.cs @@ -302,7 +302,7 @@ namespace Game.Maps high_bound = high; } - void ResizeBorders(ICoord begin_cell, ICoord end_cell) + void ResizeBorders(ref ICoord begin_cell, ref ICoord end_cell) { begin_cell = low_bound; end_cell = high_bound; diff --git a/Game/Maps/Map.cs b/Game/Maps/Map.cs index 55f8a038f..5cec3134c 100644 --- a/Game/Maps/Map.cs +++ b/Game/Maps/Map.cs @@ -3792,7 +3792,7 @@ namespace Game.Maps if (unit) { // Target must be GameObject. - if (target != null) + if (target == null) { Log.outError(LogFilter.Scripts, "{0} target object is NULL.", step.script.GetDebugInfo()); break; diff --git a/Game/Spells/Spell.cs b/Game/Spells/Spell.cs index fb3427754..c7a48c7e8 100644 --- a/Game/Spells/Spell.cs +++ b/Game/Spells/Spell.cs @@ -4930,7 +4930,7 @@ namespace Game.Spells int skillValue = 0; // check lock compatibility - SpellCastResult res = CanOpenLock(effect.EffectIndex, lockId, skillId, ref reqSkillValue, ref skillValue); + SpellCastResult res = CanOpenLock(effect.EffectIndex, lockId, ref skillId, ref reqSkillValue, ref skillValue); if (res != SpellCastResult.SpellCastOk) return res; break; @@ -6541,7 +6541,7 @@ namespace Game.Spells modOwner.SetSpellModTakingSpell(this, false); } - SpellCastResult CanOpenLock(uint effIndex, uint lockId, SkillType skillId, ref int reqSkillValue, ref int skillValue) + SpellCastResult CanOpenLock(uint effIndex, uint lockId, ref SkillType skillId, ref int reqSkillValue, ref int skillValue) { if (lockId == 0) // possible case for GO and maybe for items. return SpellCastResult.SpellCastOk; diff --git a/Game/Spells/SpellEffects.cs b/Game/Spells/SpellEffects.cs index 719aa6917..102932d86 100644 --- a/Game/Spells/SpellEffects.cs +++ b/Game/Spells/SpellEffects.cs @@ -1579,7 +1579,7 @@ namespace Game.Spells int reqSkillValue = 0; int skillValue = 0; - SpellCastResult res = CanOpenLock(effIndex, lockId, skillId, ref reqSkillValue, ref skillValue); + SpellCastResult res = CanOpenLock(effIndex, lockId, ref skillId, ref reqSkillValue, ref skillValue); if (res != SpellCastResult.SpellCastOk) { SendCastResult(res); diff --git a/Game/Spells/SpellInfo.cs b/Game/Spells/SpellInfo.cs index f07a90802..57a3e5058 100644 --- a/Game/Spells/SpellInfo.cs +++ b/Game/Spells/SpellInfo.cs @@ -91,7 +91,7 @@ namespace Game.Spells _visuals = visuals; // sort all visuals so that the ones without a condition requirement are last on the list foreach (var key in _visuals.Keys) - _visuals[key].OrderByDescending(x => x.PlayerConditionID); + _visuals[key] = _visuals[key].OrderByDescending(x => x.PlayerConditionID).ToList(); // SpellScalingEntry SpellScalingRecord _scaling = data.Scaling; diff --git a/Scripts/Northrend/IcecrownCitadel/GunshipBattle.cs b/Scripts/Northrend/IcecrownCitadel/GunshipBattle.cs index bf27a09cf..1a6a6810e 100644 --- a/Scripts/Northrend/IcecrownCitadel/GunshipBattle.cs +++ b/Scripts/Northrend/IcecrownCitadel/GunshipBattle.cs @@ -368,7 +368,7 @@ namespace Scripts.Northrend.IcecrownCitadel public SlotInfo(uint _entry, float x, float y, float z, float o, uint _cooldown) { Entry = _entry; - TargetPosition = new Position(x, y, z); + TargetPosition = new Position(x, y, z, o); Cooldown = _cooldown; } public SlotInfo(uint _entry, Position pos, uint _cooldown) diff --git a/Scripts/Northrend/IcecrownCitadel/IcecrownCitadelTeleport.cs b/Scripts/Northrend/IcecrownCitadel/IcecrownCitadelTeleport.cs index c1ff34777..09c128fbb 100644 --- a/Scripts/Northrend/IcecrownCitadel/IcecrownCitadelTeleport.cs +++ b/Scripts/Northrend/IcecrownCitadel/IcecrownCitadelTeleport.cs @@ -85,7 +85,7 @@ namespace Scripts.Northrend.IcecrownCitadel if (player.IsInCombat()) { SpellInfo spell = Global.SpellMgr.GetSpellInfo(TeleporterSpells.FROZEN_THRONE_TELEPORT); - if (spell == null) + if (spell != null) { ObjectGuid castId = ObjectGuid.Create(HighGuid.Cast, SpellCastSource.Normal, player.GetMapId(), spell.Id, player.GetMap().GenerateLowGuid(HighGuid.Cast)); Spell.SendCastResult(player, spell, 0, castId, SpellCastResult.AffectingCombat); diff --git a/Scripts/Spells/Druid.cs b/Scripts/Spells/Druid.cs index 6935091df..c3c594b88 100644 --- a/Scripts/Spells/Druid.cs +++ b/Scripts/Spells/Druid.cs @@ -1147,7 +1147,8 @@ namespace Scripts.Spells.Druid void SetTargets(List targets) { - targets = _targets; + targets.Clear(); + targets .AddRange(_targets); } public override void Register()