diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 52 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 20 |
2 files changed, 56 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 | } |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 571d33d..d21d601 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | |||
@@ -119,6 +119,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
119 | } | 119 | } |
120 | 120 | ||
121 | [Test] | 121 | [Test] |
122 | public void TestRemove() | ||
123 | { | ||
124 | TestHelpers.InMethod(); | ||
125 | // log4net.Config.XmlConfigurator.Configure(); | ||
126 | |||
127 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); | ||
128 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | ||
129 | |||
130 | Vector3 startPos = new Vector3(128, 128, 30); | ||
131 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | ||
132 | UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, UUID.Zero, scene, sp.Appearance); | ||
133 | |||
134 | npcModule.DeleteNPC(npcId, scene); | ||
135 | |||
136 | ScenePresence deletedNpc = scene.GetScenePresence(npcId); | ||
137 | |||
138 | Assert.That(deletedNpc, Is.Null); | ||
139 | } | ||
140 | |||
141 | [Test] | ||
122 | public void TestAttachments() | 142 | public void TestAttachments() |
123 | { | 143 | { |
124 | TestHelpers.InMethod(); | 144 | TestHelpers.InMethod(); |