aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/World/NPC
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-01-12 18:14:19 +0000
committerJustin Clark-Casey (justincc)2012-01-12 18:14:19 +0000
commitb47c0d7e51bdb4d4bfa34f0952593f94c657d19c (patch)
treeff869b0264b252f6246d0c8d76e41cfd856f17c3 /OpenSim/Region/OptionalModules/World/NPC
parentIf deserializing a scene object fails during IAR load then ignore the object ... (diff)
downloadopensim-SC_OLD-b47c0d7e51bdb4d4bfa34f0952593f94c657d19c.zip
opensim-SC_OLD-b47c0d7e51bdb4d4bfa34f0952593f94c657d19c.tar.gz
opensim-SC_OLD-b47c0d7e51bdb4d4bfa34f0952593f94c657d19c.tar.bz2
opensim-SC_OLD-b47c0d7e51bdb4d4bfa34f0952593f94c657d19c.tar.xz
refactor: Move existing npc owner checks to NPCModule.CheckPermissions() methods and expose on interface for external calls.
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC')
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs49
1 files changed, 36 insertions, 13 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index e874417..8f9b513 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
@@ -255,7 +273,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
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) 276 if (!CheckPermissions(av, callerID));
259 return false; 277 return false;
260 278
261 scene.RemoveClient(agentID, false); 279 scene.RemoveClient(agentID, false);
@@ -268,22 +286,27 @@ namespace OpenSim.Region.OptionalModules.World.NPC
268 return false; 286 return false;
269 } 287 }
270 288
271 public void PostInitialise() 289 public bool CheckPermissions(UUID npcID, UUID callerID)
272 {
273 }
274
275 public void Close()
276 {
277 }
278
279 public string Name
280 { 290 {
281 get { return "NPCModule"; } 291 lock (m_avatars)
292 {
293 NPCAvatar av;
294 if (m_avatars.TryGetValue(npcID, out av))
295 return CheckPermissions(av, callerID);
296 else
297 return false;
298 }
282 } 299 }
283 300
284 public bool IsSharedModule 301 /// <summary>
302 /// Check if the caller has permission to manipulate the given NPC.
303 /// </summary>
304 /// <param name="av"></param>
305 /// <param name="callerID"></param>
306 /// <returns>true if they do, false if they don't.</returns>
307 private bool CheckPermissions(NPCAvatar av, UUID callerID)
285 { 308 {
286 get { return true; } 309 return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID;
287 } 310 }
288 } 311 }
289} 312}