diff options
Diffstat (limited to 'OpenSim')
11 files changed, 311 insertions, 82 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 2ad30a0..80ab30c 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -413,14 +413,13 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
413 | user.Id = uuid; | 413 | user.Id = uuid; |
414 | user.FirstName = first; | 414 | user.FirstName = first; |
415 | user.LastName = last; | 415 | user.LastName = last; |
416 | // user.ProfileURL = we should initialize this to the default | ||
417 | 416 | ||
418 | AddUserInternal(user); | 417 | AddUserInternal(user); |
419 | } | 418 | } |
420 | 419 | ||
421 | public void AddUser(UUID uuid, string first, string last, string profileURL) | 420 | public void AddUser(UUID uuid, string first, string last, string homeURL) |
422 | { | 421 | { |
423 | AddUser(uuid, profileURL + ";" + first + " " + last); | 422 | AddUser(uuid, homeURL + ";" + first + " " + last); |
424 | } | 423 | } |
425 | 424 | ||
426 | public void AddUser (UUID id, string creatorData) | 425 | public void AddUser (UUID id, string creatorData) |
@@ -492,36 +491,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
492 | // user.Id, user.FirstName, user.LastName, user.HomeURL); | 491 | // user.Id, user.FirstName, user.LastName, user.HomeURL); |
493 | } | 492 | } |
494 | 493 | ||
495 | //public void AddUser(UUID uuid, string userData) | ||
496 | //{ | ||
497 | // if (m_UserCache.ContainsKey(uuid)) | ||
498 | // return; | ||
499 | |||
500 | // UserData user = new UserData(); | ||
501 | // user.Id = uuid; | ||
502 | |||
503 | // // userData = <profile url>;<name> | ||
504 | // string[] parts = userData.Split(';'); | ||
505 | // if (parts.Length >= 1) | ||
506 | // user.ProfileURL = parts[0].Trim(); | ||
507 | // if (parts.Length >= 2) | ||
508 | // { | ||
509 | // string[] name = parts[1].Trim().Split(' '); | ||
510 | // if (name.Length >= 1) | ||
511 | // user.FirstName = name[0]; | ||
512 | // if (name.Length >= 2) | ||
513 | // user.LastName = name[1]; | ||
514 | // else | ||
515 | // user.LastName = "?"; | ||
516 | // } | ||
517 | |||
518 | // lock (m_UserCache) | ||
519 | // m_UserCache.Add(uuid, user); | ||
520 | |||
521 | // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.ProfileURL); | ||
522 | |||
523 | //} | ||
524 | |||
525 | public bool IsLocalGridUser(UUID uuid) | 494 | public bool IsLocalGridUser(UUID uuid) |
526 | { | 495 | { |
527 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid); | 496 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid); |
diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index cac8479..c50e734 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs | |||
@@ -53,6 +53,14 @@ namespace OpenSim.Region.Framework.Interfaces | |||
53 | bool IsNPC(UUID agentID, Scene scene); | 53 | bool IsNPC(UUID agentID, Scene scene); |
54 | 54 | ||
55 | /// <summary> | 55 | /// <summary> |
56 | /// Check if the caller has permission to manipulate the given NPC. | ||
57 | /// </summary> | ||
58 | /// <param name="npcID"></param> | ||
59 | /// <param name="callerID"></param> | ||
60 | /// <returns>true if they do, false if they don't or if there's no NPC with the given ID.</returns> | ||
61 | bool CheckPermissions(UUID npcID, UUID callerID); | ||
62 | |||
63 | /// <summary> | ||
56 | /// Set the appearance for an NPC. | 64 | /// Set the appearance for an NPC. |
57 | /// </summary> | 65 | /// </summary> |
58 | /// <param name="agentID"></param> | 66 | /// <param name="agentID"></param> |
@@ -117,7 +125,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
117 | /// <param name="agentID">The UUID of the NPC</param> | 125 | /// <param name="agentID">The UUID of the NPC</param> |
118 | /// <param name="scene"></param> | 126 | /// <param name="scene"></param> |
119 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | 127 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> |
120 | bool DeleteNPC(UUID agentID, UUID CallerID, Scene scene); | 128 | bool DeleteNPC(UUID agentID, Scene scene); |
121 | 129 | ||
122 | /// <summary> | 130 | /// <summary> |
123 | /// Get the owner of a NPC | 131 | /// Get the owner of a NPC |
diff --git a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs index 54dfaf4..4f62e28 100644 --- a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs +++ b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs | |||
@@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
50 | /// <param name="uuid"></param> | 50 | /// <param name="uuid"></param> |
51 | /// <param name="firstName"></param> | 51 | /// <param name="firstName"></param> |
52 | /// <param name="profileURL"></param> | 52 | /// <param name="profileURL"></param> |
53 | void AddUser(UUID uuid, string firstName, string lastName, string profileURL); | 53 | void AddUser(UUID uuid, string firstName, string lastName, string homeURL); |
54 | 54 | ||
55 | bool IsLocalGridUser(UUID uuid); | 55 | bool IsLocalGridUser(UUID uuid); |
56 | } | 56 | } |
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(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 8999f00..62cd75f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -2098,6 +2098,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2098 | return NpcCreate(firstname, lastname, position, notecard, false); | 2098 | return NpcCreate(firstname, lastname, position, notecard, false); |
2099 | } | 2099 | } |
2100 | 2100 | ||
2101 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) | ||
2102 | { | ||
2103 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); | ||
2104 | return NpcCreate(firstname, lastname, position, notecard, (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0); | ||
2105 | } | ||
2106 | |||
2101 | private LSL_Key NpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, bool owned) | 2107 | private LSL_Key NpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, bool owned) |
2102 | { | 2108 | { |
2103 | string groupTitle = String.Empty; | 2109 | string groupTitle = String.Empty; |
@@ -2175,11 +2181,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2175 | if (!UUID.TryParse(npc.m_string, out npcId)) | 2181 | if (!UUID.TryParse(npc.m_string, out npcId)) |
2176 | return new LSL_Key(UUID.Zero.ToString()); | 2182 | return new LSL_Key(UUID.Zero.ToString()); |
2177 | 2183 | ||
2178 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | 2184 | if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) |
2179 | return new LSL_Key(UUID.Zero.ToString()); | ||
2180 | |||
2181 | UUID ownerID = npcModule.GetOwner(npcId); | ||
2182 | if (ownerID != UUID.Zero && ownerID != m_host.OwnerID) | ||
2183 | return new LSL_Key(UUID.Zero.ToString()); | 2185 | return new LSL_Key(UUID.Zero.ToString()); |
2184 | 2186 | ||
2185 | return SaveAppearanceToNotecard(npcId, notecard); | 2187 | return SaveAppearanceToNotecard(npcId, notecard); |
@@ -2200,6 +2202,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2200 | if (!UUID.TryParse(npc.m_string, out npcId)) | 2202 | if (!UUID.TryParse(npc.m_string, out npcId)) |
2201 | return; | 2203 | return; |
2202 | 2204 | ||
2205 | if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) | ||
2206 | return; | ||
2207 | |||
2203 | string appearanceSerialized = LoadNotecard(notecard); | 2208 | string appearanceSerialized = LoadNotecard(notecard); |
2204 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); | 2209 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); |
2205 | // OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized); | 2210 | // OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized); |
@@ -2223,7 +2228,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2223 | if (!UUID.TryParse(npc.m_string, out npcId)) | 2228 | if (!UUID.TryParse(npc.m_string, out npcId)) |
2224 | return new LSL_Vector(0, 0, 0); | 2229 | return new LSL_Vector(0, 0, 0); |
2225 | 2230 | ||
2226 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | 2231 | if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) |
2227 | return new LSL_Vector(0, 0, 0); | 2232 | return new LSL_Vector(0, 0, 0); |
2228 | 2233 | ||
2229 | Vector3 pos = World.GetScenePresence(npcId).AbsolutePosition; | 2234 | Vector3 pos = World.GetScenePresence(npcId).AbsolutePosition; |
@@ -2243,6 +2248,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2243 | UUID npcId; | 2248 | UUID npcId; |
2244 | if (!UUID.TryParse(npc.m_string, out npcId)) | 2249 | if (!UUID.TryParse(npc.m_string, out npcId)) |
2245 | return; | 2250 | return; |
2251 | |||
2252 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2253 | return; | ||
2246 | 2254 | ||
2247 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); | 2255 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); |
2248 | module.MoveToTarget(npcId, World, pos, false, true); | 2256 | module.MoveToTarget(npcId, World, pos, false, true); |
@@ -2260,6 +2268,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2260 | if (!UUID.TryParse(npc.m_string, out npcId)) | 2268 | if (!UUID.TryParse(npc.m_string, out npcId)) |
2261 | return; | 2269 | return; |
2262 | 2270 | ||
2271 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2272 | return; | ||
2273 | |||
2263 | Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z); | 2274 | Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z); |
2264 | module.MoveToTarget( | 2275 | module.MoveToTarget( |
2265 | new UUID(npc.m_string), | 2276 | new UUID(npc.m_string), |
@@ -2281,7 +2292,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2281 | if (!UUID.TryParse(npc.m_string, out npcId)) | 2292 | if (!UUID.TryParse(npc.m_string, out npcId)) |
2282 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | 2293 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); |
2283 | 2294 | ||
2284 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | 2295 | if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) |
2285 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | 2296 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); |
2286 | 2297 | ||
2287 | ScenePresence sp = World.GetScenePresence(npcId); | 2298 | ScenePresence sp = World.GetScenePresence(npcId); |
@@ -2304,7 +2315,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2304 | if (!UUID.TryParse(npc.m_string, out npcId)) | 2315 | if (!UUID.TryParse(npc.m_string, out npcId)) |
2305 | return; | 2316 | return; |
2306 | 2317 | ||
2307 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | 2318 | if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) |
2308 | return; | 2319 | return; |
2309 | 2320 | ||
2310 | ScenePresence sp = World.GetScenePresence(npcId); | 2321 | ScenePresence sp = World.GetScenePresence(npcId); |
@@ -2318,7 +2329,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2318 | 2329 | ||
2319 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2330 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2320 | if (module != null) | 2331 | if (module != null) |
2321 | module.StopMoveToTarget(new UUID(npc.m_string), World); | 2332 | { |
2333 | UUID npcId = new UUID(npc.m_string); | ||
2334 | |||
2335 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2336 | return; | ||
2337 | |||
2338 | module.StopMoveToTarget(npcId, World); | ||
2339 | } | ||
2322 | } | 2340 | } |
2323 | 2341 | ||
2324 | public void osNpcSay(LSL_Key npc, string message) | 2342 | public void osNpcSay(LSL_Key npc, string message) |
@@ -2328,7 +2346,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2328 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2346 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2329 | if (module != null) | 2347 | if (module != null) |
2330 | { | 2348 | { |
2331 | module.Say(new UUID(npc.m_string), World, message); | 2349 | UUID npcId = new UUID(npc.m_string); |
2350 | |||
2351 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2352 | return; | ||
2353 | |||
2354 | module.Say(npcId, World, message); | ||
2332 | } | 2355 | } |
2333 | } | 2356 | } |
2334 | 2357 | ||
@@ -2339,7 +2362,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2339 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2362 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2340 | if (module != null) | 2363 | if (module != null) |
2341 | { | 2364 | { |
2342 | module.Sit(new UUID(npc.m_string), new UUID(target.m_string), World); | 2365 | UUID npcId = new UUID(npc.m_string); |
2366 | |||
2367 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2368 | return; | ||
2369 | |||
2370 | module.Sit(npcId, new UUID(target.m_string), World); | ||
2343 | } | 2371 | } |
2344 | } | 2372 | } |
2345 | 2373 | ||
@@ -2350,7 +2378,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2350 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2378 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2351 | if (module != null) | 2379 | if (module != null) |
2352 | { | 2380 | { |
2353 | module.Stand(new UUID(npc.m_string), World); | 2381 | UUID npcId = new UUID(npc.m_string); |
2382 | |||
2383 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2384 | return; | ||
2385 | |||
2386 | module.Stand(npcId, World); | ||
2354 | } | 2387 | } |
2355 | } | 2388 | } |
2356 | 2389 | ||
@@ -2361,7 +2394,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2361 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2394 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2362 | if (module != null) | 2395 | if (module != null) |
2363 | { | 2396 | { |
2364 | module.DeleteNPC(new UUID(npc.m_string), m_host.OwnerID, World); | 2397 | UUID npcId = new UUID(npc.m_string); |
2398 | |||
2399 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | ||
2400 | return; | ||
2401 | |||
2402 | module.DeleteNPC(npcId, World); | ||
2365 | } | 2403 | } |
2366 | } | 2404 | } |
2367 | 2405 | ||
@@ -2373,12 +2411,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2373 | if (module != null) | 2411 | if (module != null) |
2374 | { | 2412 | { |
2375 | UUID npcID = new UUID(npc.m_string); | 2413 | UUID npcID = new UUID(npc.m_string); |
2376 | if (module.IsNPC(npcID, m_host.ParentGroup.Scene)) | 2414 | |
2377 | { | 2415 | if (module.CheckPermissions(npcID, m_host.OwnerID)) |
2378 | UUID ownerID = module.GetOwner(npcID); | 2416 | AvatarPlayAnimation(npcID.ToString(), animation); |
2379 | if (ownerID == UUID.Zero || ownerID == m_host.OwnerID) | ||
2380 | AvatarPlayAnimation(npcID.ToString(), animation); | ||
2381 | } | ||
2382 | } | 2417 | } |
2383 | } | 2418 | } |
2384 | 2419 | ||
@@ -2390,12 +2425,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2390 | if (module != null) | 2425 | if (module != null) |
2391 | { | 2426 | { |
2392 | UUID npcID = new UUID(npc.m_string); | 2427 | UUID npcID = new UUID(npc.m_string); |
2393 | if (module.IsNPC(npcID, m_host.ParentGroup.Scene)) | 2428 | |
2394 | { | 2429 | if (module.CheckPermissions(npcID, m_host.OwnerID)) |
2395 | UUID ownerID = module.GetOwner(npcID); | 2430 | AvatarPlayAnimation(npcID.ToString(), animation); |
2396 | if (ownerID == UUID.Zero || ownerID == m_host.OwnerID) | ||
2397 | AvatarStopAnimation(npcID.ToString(), animation); | ||
2398 | } | ||
2399 | } | 2431 | } |
2400 | } | 2432 | } |
2401 | 2433 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index ac1c1a9..dddf913 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -468,12 +468,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
468 | toRegionPos = presence.AbsolutePosition; | 468 | toRegionPos = presence.AbsolutePosition; |
469 | dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos)); | 469 | dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos)); |
470 | 470 | ||
471 | if (presence.PresenceType == PresenceType.Npc && npcModule != null) | 471 | // Disabled for now since all osNpc* methods check for appropriate ownership permission. |
472 | { | 472 | // Perhaps could be re-enabled as an NPC setting at some point since being able to make NPCs not |
473 | UUID npcOwner = npcModule.GetOwner(presence.UUID); | 473 | // sensed might be useful. |
474 | if (npcOwner != UUID.Zero && npcOwner != SensePoint.OwnerID) | 474 | // if (presence.PresenceType == PresenceType.Npc && npcModule != null) |
475 | return; | 475 | // { |
476 | } | 476 | // UUID npcOwner = npcModule.GetOwner(presence.UUID); |
477 | // if (npcOwner != UUID.Zero && npcOwner != SensePoint.OwnerID) | ||
478 | // return; | ||
479 | // } | ||
477 | 480 | ||
478 | // are they in range | 481 | // are they in range |
479 | if (dis <= ts.range) | 482 | if (dis <= ts.range) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 44aff21..25f359a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -172,6 +172,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
172 | LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); | 172 | LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); |
173 | 173 | ||
174 | key osNpcCreate(string user, string name, vector position, string notecard); | 174 | key osNpcCreate(string user, string name, vector position, string notecard); |
175 | key osNpcCreate(string user, string name, vector position, string notecard, int options); | ||
175 | key osNpcCreateOwned(string user, string name, vector position, string notecard); | 176 | key osNpcCreateOwned(string user, string name, vector position, string notecard); |
176 | LSL_Key osNpcSaveAppearance(key npc, string notecard); | 177 | LSL_Key osNpcSaveAppearance(key npc, string notecard); |
177 | void osNpcLoadAppearance(key npc, string notecard); | 178 | void osNpcLoadAppearance(key npc, string notecard); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 3c258d8..32226f9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -609,6 +609,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
609 | 609 | ||
610 | public const int OS_NPC_SIT_NOW = 0; | 610 | public const int OS_NPC_SIT_NOW = 0; |
611 | 611 | ||
612 | public const int OS_NPC_CREATOR_OWNED = 0x1; | ||
613 | public const int OS_NPC_NOT_OWNED = 0x2; | ||
614 | |||
612 | public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; | 615 | public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; |
613 | public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; | 616 | public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; |
614 | 617 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index a94392a..ceccceb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -488,6 +488,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
488 | return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom); | 488 | return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom); |
489 | } | 489 | } |
490 | 490 | ||
491 | public key osNpcCreate(string user, string name, vector position, key cloneFrom, int options) | ||
492 | { | ||
493 | return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom, options); | ||
494 | } | ||
495 | |||
491 | public key osNpcCreateOwned(string user, string name, vector position, key cloneFrom) | 496 | public key osNpcCreateOwned(string user, string name, vector position, key cloneFrom) |
492 | { | 497 | { |
493 | return m_OSSL_Functions.osNpcCreateOwned(user, name, position, cloneFrom); | 498 | return m_OSSL_Functions.osNpcCreateOwned(user, name, position, cloneFrom); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs new file mode 100644 index 0000000..f0b28b2 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | |||
@@ -0,0 +1,168 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Text; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using NUnit.Framework; | ||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.Assets; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | ||
40 | using OpenSim.Region.OptionalModules.World.NPC; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using OpenSim.Region.ScriptEngine.Shared; | ||
43 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
44 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using OpenSim.Tests.Common; | ||
47 | using OpenSim.Tests.Common.Mock; | ||
48 | |||
49 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | ||
50 | { | ||
51 | /// <summary> | ||
52 | /// Tests for OSSL NPC API | ||
53 | /// </summary> | ||
54 | [TestFixture] | ||
55 | public class OSSL_NpcApiAppearanceTest | ||
56 | { | ||
57 | protected Scene m_scene; | ||
58 | protected XEngine.XEngine m_engine; | ||
59 | |||
60 | [SetUp] | ||
61 | public void SetUp() | ||
62 | { | ||
63 | IConfigSource initConfigSource = new IniConfigSource(); | ||
64 | IConfig config = initConfigSource.AddConfig("XEngine"); | ||
65 | config.Set("Enabled", "true"); | ||
66 | config.Set("AllowOSFunctions", "true"); | ||
67 | config.Set("OSFunctionThreatLevel", "Severe"); | ||
68 | config = initConfigSource.AddConfig("NPC"); | ||
69 | config.Set("Enabled", "true"); | ||
70 | |||
71 | m_scene = SceneHelpers.SetupScene(); | ||
72 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); | ||
73 | |||
74 | m_engine = new XEngine.XEngine(); | ||
75 | m_engine.Initialise(initConfigSource); | ||
76 | m_engine.AddRegion(m_scene); | ||
77 | } | ||
78 | |||
79 | /// <summary> | ||
80 | /// Test removal of an owned NPC. | ||
81 | /// </summary> | ||
82 | [Test] | ||
83 | public void TestOsNpcRemoveOwned() | ||
84 | { | ||
85 | TestHelpers.InMethod(); | ||
86 | // log4net.Config.XmlConfigurator.Configure(); | ||
87 | |||
88 | // Store an avatar with a different height from default in a notecard. | ||
89 | UUID userId = TestHelpers.ParseTail(0x1); | ||
90 | UUID otherUserId = TestHelpers.ParseTail(0x2); | ||
91 | float newHeight = 1.9f; | ||
92 | |||
93 | SceneHelpers.AddScenePresence(m_scene, otherUserId); | ||
94 | |||
95 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | ||
96 | sp.Appearance.AvatarHeight = newHeight; | ||
97 | |||
98 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); | ||
99 | SceneObjectPart part = so.RootPart; | ||
100 | m_scene.AddSceneObject(so); | ||
101 | |||
102 | SceneObjectGroup otherSo = SceneHelpers.CreateSceneObject(1, otherUserId); | ||
103 | SceneObjectPart otherPart = otherSo.RootPart; | ||
104 | m_scene.AddSceneObject(otherSo); | ||
105 | |||
106 | OSSL_Api osslApi = new OSSL_Api(); | ||
107 | osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); | ||
108 | |||
109 | OSSL_Api otherOsslApi = new OSSL_Api(); | ||
110 | otherOsslApi.Initialize(m_engine, otherPart, otherPart.LocalId, otherPart.UUID); | ||
111 | |||
112 | string notecardName = "appearanceNc"; | ||
113 | osslApi.osOwnerSaveAppearance(notecardName); | ||
114 | |||
115 | string npcRaw | ||
116 | = osslApi.osNpcCreate( | ||
117 | "Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName, ScriptBaseClass.OS_NPC_CREATOR_OWNED); | ||
118 | |||
119 | otherOsslApi.osNpcRemove(npcRaw); | ||
120 | |||
121 | // Should still be around | ||
122 | UUID npcId = new UUID(npcRaw); | ||
123 | ScenePresence npc = m_scene.GetScenePresence(npcId); | ||
124 | Assert.That(npc, Is.Not.Null); | ||
125 | |||
126 | osslApi.osNpcRemove(npcRaw); | ||
127 | |||
128 | npc = m_scene.GetScenePresence(npcId); | ||
129 | |||
130 | } | ||
131 | |||
132 | /// <summary> | ||
133 | /// Test removal of an unowned NPC. | ||
134 | /// </summary> | ||
135 | [Test] | ||
136 | public void TestOsNpcRemoveUnowned() | ||
137 | { | ||
138 | TestHelpers.InMethod(); | ||
139 | // log4net.Config.XmlConfigurator.Configure(); | ||
140 | |||
141 | // Store an avatar with a different height from default in a notecard. | ||
142 | UUID userId = TestHelpers.ParseTail(0x1); | ||
143 | float newHeight = 1.9f; | ||
144 | |||
145 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | ||
146 | sp.Appearance.AvatarHeight = newHeight; | ||
147 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId); | ||
148 | SceneObjectPart part = so.RootPart; | ||
149 | m_scene.AddSceneObject(so); | ||
150 | |||
151 | OSSL_Api osslApi = new OSSL_Api(); | ||
152 | osslApi.Initialize(m_engine, part, part.LocalId, part.UUID); | ||
153 | |||
154 | string notecardName = "appearanceNc"; | ||
155 | osslApi.osOwnerSaveAppearance(notecardName); | ||
156 | |||
157 | string npcRaw | ||
158 | = osslApi.osNpcCreate( | ||
159 | "Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName, ScriptBaseClass.OS_NPC_NOT_OWNED); | ||
160 | |||
161 | osslApi.osNpcRemove(npcRaw); | ||
162 | |||
163 | UUID npcId = new UUID(npcRaw); | ||
164 | ScenePresence npc = m_scene.GetScenePresence(npcId); | ||
165 | Assert.That(npc, Is.Null); | ||
166 | } | ||
167 | } | ||
168 | } \ No newline at end of file | ||