Fixed some errors from analyzer

This commit is contained in:
hondacrx
2017-06-22 17:02:27 -04:00
parent 0e40e90a11
commit d538acc979
26 changed files with 38 additions and 46 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ namespace Framework.Configuration
foreach (var line in ConfigContent) foreach (var line in ConfigContent)
{ {
lineCounter++; lineCounter++;
if (line.StartsWith("#") || line.StartsWith("-") || string.IsNullOrEmpty(line)) if (string.IsNullOrEmpty(line) || line.StartsWith("#") || line.StartsWith("-"))
continue; continue;
var configOption = new StringArray(line, '='); var configOption = new StringArray(line, '=');
-2
View File
@@ -50,8 +50,6 @@ namespace Framework.Cryptography
public void Initialize(byte[] sessionKey, byte[] serverSeed, byte[] clientSeed) public void Initialize(byte[] sessionKey, byte[] serverSeed, byte[] clientSeed)
{ {
IsInitialized = false;
if (IsInitialized) if (IsInitialized)
throw new InvalidOperationException("PacketCrypt already initialized!"); throw new InvalidOperationException("PacketCrypt already initialized!");
+1 -1
View File
@@ -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); Log.outInfo(LogFilter.ServerLoading, "Database \"{0}\" does not exist, do you want to create it? [yes (default) / no]: ", name);
string answer = Console.ReadLine(); string answer = Console.ReadLine();
if (string.IsNullOrEmpty(answer) && answer[0] != 'y') if (string.IsNullOrEmpty(answer) || answer[0] != 'y')
return false; return false;
Log.outInfo(LogFilter.ServerLoading, "Creating database \"{0}\"...", name); Log.outInfo(LogFilter.ServerLoading, "Creating database \"{0}\"...", name);
+1 -2
View File
@@ -482,8 +482,7 @@ namespace Framework.Dynamic
public void ModifyIf(Func<Task, bool> filter) public void ModifyIf(Func<Task, bool> filter)
{ {
List<Task> cache = new List<Task>(); List<Task> cache = new List<Task>();
container.Where(filter); foreach (var task in container.Where(filter))
foreach (var task in container.ToList())
{ {
if (filter(task)) if (filter(task))
{ {
+5 -5
View File
@@ -131,12 +131,12 @@ namespace Framework.GameMath
vertices[0] = _lo; vertices[0] = _lo;
vertices[1] = new Vector3(_hi.X, _lo.Y, _lo.Z); vertices[1] = new Vector3(_hi.X, _lo.Y, _lo.Z);
vertices[2] = new Vector3(_hi.X, _hi.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[4] = new Vector3(_lo.X, _lo.Y, _hi.Z);
vertices[6] = new Vector3(_hi.X, _lo.Y, _hi.Z); vertices[5] = new Vector3(_hi.X, _lo.Y, _hi.Z);
vertices[7] = _hi; vertices[6] = _hi;
vertices[8] = new Vector3(_lo.X, _hi.Y, _hi.Z); vertices[7] = new Vector3(_lo.X, _hi.Y, _hi.Z);
return vertices; return vertices;
} }
+1 -1
View File
@@ -26,7 +26,7 @@ public class Realm : IEquatable<Realm>
{ {
Name = name; Name = name;
NormalizedName = name; NormalizedName = name;
NormalizedName.Replace(" ", ""); NormalizedName = NormalizedName.Replace(" ", "");
} }
public IPEndPoint GetAddressForClient(IPAddress clientAddr) public IPEndPoint GetAddressForClient(IPAddress clientAddr)
+2 -2
View File
@@ -162,8 +162,8 @@ namespace Game.Arenas
if (winner != 0) if (winner != 0)
{ {
winnerMatchmakerChange = winnerArenaTeam.WonAgainst(winnerMatchmakerRating, loserMatchmakerRating, winnerChange); winnerMatchmakerChange = winnerArenaTeam.WonAgainst(winnerMatchmakerRating, loserMatchmakerRating, ref winnerChange);
loserMatchmakerChange = loserArenaTeam.LostAgainst(loserMatchmakerRating, winnerMatchmakerRating, loserChange); 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}, " + 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, "rating loss: {6}, old MMR: {7}, MMR loss: {8} ---", GetArenaType(), winnerTeamRating, winnerChange, winnerMatchmakerRating, winnerMatchmakerChange,
+2 -2
View File
@@ -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 // Called when the team has won
// Change in Matchmaker rating // Change in Matchmaker rating
@@ -608,7 +608,7 @@ namespace Game.Arenas
return mod; 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 // Called when the team has lost
// Change in Matchmaker Rating // Change in Matchmaker Rating
+5 -5
View File
@@ -27,7 +27,7 @@ namespace Game.Chat.Commands
[Command("god", RBACPermissions.CommandCheatGod)] [Command("god", RBACPermissions.CommandCheatGod)]
static bool HandleGodModeCheat(StringArguments args, CommandHandler handler) static bool HandleGodModeCheat(StringArguments args, CommandHandler handler)
{ {
if (handler.GetSession() == null && handler.GetSession().GetPlayer()) if (handler.GetSession() == null || handler.GetSession().GetPlayer())
return false; return false;
string argstr = args.NextString(); string argstr = args.NextString();
@@ -53,7 +53,7 @@ namespace Game.Chat.Commands
[Command("casttime", RBACPermissions.CommandCheatCasttime)] [Command("casttime", RBACPermissions.CommandCheatCasttime)]
static bool HandleCasttimeCheat(StringArguments args, CommandHandler handler) static bool HandleCasttimeCheat(StringArguments args, CommandHandler handler)
{ {
if (handler.GetSession() == null && handler.GetSession().GetPlayer()) if (handler.GetSession() == null || handler.GetSession().GetPlayer())
return false; return false;
string argstr = args.NextString(); string argstr = args.NextString();
@@ -80,7 +80,7 @@ namespace Game.Chat.Commands
[Command("cooldown", RBACPermissions.CommandCheatCooldown)] [Command("cooldown", RBACPermissions.CommandCheatCooldown)]
static bool HandleCoolDownCheat(StringArguments args, CommandHandler handler) static bool HandleCoolDownCheat(StringArguments args, CommandHandler handler)
{ {
if (handler.GetSession() == null && handler.GetSession().GetPlayer()) if (handler.GetSession() == null || handler.GetSession().GetPlayer())
return false; return false;
string argstr = args.NextString(); string argstr = args.NextString();
@@ -107,7 +107,7 @@ namespace Game.Chat.Commands
[Command("power", RBACPermissions.CommandCheatPower)] [Command("power", RBACPermissions.CommandCheatPower)]
static bool HandlePowerCheat(StringArguments args, CommandHandler handler) static bool HandlePowerCheat(StringArguments args, CommandHandler handler)
{ {
if (handler.GetSession() == null && handler.GetSession().GetPlayer()) if (handler.GetSession() == null || handler.GetSession().GetPlayer())
return false; return false;
string argstr = args.NextString(); string argstr = args.NextString();
@@ -152,7 +152,7 @@ namespace Game.Chat.Commands
[Command("waterwalk", RBACPermissions.CommandCheatWaterwalk)] [Command("waterwalk", RBACPermissions.CommandCheatWaterwalk)]
static bool HandleWaterWalkCheat(StringArguments args, CommandHandler handler) static bool HandleWaterWalkCheat(StringArguments args, CommandHandler handler)
{ {
if (handler.GetSession() == null && handler.GetSession().GetPlayer()) if (handler.GetSession() == null || handler.GetSession().GetPlayer())
return false; return false;
string argstr = args.NextString(); string argstr = args.NextString();
+1 -1
View File
@@ -227,7 +227,7 @@ namespace Game.Collision
} }
static uint packTileID(uint tileX, uint tileY) { return tileX << 16 | tileY; } 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) public static bool CanLoadMap(string vmapPath, uint mapID, uint tileX, uint tileY)
{ {
string fullname = vmapPath + VMapManager.getMapFileName(mapID); string fullname = vmapPath + VMapManager.getMapFileName(mapID);
-3
View File
@@ -612,9 +612,6 @@ namespace Game.DataStorage
return 0.0f; return 0.0f;
CurveRecord curve = CliDB.CurveStorage.LookupByKey(curveId); CurveRecord curve = CliDB.CurveStorage.LookupByKey(curveId);
if (points.Empty())
return 0.0f;
switch (DetermineCurveType(curve, points)) switch (DetermineCurveType(curve, points))
{ {
case CurveInterpolationMode.Linear: case CurveInterpolationMode.Linear:
+1 -1
View File
@@ -705,7 +705,7 @@ namespace Game.Entities
public void SetState(ItemUpdateState state, Player forplayer = null) 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 // pretend the item never existed
if (forplayer) if (forplayer)
+1 -1
View File
@@ -192,7 +192,7 @@ namespace Game.Entities
float avgDamage = dps * GetDelay() * 0.001f; float avgDamage = dps * GetDelay() * 0.001f;
minDamage = (GetStatScalingFactor() * -0.5f + 1.0f) * avgDamage; 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) public bool IsUsableByLootSpecialization(Player player)
-3
View File
@@ -164,9 +164,6 @@ namespace Game.Entities
if (eventList.Empty()) if (eventList.Empty())
return; return;
if (eventList.Empty())
return;
foreach (uint questId in eventList) foreach (uint questId in eventList)
{ {
uint questBit = Global.DB2Mgr.GetQuestUniqueBitFlag(questId); uint questBit = Global.DB2Mgr.GetQuestUniqueBitFlag(questId);
+2 -2
View File
@@ -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; continue;
// do checks using conditions table // 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(); SpellInfo spellInfo = aura.GetSpellInfo();
+1 -1
View File
@@ -269,7 +269,7 @@ namespace Game.Garrisons
} }
List<GarrAbilityRecord> genericTraits = genericTraitsTemp.Except(forcedTraits).ToList(); List<GarrAbilityRecord> genericTraits = genericTraitsTemp.Except(forcedTraits).ToList();
genericTraits.AddRange(genericTraits); genericTraits.AddRange(traitList);
genericTraits.Sort((GarrAbilityRecord a1, GarrAbilityRecord a2) => genericTraits.Sort((GarrAbilityRecord a1, GarrAbilityRecord a2) =>
{ {
int e1 = (int)(a1.Flags & GarrisonAbilityFlags.Exclusive); int e1 = (int)(a1.Flags & GarrisonAbilityFlags.Exclusive);
+1 -1
View File
@@ -34,7 +34,7 @@ namespace Game.Garrisons
public override void LoadGridObjects(Grid grid, Cell cell) public override void LoadGridObjects(Grid grid, Cell cell)
{ {
LoadGridObjects(grid, cell); base.LoadGridObjects(grid, cell);
GarrisonGridLoader loader = new GarrisonGridLoader(grid, this, cell); GarrisonGridLoader loader = new GarrisonGridLoader(grid, this, cell);
loader.LoadN(); loader.LoadN();
+3 -3
View File
@@ -184,7 +184,7 @@ namespace Game.Loots
if (_difficultyBonusTreeMod != 0) if (_difficultyBonusTreeMod != 0)
{ {
List<uint> bonusListIDs = Global.DB2Mgr.GetItemBonusTree(generatedLoot.itemid, _difficultyBonusTreeMod); List<uint> bonusListIDs = Global.DB2Mgr.GetItemBonusTree(generatedLoot.itemid, _difficultyBonusTreeMod);
generatedLoot.BonusListIDs.AddRange(generatedLoot.BonusListIDs); generatedLoot.BonusListIDs.AddRange(bonusListIDs);
} }
lootItems.Add(generatedLoot); lootItems.Add(generatedLoot);
count -= proto.GetMaxStackSize(); count -= proto.GetMaxStackSize();
@@ -767,7 +767,7 @@ namespace Game.Loots
if (!fi.is_looted && !item.is_looted) if (!fi.is_looted && !item.is_looted)
{ {
LootItemData lootItem = new LootItemData(); LootItemData lootItem = new LootItemData();
lootItem.LootListID = (byte)(items.Count + fi.index + 1); lootItem.LootListID = (byte)(fi.index + 1);
lootItem.UIType = slotType; lootItem.UIType = slotType;
lootItem.Quantity = item.count; lootItem.Quantity = item.count;
lootItem.Loot = new ItemInstance(item); lootItem.Loot = new ItemInstance(item);
@@ -786,7 +786,7 @@ namespace Game.Loots
if (!ci.is_looted && !item.is_looted) if (!ci.is_looted && !item.is_looted)
{ {
LootItemData lootItem = new LootItemData(); LootItemData lootItem = new LootItemData();
lootItem.LootListID = (byte)(items.Count + ci.index + 1); lootItem.LootListID = (byte)(ci.index + 1);
lootItem.Quantity = item.count; lootItem.Quantity = item.count;
lootItem.Loot = new ItemInstance(item); lootItem.Loot = new ItemInstance(item);
+1 -1
View File
@@ -302,7 +302,7 @@ namespace Game.Maps
high_bound = high; 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; begin_cell = low_bound;
end_cell = high_bound; end_cell = high_bound;
+1 -1
View File
@@ -3792,7 +3792,7 @@ namespace Game.Maps
if (unit) if (unit)
{ {
// Target must be GameObject. // Target must be GameObject.
if (target != null) if (target == null)
{ {
Log.outError(LogFilter.Scripts, "{0} target object is NULL.", step.script.GetDebugInfo()); Log.outError(LogFilter.Scripts, "{0} target object is NULL.", step.script.GetDebugInfo());
break; break;
+2 -2
View File
@@ -4930,7 +4930,7 @@ namespace Game.Spells
int skillValue = 0; int skillValue = 0;
// check lock compatibility // 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) if (res != SpellCastResult.SpellCastOk)
return res; return res;
break; break;
@@ -6541,7 +6541,7 @@ namespace Game.Spells
modOwner.SetSpellModTakingSpell(this, false); 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. if (lockId == 0) // possible case for GO and maybe for items.
return SpellCastResult.SpellCastOk; return SpellCastResult.SpellCastOk;
+1 -1
View File
@@ -1579,7 +1579,7 @@ namespace Game.Spells
int reqSkillValue = 0; int reqSkillValue = 0;
int skillValue = 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) if (res != SpellCastResult.SpellCastOk)
{ {
SendCastResult(res); SendCastResult(res);
+1 -1
View File
@@ -91,7 +91,7 @@ namespace Game.Spells
_visuals = visuals; _visuals = visuals;
// sort all visuals so that the ones without a condition requirement are last on the list // sort all visuals so that the ones without a condition requirement are last on the list
foreach (var key in _visuals.Keys) foreach (var key in _visuals.Keys)
_visuals[key].OrderByDescending(x => x.PlayerConditionID); _visuals[key] = _visuals[key].OrderByDescending(x => x.PlayerConditionID).ToList();
// SpellScalingEntry // SpellScalingEntry
SpellScalingRecord _scaling = data.Scaling; SpellScalingRecord _scaling = data.Scaling;
@@ -368,7 +368,7 @@ namespace Scripts.Northrend.IcecrownCitadel
public SlotInfo(uint _entry, float x, float y, float z, float o, uint _cooldown) public SlotInfo(uint _entry, float x, float y, float z, float o, uint _cooldown)
{ {
Entry = _entry; Entry = _entry;
TargetPosition = new Position(x, y, z); TargetPosition = new Position(x, y, z, o);
Cooldown = _cooldown; Cooldown = _cooldown;
} }
public SlotInfo(uint _entry, Position pos, uint _cooldown) public SlotInfo(uint _entry, Position pos, uint _cooldown)
@@ -85,7 +85,7 @@ namespace Scripts.Northrend.IcecrownCitadel
if (player.IsInCombat()) if (player.IsInCombat())
{ {
SpellInfo spell = Global.SpellMgr.GetSpellInfo(TeleporterSpells.FROZEN_THRONE_TELEPORT); 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)); 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); Spell.SendCastResult(player, spell, 0, castId, SpellCastResult.AffectingCombat);
+2 -1
View File
@@ -1147,7 +1147,8 @@ namespace Scripts.Spells.Druid
void SetTargets(List<WorldObject> targets) void SetTargets(List<WorldObject> targets)
{ {
targets = _targets; targets.Clear();
targets .AddRange(_targets);
} }
public override void Register() public override void Register()