Push more NPC stuff into threads

avinationmerge
Melanie 2012-02-08 13:04:23 +01:00
parent 236e1c45f2
commit 9c6ba8d18f
2 changed files with 41 additions and 24 deletions

View File

@ -140,6 +140,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
// } // }
ManualResetEvent ev = new ManualResetEvent(false);
Util.FireAndForget(delegate(object x) {
lock (m_avatars) lock (m_avatars)
{ {
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
@ -160,6 +163,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
m_avatars.Add(npcAvatar.AgentId, npcAvatar); m_avatars.Add(npcAvatar.AgentId, npcAvatar);
} }
ev.Set();
});
ev.WaitOne();
m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);

View File

@ -2584,7 +2584,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); CheckThreatLevel(ThreatLevel.High, "osNpcRemove");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
ManualResetEvent ev = new ManualResetEvent(false);
Util.FireAndForget(delegate(object x) { Util.FireAndForget(delegate(object x) {
try
{
INPCModule module = World.RequestModuleInterface<INPCModule>(); INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null) if (module != null)
{ {
@ -2594,9 +2598,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return; return;
module.DeleteNPC(npcId, World); module.DeleteNPC(npcId, World);
});
} }
} }
finally
{
ev.Set();
}
});
ev.WaitOne();
}
public void osNpcPlayAnimation(LSL_Key npc, string animation) public void osNpcPlayAnimation(LSL_Key npc, string animation)
{ {