aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs')
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs45
1 files changed, 27 insertions, 18 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 2052cdb..ae46c97 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -140,29 +140,38 @@ 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 m_avatars.Add(npcAvatar.AgentId, npcAvatar); 152 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
156 m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); 153 {
154 m_log.DebugFormat(
155 "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
156
157 sp.CompleteMovement(npcAvatar, false);
158 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
159 }
160 else
161 {
162 m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
163 npcAvatar.AgentId = UUID.Zero;
164 }
157 165
158 return npcAvatar.AgentId;
159 }
160 else
161 {
162 m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
163 return UUID.Zero;
164 } 166 }
165 } 167 ev.Set();
168 });
169
170 ev.WaitOne();
171
172// m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
173
174 return npcAvatar.AgentId;
166 } 175 }
167 176
168 public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget) 177 public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget)