From 0df2703eab7e6bacc55097708faa7f0b90adfc6e Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 5 Nov 2017 15:48:55 -0500 Subject: [PATCH] Cleanup errors and misc fixes --- Source/Game/AI/SmartScripts/SmartScript.cs | 10 +----- Source/Game/Chat/Commands/AccountCommands.cs | 2 +- Source/Game/Conditions/ConditionManager.cs | 32 ++++++++------------ 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 325b7c80f..ba91098d1 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -3638,7 +3638,7 @@ namespace Game.AI if (scene != null) Log.outDebug(LogFilter.ScriptsAi, "SmartScript: EventMap for SceneId {0} is empty but is using SmartScript.", scene.SceneId); if (spell != null) - Log.outDebug(LogFilter.ScriptsAi, "SmartScript: EventMap for SceneId {0} is empty but is using SmartScript.", scene.SceneId); + Log.outDebug(LogFilter.ScriptsAi, "SmartScript: EventMap for SpellId {0} is empty but is using SmartScript.", spell.GetSpellInfo().Id); return; } foreach (var holder in e) @@ -3656,14 +3656,6 @@ namespace Game.AI } mEvents.Add(holder);//NOTE: 'world(0)' events still get processed in ANY instance mode } - if (mEvents.Empty() && obj != null) - Log.outError(LogFilter.Sql, "SmartScript: Entry {0} has events but no events added to list because of instance flags.", obj.GetEntry()); - if (mEvents.Empty() && at != null) - Log.outError(LogFilter.Sql, "SmartScript: AreaTrigger {0} has events but no events added to list because of instance flags. NOTE: triggers can not handle any instance flags.", at.Id); - if (mEvents.Empty() && scene != null) - Log.outError(LogFilter.Sql, "SmartScript: SceneId {0} has events but no events added to list because of instance flags. NOTE: scenes can not handle any instance flags.", scene.SceneId); - if (mEvents.Empty() && spell != null) - Log.outError(LogFilter.Sql, "SmartScript: Spell {0} has events but no events added to list because of instance flags. NOTE: scenes can not handle any instance flags.", spell.GetSpellInfo().Id); } void GetScript() diff --git a/Source/Game/Chat/Commands/AccountCommands.cs b/Source/Game/Chat/Commands/AccountCommands.cs index a14706af2..77856271e 100644 --- a/Source/Game/Chat/Commands/AccountCommands.cs +++ b/Source/Game/Chat/Commands/AccountCommands.cs @@ -561,7 +561,7 @@ namespace Game.Chat // command.getSession() == NULL only for console targetAccountId = (isAccountNameGiven) ? Global.AccountMgr.GetId(targetAccountName) : handler.getSelectedPlayer().GetSession().GetAccountId(); - if (int.TryParse(isAccountNameGiven ? arg3 : arg2, out int gmRealmID)) + if (!int.TryParse(isAccountNameGiven ? arg3 : arg2, out int gmRealmID)) return false; AccountTypes playerSecurity; diff --git a/Source/Game/Conditions/ConditionManager.cs b/Source/Game/Conditions/ConditionManager.cs index ce3c810cc..b940dc331 100644 --- a/Source/Game/Conditions/ConditionManager.cs +++ b/Source/Game/Conditions/ConditionManager.cs @@ -725,12 +725,6 @@ namespace Game bool isSourceTypeValid(Condition cond) { - if (cond.SourceType == ConditionSourceType.None || cond.SourceType >= ConditionSourceType.Max) - { - Log.outError(LogFilter.Sql, "{0} Invalid ConditionSourceType in `condition` table, ignoring.", cond.ToString()); - return false; - } - switch (cond.SourceType) { case ConditionSourceType.CreatureLootTemplate: @@ -1079,8 +1073,9 @@ namespace Game case ConditionSourceType.GossipMenu: case ConditionSourceType.GossipMenuOption: case ConditionSourceType.SmartEvent: - case ConditionSourceType.None: + break; default: + Log.outError(LogFilter.Sql, $"{cond.ToString()} Invalid ConditionSourceType in `condition` table, ignoring."); break; } @@ -1089,18 +1084,6 @@ namespace Game bool isConditionTypeValid(Condition cond) { - if (cond.ConditionType == ConditionTypes.None || cond.ConditionType >= ConditionTypes.Max) - { - Log.outError(LogFilter.Sql, "{0} Invalid ConditionType in `condition` table, ignoring.", cond.ToString()); - return false; - } - - if (cond.ConditionTarget >= cond.GetMaxAvailableConditionTargets()) - { - Log.outError(LogFilter.Sql, "{0} in `condition` table, has incorrect ConditionTarget set, ignoring.", cond.ToString()); - return false; - } - switch (cond.ConditionType) { case ConditionTypes.Aura: @@ -1584,11 +1567,20 @@ namespace Game case ConditionTypes.Alive: case ConditionTypes.Areaid: case ConditionTypes.InstanceInfo: + case ConditionTypes.TerrainSwap: case ConditionTypes.InWater: case ConditionTypes.Charmed: case ConditionTypes.Taxi: - default: break; + default: + Log.outError(LogFilter.Sql, $"{cond.ToString()} Invalid ConditionType in `condition` table, ignoring."); + return false; + } + + if (cond.ConditionTarget >= cond.GetMaxAvailableConditionTargets()) + { + Log.outError(LogFilter.Sql, $"{cond.ToString(true)} in `condition` table, has incorrect ConditionTarget set, ignoring."); + return false; } if (cond.ConditionValue1 != 0 && !StaticConditionTypeData[(int)cond.ConditionType].HasConditionValue1)