From ea2ea83ee9b47aa742ce2906f816b69d82d8bf4c Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 17 Feb 2022 13:23:27 -0500 Subject: [PATCH] Core/Movement: Improve log when starting a spline with invalid arguments Port From (https://github.com/TrinityCore/TrinityCore/commit/040af829ca7d1148a99c3ac03a3383c58af9e23c) --- Source/Game/Movement/MoveSplineInitArgs.cs | 27 +++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/Source/Game/Movement/MoveSplineInitArgs.cs b/Source/Game/Movement/MoveSplineInitArgs.cs index 5e956f265..b6c87a7b7 100644 --- a/Source/Game/Movement/MoveSplineInitArgs.cs +++ b/Source/Game/Movement/MoveSplineInitArgs.cs @@ -16,6 +16,7 @@ */ using Framework.Dynamic; +using Game.DataStorage; using Game.Entities; using System.Collections.Generic; using System.Numerics; @@ -55,24 +56,38 @@ namespace Game.Movement // Returns true to show that the arguments were configured correctly and MoveSpline initialization will succeed. public bool Validate(Unit unit) { - bool CHECK(bool exp) + bool CHECK(bool exp, bool verbose) { if (!exp) { - Log.outError(LogFilter.Misc, "MoveSplineInitArgs::Validate: expression '{0}' failed for {1} Entry: {2}", exp.ToString(), unit.GetGUID().ToString(), unit.GetEntry()); + if (unit) + Log.outError(LogFilter.Movement, $"MoveSplineInitArgs::Validate: expression '{exp}' failed for {(verbose ? unit.GetDebugInfo() : unit.GetGUID().ToString())}"); + else + Log.outError(LogFilter.Movement, $"MoveSplineInitArgs::Validate: expression '{exp}' failed for cyclic spline continuation"); return false; } return true; } - if (!CHECK(path.Count > 1)) + if (!CHECK(path.Count > 1, true)) return false; - if (!CHECK(velocity >= 0.01f)) + if (!CHECK(velocity >= 0.01f, true)) return false; - if (!CHECK(time_perc >= 0.0f && time_perc <= 1.0f)) + if (!CHECK(time_perc >= 0.0f && time_perc <= 1.0f, true)) return false; - if (!CHECK(_checkPathLengths())) + if (!CHECK(_checkPathLengths(), false)) return false; + if (spellEffectExtra.HasValue) + { + if (!CHECK(spellEffectExtra.Value.ProgressCurveId == 0 || CliDB.CurveStorage.ContainsKey(spellEffectExtra.Value.ProgressCurveId), false)) + return false; + if (!CHECK(spellEffectExtra.Value.ParabolicCurveId == 0 || CliDB.CurveStorage.ContainsKey(spellEffectExtra.Value.ParabolicCurveId), false)) + return false; + if (!CHECK(spellEffectExtra.Value.ProgressCurveId == 0 || CliDB.CurveStorage.ContainsKey(spellEffectExtra.Value.ProgressCurveId), true)) + return false; + if (!CHECK(spellEffectExtra.Value.ParabolicCurveId == 0 || CliDB.CurveStorage.ContainsKey(spellEffectExtra.Value.ParabolicCurveId), true)) + return false; + } return true; }