From a773c28a73a553f51dfcda33c8751b96e76d74c2 Mon Sep 17 00:00:00 2001 From: Christopher Date: Fri, 19 Jun 2020 12:45:28 +0200 Subject: [PATCH] try to fix line --- src/BasicPathFinding.cs | 67 +++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/src/BasicPathFinding.cs b/src/BasicPathFinding.cs index 9f242a5..acd584a 100644 --- a/src/BasicPathFinding.cs +++ b/src/BasicPathFinding.cs @@ -233,47 +233,48 @@ namespace OpenSim.Modules.PathFinding return; } + Vector3 _PointA = new Vector3(0, 0, 0); + Vector3 _PointB = new Vector3(0, 0, 0); + if ((int)start.X != (int)target.X) { - int difference = (int)start.X - (int)target.X; - - while (difference != 0) + if((int)start.X < (int)target.X) { - Vector3 _position = start; - if (difference < 0) - { - _position.X = _position.X - 1; - setPositionData(requestData, _position, walkable, 0); - difference++; - } - else - { - _position.X = _position.X + 1; - setPositionData(requestData, _position, walkable, 0); - difference--; - } + _PointA = start; + _PointB = target; + } + + if ((int)start.X > (int)target.X) + { + _PointA = target; + _PointB = start; + } + + while ((int)_PointA.X != _PointB.X) + { + setPositionData(requestData, _PointA, walkable, 0); + _PointA.X = (int)_PointA.X + 1; } } if ((int)start.Y != (int)target.Y) { - int difference = (int)start.Y - (int)target.Y; - - while (difference != 0) + if ((int)start.Y < (int)target.Y) { - Vector3 _position = start; - if (difference < 0) - { - _position.Y = _position.Y - 1; - setPositionData(requestData, _position, walkable, 0); - difference++; - } - else - { - _position.Y = _position.Y + 1; - setPositionData(requestData, _position, walkable, 0); - difference--; - } + _PointA = start; + _PointB = target; + } + + if ((int)start.Y > (int)target.Y) + { + _PointA = target; + _PointB = start; + } + + while ((int)_PointA.Y != _PointB.Y) + { + setPositionData(requestData, _PointA, walkable, 0); + _PointA.Y = (int)_PointA.Y + 1; } } @@ -327,7 +328,7 @@ namespace OpenSim.Modules.PathFinding #region Script Funktions [ScriptInvocation] - public string osGeneratePathEnv(UUID hostID, UUID scriptID, int size) + public string osGeneratePathEnv(UUID hostID, UUID scriptID) { UUID requestKey = UUID.Random();