aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2012-02-08 13:04:23 +0100
committerMelanie2012-02-08 13:04:23 +0100
commit9c6ba8d18f4b3c4b457240f251612691cb271d90 (patch)
tree4dce5e2aec6db01eaa6932732f94f78552f09f86 /OpenSim
parentMerge branch 'master' into careminster (diff)
downloadopensim-SC_OLD-9c6ba8d18f4b3c4b457240f251612691cb271d90.zip
opensim-SC_OLD-9c6ba8d18f4b3c4b457240f251612691cb271d90.tar.gz
opensim-SC_OLD-9c6ba8d18f4b3c4b457240f251612691cb271d90.tar.bz2
opensim-SC_OLD-9c6ba8d18f4b3c4b457240f251612691cb271d90.tar.xz
Push more NPC stuff into threads
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs37
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs26
2 files changed, 40 insertions, 23 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 6a48b89..3ea7352 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -140,26 +140,33 @@ namespace OpenSim.Region.OptionalModules.World.NPC
140// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); 140// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
141// } 141// }
142 142
143 lock (m_avatars) 143 ManualResetEvent ev = new ManualResetEvent(false);
144 {
145 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
146 scene.AddNewClient(npcAvatar, PresenceType.Npc);
147 144
148 ScenePresence sp; 145 Util.FireAndForget(delegate(object x) {
149 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) 146 lock (m_avatars)
150 { 147 {
151 m_log.DebugFormat( 148 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
152 "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); 149 scene.AddNewClient(npcAvatar, PresenceType.Npc);
153 150
154 sp.CompleteMovement(npcAvatar, false); 151 ScenePresence sp;
155 } 152 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
156 else 153 {
157 { 154 m_log.DebugFormat(
158 m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID); 155 "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
156
157 sp.CompleteMovement(npcAvatar, false);
158 }
159 else
160 {
161 m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
162 }
163
164 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
159 } 165 }
166 ev.Set();
167 });
160 168
161 m_avatars.Add(npcAvatar.AgentId, npcAvatar); 169 ev.WaitOne();
162 }
163 170
164 m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); 171 m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
165 172
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 614872e..c83df4e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2584,18 +2584,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2584 CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); 2584 CheckThreatLevel(ThreatLevel.High, "osNpcRemove");
2585 m_host.AddScriptLPS(1); 2585 m_host.AddScriptLPS(1);
2586 2586
2587 ManualResetEvent ev = new ManualResetEvent(false);
2588
2587 Util.FireAndForget(delegate(object x) { 2589 Util.FireAndForget(delegate(object x) {
2588 INPCModule module = World.RequestModuleInterface<INPCModule>(); 2590 try
2589 if (module != null)
2590 { 2591 {
2591 UUID npcId = new UUID(npc.m_string); 2592 INPCModule module = World.RequestModuleInterface<INPCModule>();
2593 if (module != null)
2594 {
2595 UUID npcId = new UUID(npc.m_string);
2592 2596
2593 if (!module.CheckPermissions(npcId, m_host.OwnerID)) 2597 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2594 return; 2598 return;
2595 2599
2596 module.DeleteNPC(npcId, World); 2600 module.DeleteNPC(npcId, World);
2597 }); 2601 }
2598 } 2602 }
2603 finally
2604 {
2605 ev.Set();
2606 }
2607 });
2608 ev.WaitOne();
2599 } 2609 }
2600 2610
2601 public void osNpcPlayAnimation(LSL_Key npc, string animation) 2611 public void osNpcPlayAnimation(LSL_Key npc, string animation)