change use of lock

master
Christopher Latza 2020-06-19 20:44:56 +02:00
parent e3c230c2f8
commit 767e7c48b1
1 changed files with 66 additions and 66 deletions

View File

@ -144,40 +144,39 @@ namespace OpenSim.Modules.PathFinding
#region Asyn Funktions
private void generatePathEnvironment(ScriptRequestData requestData)
{
lock(m_environments)
{
try
{
UUID _envID = UUID.Random();
Environment _newEnv = new Environment(_envID.ToString(), (int)m_scene.RegionInfo.RegionSizeX);
lock (m_environments)
{
m_environments.Add(_newEnv);
}
m_scriptModule.DispatchReply(requestData.ScriptID, 19850, _envID.ToString(), requestData.RequestID.ToString());
}
catch(Exception _error)
catch (Exception _error)
{
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
}
}
}
private void keepAlivePathEnv(ScriptRequestData requestData)
{
lock (m_environments)
{
try
{
Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID);
if (_env != null)
{
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());
}
@ -186,16 +185,17 @@ namespace OpenSim.Modules.PathFinding
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
}
}
}
private void removeAllTargets(ScriptRequestData requestData)
{
lock(m_environments)
{
try
{
Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID);
if (_env != null)
{
lock(_env)
{
List<PathNode> _nodes = _env.Nodes.FindAll(X => X.Target == true);
@ -205,22 +205,22 @@ namespace OpenSim.Modules.PathFinding
}
}
}
}
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)
{
lock(m_environments)
{
try
{
Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID);
if (_env != null)
{
lock(_env)
{
if (isTarget == 1)
removeAllTargets(requestData);
@ -247,7 +247,6 @@ namespace OpenSim.Modules.PathFinding
return;
}
}
m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString());
}
@ -256,16 +255,17 @@ namespace OpenSim.Modules.PathFinding
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
}
}
}
private void setLineData(ScriptRequestData requestData, Vector3 start, Vector3 target, int walkable)
{
lock(m_environments)
{
try
{
Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID);
if (_env != null)
{
lock(_env)
{
if ((int)start.X == (int)target.X || (int)start.Y == (int)target.Y)
{
@ -328,7 +328,6 @@ namespace OpenSim.Modules.PathFinding
m_scriptModule.DispatchReply(requestData.ScriptID, 19853, "", requestData.RequestID.ToString());
}
}
}
else
{
m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString());
@ -339,6 +338,7 @@ namespace OpenSim.Modules.PathFinding
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
}
}
}
private void generatePath(ScriptRequestData requestData)
{
@ -346,14 +346,14 @@ namespace OpenSim.Modules.PathFinding
}
private void generateDebugImage(ScriptRequestData requestData)
{
lock(m_environments)
{
try
{
Environment _env = m_environments.Find(X => X.ID == requestData.EnvironmentID);
if (_env != null)
{
lock (_env)
{
Bitmap _bitmap = new Bitmap(_env.Size, _env.Size);
@ -370,10 +370,9 @@ namespace OpenSim.Modules.PathFinding
}
_bitmap.Save(requestData.EnvironmentID + ".png");
m_scriptModule.DispatchReply(requestData.ScriptID, 19850, "", requestData.RequestID.ToString());
m_scriptModule.DispatchReply(requestData.ScriptID, 19850, requestData.EnvironmentID + ".png", requestData.RequestID.ToString());
return;
}
}
m_scriptModule.DispatchReply(requestData.ScriptID, 19851, "", requestData.RequestID.ToString());
}
@ -382,6 +381,7 @@ namespace OpenSim.Modules.PathFinding
m_scriptModule.DispatchReply(requestData.ScriptID, 19860, _error.Message, requestData.RequestID.ToString());
}
}
}
#endregion