Push more NPC stuff into threads
parent
236e1c45f2
commit
9c6ba8d18f
|
@ -140,26 +140,33 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||||
// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
|
// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
lock (m_avatars)
|
ManualResetEvent ev = new ManualResetEvent(false);
|
||||||
{
|
|
||||||
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
|
|
||||||
scene.AddNewClient(npcAvatar, PresenceType.Npc);
|
|
||||||
|
|
||||||
ScenePresence sp;
|
Util.FireAndForget(delegate(object x) {
|
||||||
if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
|
lock (m_avatars)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat(
|
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
|
||||||
"[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
|
scene.AddNewClient(npcAvatar, PresenceType.Npc);
|
||||||
|
|
||||||
sp.CompleteMovement(npcAvatar, false);
|
ScenePresence sp;
|
||||||
}
|
if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
|
||||||
else
|
{
|
||||||
{
|
m_log.DebugFormat(
|
||||||
m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
|
"[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
|
||||||
}
|
|
||||||
|
|
||||||
m_avatars.Add(npcAvatar.AgentId, npcAvatar);
|
sp.CompleteMovement(npcAvatar, false);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
|
@ -2584,18 +2584,28 @@ 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) {
|
||||||
INPCModule module = World.RequestModuleInterface<INPCModule>();
|
try
|
||||||
if (module != null)
|
|
||||||
{
|
{
|
||||||
UUID npcId = new UUID(npc.m_string);
|
INPCModule module = World.RequestModuleInterface<INPCModule>();
|
||||||
|
if (module != null)
|
||||||
|
{
|
||||||
|
UUID npcId = new UUID(npc.m_string);
|
||||||
|
|
||||||
if (!module.CheckPermissions(npcId, m_host.OwnerID))
|
if (!module.CheckPermissions(npcId, m_host.OwnerID))
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue