master
Christopher Latza 2020-06-19 20:12:22 +02:00
parent 182e7c7234
commit c75eacd7d1
1 changed files with 91 additions and 79 deletions

View File

@ -171,9 +171,12 @@ namespace OpenSim.Modules.PathFinding
if (_env != null)
{
_env.LastTimeUsed = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
m_scriptModule.DispatchReply(requestData.ScriptID, 19850, "", requestData.RequestID.ToString());
return;
lock(_env)
{
_env.LastTimeUsed = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
m_scriptModule.DispatchReply(requestData.ScriptID, 19850, "", requestData.RequestID.ToString());
return;
}
}
m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString());
@ -192,11 +195,14 @@ namespace OpenSim.Modules.PathFinding
if (_env != null)
{
List<PathNode> _nodes = _env.Nodes.FindAll(X => X.Target == true);
foreach (PathNode thisNode in _nodes)
lock(_env)
{
thisNode.Target = false;
List<PathNode> _nodes = _env.Nodes.FindAll(X => X.Target == true);
foreach (PathNode thisNode in _nodes)
{
thisNode.Target = false;
}
}
}
}
@ -214,30 +220,33 @@ namespace OpenSim.Modules.PathFinding
if (_env != null)
{
if (isTarget == 1)
removeAllTargets(requestData);
PathNode _node = _env.Nodes.Find(X => X.PositionX == (int)position.X && X.PositionY == (int)position.Y);
if (_node == null)
lock(_env)
{
_node = new PathNode((int)position.X, (int)position.Y, false, false);
_env.Nodes.Add(_node);
if (isTarget == 1)
removeAllTargets(requestData);
PathNode _node = _env.Nodes.Find(X => X.PositionX == (int)position.X && X.PositionY == (int)position.Y);
if (_node == null)
{
_node = new PathNode((int)position.X, (int)position.Y, false, false);
_env.Nodes.Add(_node);
}
if (walkable == 1)
_node.Walkable = true;
if (walkable == 0)
_node.Walkable = false;
if (isTarget == 1)
_node.Target = true;
if (isTarget == 0)
_node.Target = false;
return;
}
if (walkable == 1)
_node.Walkable = true;
if (walkable == 0)
_node.Walkable = false;
if (isTarget == 1)
_node.Target = true;
if (isTarget == 0)
_node.Target = false;
return;
}
m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString());
@ -256,61 +265,64 @@ namespace OpenSim.Modules.PathFinding
if (_env != null)
{
if ((int)start.X == (int)target.X || (int)start.Y == (int)target.Y)
lock(_env)
{
if ((int)start.X == (int)target.X && (int)start.Y == (int)target.Y)
if ((int)start.X == (int)target.X || (int)start.Y == (int)target.Y)
{
if ((int)start.X == (int)target.X && (int)start.Y == (int)target.Y)
{
m_scriptModule.DispatchReply(requestData.ScriptID, 19850, "", requestData.RequestID.ToString());
return;
}
Vector3 _PointA = new Vector3(0, 0, 0);
Vector3 _PointB = new Vector3(0, 0, 0);
if ((int)start.X != (int)target.X)
{
if ((int)start.X < (int)target.X)
{
_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)
{
if ((int)start.Y < (int)target.Y)
{
_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;
}
}
m_scriptModule.DispatchReply(requestData.ScriptID, 19850, "", requestData.RequestID.ToString());
return;
}
Vector3 _PointA = new Vector3(0, 0, 0);
Vector3 _PointB = new Vector3(0, 0, 0);
if ((int)start.X != (int)target.X)
{
if ((int)start.X < (int)target.X)
{
_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)
{
if ((int)start.Y < (int)target.Y)
{
_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;
}
}
m_scriptModule.DispatchReply(requestData.ScriptID, 19850, "", requestData.RequestID.ToString());
return;
}
}
else