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.cs52
1 files changed, 36 insertions, 16 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index e874417..d90309f 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -56,6 +56,24 @@ namespace OpenSim.Region.OptionalModules.World.NPC
56 } 56 }
57 } 57 }
58 58
59 public void PostInitialise()
60 {
61 }
62
63 public void Close()
64 {
65 }
66
67 public string Name
68 {
69 get { return "NPCModule"; }
70 }
71
72 public bool IsSharedModule
73 {
74 get { return true; }
75 }
76
59 public bool IsNPC(UUID agentId, Scene scene) 77 public bool IsNPC(UUID agentId, Scene scene)
60 { 78 {
61 // FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect 79 // FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect
@@ -248,16 +266,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC
248 return UUID.Zero; 266 return UUID.Zero;
249 } 267 }
250 268
251 public bool DeleteNPC(UUID agentID, UUID callerID, Scene scene) 269 public bool DeleteNPC(UUID agentID, Scene scene)
252 { 270 {
253 lock (m_avatars) 271 lock (m_avatars)
254 { 272 {
255 NPCAvatar av; 273 NPCAvatar av;
256 if (m_avatars.TryGetValue(agentID, out av)) 274 if (m_avatars.TryGetValue(agentID, out av))
257 { 275 {
258 if (av.OwnerID != UUID.Zero && callerID != UUID.Zero && av.OwnerID != callerID)
259 return false;
260
261 scene.RemoveClient(agentID, false); 276 scene.RemoveClient(agentID, false);
262 m_avatars.Remove(agentID); 277 m_avatars.Remove(agentID);
263 278
@@ -268,22 +283,27 @@ namespace OpenSim.Region.OptionalModules.World.NPC
268 return false; 283 return false;
269 } 284 }
270 285
271 public void PostInitialise() 286 public bool CheckPermissions(UUID npcID, UUID callerID)
272 {
273 }
274
275 public void Close()
276 {
277 }
278
279 public string Name
280 { 287 {
281 get { return "NPCModule"; } 288 lock (m_avatars)
289 {
290 NPCAvatar av;
291 if (m_avatars.TryGetValue(npcID, out av))
292 return CheckPermissions(av, callerID);
293 else
294 return false;
295 }
282 } 296 }
283 297
284 public bool IsSharedModule 298 /// <summary>
299 /// Check if the caller has permission to manipulate the given NPC.
300 /// </summary>
301 /// <param name="av"></param>
302 /// <param name="callerID"></param>
303 /// <returns>true if they do, false if they don't.</returns>
304 private bool CheckPermissions(NPCAvatar av, UUID callerID)
285 { 305 {
286 get { return true; } 306 return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID;
287 } 307 }
288 } 308 }
289} 309}