master
Christopher Latza 2020-06-19 20:10:23 +02:00
parent f74b953983
commit 182e7c7234
1 changed files with 141 additions and 105 deletions

View File

@ -122,6 +122,7 @@ namespace OpenSim.Modules.PathFinding
m_scriptModule.RegisterConstant("PATH_ENV_ERR_NOT_FOUND", 19851);
m_scriptModule.RegisterConstant("PATH_ENV_ERR_OUT_OF_RANGE", 19852);
m_scriptModule.RegisterConstant("PATH_ENV_ERR_NOT_IN_LINE", 19853);
m_scriptModule.RegisterConstant("PATH_ENV_ERR_UNKNOWN", 19860);
}
catch (Exception e)
{
@ -143,23 +144,32 @@ namespace OpenSim.Modules.PathFinding
#region Asyn Funktions
private void generatePathEnvironment(ScriptRequestData requestData)
{
try
{
UUID _envID = UUID.Random();
Environment _newEnv = new Environment(_envID.ToString(), (int)m_scene.RegionInfo.RegionSizeX);
lock(m_environments)
lock (m_environments)
{
m_environments.Add(_newEnv);
}
m_scriptModule.DispatchReply(requestData.ScriptID, 19850, _envID.ToString(), requestData.RequestID.ToString());
}
catch(Exception _error)
{
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
}
}
private void keepAlivePathEnv(ScriptRequestData requestData)
{
try
{
Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID);
if(_env != null)
if (_env != null)
{
_env.LastTimeUsed = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
m_scriptModule.DispatchReply(requestData.ScriptID, 19850, "", requestData.RequestID.ToString());
@ -168,8 +178,15 @@ namespace OpenSim.Modules.PathFinding
m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString());
}
catch (Exception _error)
{
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
}
}
private void removeAllTargets(ScriptRequestData requestData)
{
try
{
Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID);
@ -177,14 +194,21 @@ namespace OpenSim.Modules.PathFinding
{
List<PathNode> _nodes = _env.Nodes.FindAll(X => X.Target == true);
foreach(PathNode thisNode in _nodes)
foreach (PathNode thisNode in _nodes)
{
thisNode.Target = false;
}
}
}
catch (Exception _error)
{
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
}
}
private void setPositionData(ScriptRequestData requestData, Vector3 position, int walkable, int isTarget)
{
try
{
Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID);
@ -218,8 +242,15 @@ namespace OpenSim.Modules.PathFinding
m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString());
}
catch (Exception _error)
{
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
}
}
private void setLineData(ScriptRequestData requestData, Vector3 start, Vector3 target, int walkable)
{
try
{
Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID);
@ -238,7 +269,7 @@ namespace OpenSim.Modules.PathFinding
if ((int)start.X != (int)target.X)
{
if((int)start.X < (int)target.X)
if ((int)start.X < (int)target.X)
{
_PointA = start;
_PointB = target;
@ -289,6 +320,11 @@ namespace OpenSim.Modules.PathFinding
m_scriptModule.DispatchReply(requestData.ScriptID, 19853, "", requestData.RequestID.ToString());
}
catch (Exception _error)
{
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
}
}
private void generatePath(ScriptRequestData requestData)
{