From ff4769df1a2a79199c2e1ddf4d826ae80ddf4a0b Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 29 Feb 2024 17:11:17 -0500 Subject: [PATCH] Core/Movement: require a minimum wander_distance value of 0.1 and check the path length of generated random movement this serves as a means to reduce the console spam caused by failed spline validation Port From (https://github.com/TrinityCore/TrinityCore/commit/fb3e6737da7795be651d36ce7493c07c7ecbdfeb) --- Source/Game/Globals/ObjectManager.cs | 5 +++++ .../Movement/Generators/RandomMovementGenerator.cs | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/Game/Globals/ObjectManager.cs b/Source/Game/Globals/ObjectManager.cs index f993feebd..808abb1a5 100644 --- a/Source/Game/Globals/ObjectManager.cs +++ b/Source/Game/Globals/ObjectManager.cs @@ -3545,6 +3545,11 @@ namespace Game Log.outError(LogFilter.Sql, "Table `creature` have creature (GUID: {0} Entry: {1}) with `wander_distance`< 0, set to 0.", guid, data.Id); data.WanderDistance = 0.0f; } + else if (data.WanderDistance > 0.0f && data.WanderDistance < 0.1f) + { + Log.outError(LogFilter.Sql, $"Table `creature` has creature (GUID: {guid} Entry: {data.Id}) with `wander_distance` below the allowed minimum distance of 0.1, set to 0."); + data.WanderDistance = 0.0f; + } else if (data.movementType == (byte)MovementGeneratorType.Random) { if (MathFunctions.fuzzyEq(data.WanderDistance, 0.0f)) diff --git a/Source/Game/Movement/Generators/RandomMovementGenerator.cs b/Source/Game/Movement/Generators/RandomMovementGenerator.cs index 0794ab4b0..5b2368357 100644 --- a/Source/Game/Movement/Generators/RandomMovementGenerator.cs +++ b/Source/Game/Movement/Generators/RandomMovementGenerator.cs @@ -153,8 +153,8 @@ namespace Game.Movement } Position position = new(_reference); - float distance = RandomHelper.FRand(0.0f, _wanderDistance); - float angle = RandomHelper.FRand(0.0f, MathF.PI * 2.0f); + float distance = _wanderDistance > 0.1f ? RandomHelper.FRand(0.1f, _wanderDistance) : _wanderDistance; + float angle = RandomHelper.FRand(0.0f, MathF.PI * 2); owner.MovePositionToFirstCollision(position, distance, angle); // Check if the destination is in LOS @@ -179,6 +179,13 @@ namespace Game.Movement return; } + if (_path.GetPathLength() < 0.1f) + { + // the path is too short for the spline system to be accepted. Let's try again soon. + _timer.Reset(500); + return; + } + RemoveFlag(MovementGeneratorFlags.Transitory | MovementGeneratorFlags.TimedPaused); owner.AddUnitState(UnitState.RoamingMove);