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 3ac1eb1..9c77b59 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) | 173 | public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget) |
@@ -355,9 +356,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
355 | { | 356 | { |
356 | NPCAvatar av; | 357 | NPCAvatar av; |
357 | if (m_avatars.TryGetValue(npcID, out av)) | 358 | if (m_avatars.TryGetValue(npcID, out av)) |
359 | { | ||
360 | if (npcID == callerID) | ||
361 | return true; | ||
358 | return CheckPermissions(av, callerID); | 362 | return CheckPermissions(av, callerID); |
363 | } | ||
359 | else | 364 | else |
365 | { | ||
360 | return false; | 366 | return false; |
367 | } | ||
361 | } | 368 | } |
362 | } | 369 | } |
363 | 370 | ||
@@ -369,7 +376,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
369 | /// <returns>true if they do, false if they don't.</returns> | 376 | /// <returns>true if they do, false if they don't.</returns> |
370 | private bool CheckPermissions(NPCAvatar av, UUID callerID) | 377 | private bool CheckPermissions(NPCAvatar av, UUID callerID) |
371 | { | 378 | { |
372 | return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID; | 379 | return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID || av.AgentId == callerID; |
373 | } | 380 | } |
374 | } | 381 | } |
375 | } | 382 | } |