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.cs62
1 files changed, 30 insertions, 32 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index fffe1ab..9ec4740 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -145,10 +145,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
145 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, 145 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0,
146 int.MaxValue); 146 int.MaxValue);
147 147
148 m_log.DebugFormat( 148// m_log.DebugFormat(
149 "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", 149// "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}",
150 firstname, lastname, npcAvatar.AgentId, owner, 150// firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName);
151 senseAsAgent, position, scene.RegionInfo.RegionName);
152 151
153 AgentCircuitData acd = new AgentCircuitData(); 152 AgentCircuitData acd = new AgentCircuitData();
154 acd.AgentID = npcAvatar.AgentId; 153 acd.AgentID = npcAvatar.AgentId;
@@ -171,36 +170,30 @@ namespace OpenSim.Region.OptionalModules.World.NPC
171 } 170 }
172 */ 171 */
173 172
174 lock (m_avatars) 173 ManualResetEvent ev = new ManualResetEvent(false);
175 {
176 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode,
177 acd);
178 scene.AddNewAgent(npcAvatar, PresenceType.Npc);
179 174
180 ScenePresence sp; 175 Util.FireAndForget(delegate(object x) {
181 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) 176 lock (m_avatars)
182 { 177 {
183 /* 178 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
184 m_log.DebugFormat( 179 scene.AddNewAgent(npcAvatar, PresenceType.Npc);
185 "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}",
186 sp.Name, sp.UUID);
187 */
188
189 sp.CompleteMovement(npcAvatar, false);
190 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
191 m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name);
192 180
193 return npcAvatar.AgentId; 181 ScenePresence sp;
182 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
183 {
184 sp.CompleteMovement(npcAvatar, false);
185 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
186// m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name);
187 }
194 } 188 }
195 else 189 ev.Set();
196 { 190 });
197 m_log.WarnFormat(
198 "[NPC MODULE]: Could not find scene presence for NPC {0} {1}",
199 sp.Name, sp.UUID);
200 191
201 return UUID.Zero; 192 ev.WaitOne();
202 } 193
203 } 194// m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
195
196 return npcAvatar.AgentId;
204 } 197 }
205 198
206 public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, 199 public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos,
@@ -408,9 +401,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC
408 { 401 {
409 NPCAvatar av; 402 NPCAvatar av;
410 if (m_avatars.TryGetValue(npcID, out av)) 403 if (m_avatars.TryGetValue(npcID, out av))
404 {
405 if (npcID == callerID)
406 return true;
411 return CheckPermissions(av, callerID); 407 return CheckPermissions(av, callerID);
408 }
412 else 409 else
410 {
413 return false; 411 return false;
412 }
414 } 413 }
415 } 414 }
416 415
@@ -422,8 +421,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
422 /// <returns>true if they do, false if they don't.</returns> 421 /// <returns>true if they do, false if they don't.</returns>
423 private bool CheckPermissions(NPCAvatar av, UUID callerID) 422 private bool CheckPermissions(NPCAvatar av, UUID callerID)
424 { 423 {
425 return callerID == UUID.Zero || av.OwnerID == UUID.Zero || 424 return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID || av.AgentId == callerID;
426 av.OwnerID == callerID;
427 } 425 }
428 } 426 }
429} \ No newline at end of file 427}