diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 1e85fb4..b37aba3 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -144,29 +144,30 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
144 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); | 144 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); |
145 | // } | 145 | // } |
146 | 146 | ||
147 | lock (m_avatars) | 147 | ManualResetEvent ev = new ManualResetEvent(false); |
148 | { | ||
149 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); | ||
150 | scene.AddNewClient(npcAvatar, PresenceType.Npc); | ||
151 | 148 | ||
152 | ScenePresence sp; | 149 | Util.FireAndForget(delegate(object x) { |
153 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) | 150 | lock (m_avatars) |
154 | { | 151 | { |
155 | // m_log.DebugFormat( | 152 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); |
156 | // "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); | 153 | scene.AddNewClient(npcAvatar, PresenceType.Npc); |
157 | 154 | ||
158 | sp.CompleteMovement(npcAvatar, false); | 155 | ScenePresence sp; |
159 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); | 156 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) |
160 | m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); | 157 | { |
161 | 158 | sp.CompleteMovement(npcAvatar, false); | |
162 | return npcAvatar.AgentId; | 159 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); |
163 | } | 160 | m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); |
164 | else | 161 | } |
165 | { | ||
166 | m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID); | ||
167 | return UUID.Zero; | ||
168 | } | 162 | } |
169 | } | 163 | ev.Set(); |
164 | }); | ||
165 | |||
166 | ev.WaitOne(); | ||
167 | |||
168 | // m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId); | ||
169 | |||
170 | return npcAvatar.AgentId; | ||
170 | } | 171 | } |
171 | 172 | ||
172 | public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget, bool running) | 173 | public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget, bool running) |
@@ -366,9 +367,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
366 | { | 367 | { |
367 | NPCAvatar av; | 368 | NPCAvatar av; |
368 | if (m_avatars.TryGetValue(npcID, out av)) | 369 | if (m_avatars.TryGetValue(npcID, out av)) |
370 | { | ||
371 | if (npcID == callerID) | ||
372 | return true; | ||
369 | return CheckPermissions(av, callerID); | 373 | return CheckPermissions(av, callerID); |
374 | } | ||
370 | else | 375 | else |
376 | { | ||
371 | return false; | 377 | return false; |
378 | } | ||
372 | } | 379 | } |
373 | } | 380 | } |
374 | 381 | ||
@@ -380,7 +387,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
380 | /// <returns>true if they do, false if they don't.</returns> | 387 | /// <returns>true if they do, false if they don't.</returns> |
381 | private bool CheckPermissions(NPCAvatar av, UUID callerID) | 388 | private bool CheckPermissions(NPCAvatar av, UUID callerID) |
382 | { | 389 | { |
383 | return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID; | 390 | return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID || av.AgentId == callerID; |
384 | } | 391 | } |
385 | } | 392 | } |
386 | } | 393 | } |