diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 49 |
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 | } |