diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 87 |
1 files changed, 71 insertions, 16 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 56ff367..3831d7a 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 |
@@ -91,9 +109,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
91 | } | 109 | } |
92 | 110 | ||
93 | public UUID CreateNPC( | 111 | public UUID CreateNPC( |
94 | string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance) | 112 | string firstname, |
113 | string lastname, | ||
114 | Vector3 position, | ||
115 | UUID owner, | ||
116 | bool senseAsAgent, | ||
117 | Scene scene, | ||
118 | AvatarAppearance appearance) | ||
95 | { | 119 | { |
96 | NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); | 120 | NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene); |
97 | npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); | 121 | npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); |
98 | 122 | ||
99 | m_log.DebugFormat( | 123 | m_log.DebugFormat( |
@@ -234,38 +258,69 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
234 | return false; | 258 | return false; |
235 | } | 259 | } |
236 | 260 | ||
237 | public bool DeleteNPC(UUID agentID, Scene scene) | 261 | public UUID GetOwner(UUID agentID) |
238 | { | 262 | { |
239 | lock (m_avatars) | 263 | lock (m_avatars) |
240 | { | 264 | { |
241 | if (m_avatars.ContainsKey(agentID)) | 265 | NPCAvatar av; |
266 | if (m_avatars.TryGetValue(agentID, out av)) | ||
242 | { | 267 | { |
243 | scene.RemoveClient(agentID, false); | 268 | return av.OwnerID; |
244 | m_avatars.Remove(agentID); | ||
245 | |||
246 | return true; | ||
247 | } | 269 | } |
248 | } | 270 | } |
249 | 271 | ||
250 | return false; | 272 | return UUID.Zero; |
251 | } | 273 | } |
252 | 274 | ||
253 | public void PostInitialise() | 275 | public INPC GetNPC(UUID agentID, Scene scene) |
254 | { | 276 | { |
277 | lock (m_avatars) | ||
278 | { | ||
279 | if (m_avatars.ContainsKey(agentID)) | ||
280 | return m_avatars[agentID]; | ||
281 | else | ||
282 | return null; | ||
283 | } | ||
255 | } | 284 | } |
256 | 285 | ||
257 | public void Close() | 286 | public bool DeleteNPC(UUID agentID, Scene scene) |
258 | { | 287 | { |
288 | lock (m_avatars) | ||
289 | { | ||
290 | NPCAvatar av; | ||
291 | if (m_avatars.TryGetValue(agentID, out av)) | ||
292 | { | ||
293 | scene.RemoveClient(agentID, false); | ||
294 | m_avatars.Remove(agentID); | ||
295 | |||
296 | return true; | ||
297 | } | ||
298 | } | ||
299 | |||
300 | return false; | ||
259 | } | 301 | } |
260 | 302 | ||
261 | public string Name | 303 | public bool CheckPermissions(UUID npcID, UUID callerID) |
262 | { | 304 | { |
263 | get { return "NPCModule"; } | 305 | lock (m_avatars) |
306 | { | ||
307 | NPCAvatar av; | ||
308 | if (m_avatars.TryGetValue(npcID, out av)) | ||
309 | return CheckPermissions(av, callerID); | ||
310 | else | ||
311 | return false; | ||
312 | } | ||
264 | } | 313 | } |
265 | 314 | ||
266 | public bool IsSharedModule | 315 | /// <summary> |
316 | /// Check if the caller has permission to manipulate the given NPC. | ||
317 | /// </summary> | ||
318 | /// <param name="av"></param> | ||
319 | /// <param name="callerID"></param> | ||
320 | /// <returns>true if they do, false if they don't.</returns> | ||
321 | private bool CheckPermissions(NPCAvatar av, UUID callerID) | ||
267 | { | 322 | { |
268 | get { return true; } | 323 | return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID; |
269 | } | 324 | } |
270 | } | 325 | } |
271 | } \ No newline at end of file | 326 | } |