diff options
author | Melanie | 2012-05-27 19:24:30 +0100 |
---|---|---|
committer | Melanie | 2012-05-27 19:24:30 +0100 |
commit | 884c0e7bb10bd2c2a951901c6f1dd56a86ef6b9f (patch) | |
tree | dd692a54213f86fd64bd29c6662584df85088193 /OpenSim/Region/ScriptEngine/Shared | |
parent | Merge branch 'master' into careminster (diff) | |
parent | minor: code formatting from 0b72f773 (diff) | |
download | opensim-SC-884c0e7bb10bd2c2a951901c6f1dd56a86ef6b9f.zip opensim-SC-884c0e7bb10bd2c2a951901c6f1dd56a86ef6b9f.tar.gz opensim-SC-884c0e7bb10bd2c2a951901c6f1dd56a86ef6b9f.tar.bz2 opensim-SC-884c0e7bb10bd2c2a951901c6f1dd56a86ef6b9f.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Data/MySQL/MySQLSimulationData.cs
OpenSim/Data/MySQL/Resources/RegionStore.migrations
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
OpenSim/Region/Framework/Scenes/Scene.cs
OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 139 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 22 |
2 files changed, 83 insertions, 78 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0cc3e8c..03f4108 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -354,51 +354,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
354 | 354 | ||
355 | protected UUID InventoryKey(string name, int type) | 355 | protected UUID InventoryKey(string name, int type) |
356 | { | 356 | { |
357 | m_host.AddScriptLPS(1); | 357 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name); |
358 | m_host.TaskInventory.LockItemsForRead(true); | ||
359 | |||
360 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
361 | { | ||
362 | if (inv.Value.Name == name) | ||
363 | { | ||
364 | m_host.TaskInventory.LockItemsForRead(false); | ||
365 | |||
366 | if (inv.Value.Type != type) | ||
367 | { | ||
368 | return UUID.Zero; | ||
369 | } | ||
370 | 358 | ||
371 | return inv.Value.AssetID; | 359 | if (item != null && item.Type == type) |
372 | } | 360 | return item.AssetID; |
373 | } | 361 | else |
374 | 362 | return UUID.Zero; | |
375 | m_host.TaskInventory.LockItemsForRead(false); | ||
376 | return UUID.Zero; | ||
377 | } | ||
378 | |||
379 | protected UUID InventoryKey(string name) | ||
380 | { | ||
381 | m_host.AddScriptLPS(1); | ||
382 | |||
383 | |||
384 | m_host.TaskInventory.LockItemsForRead(true); | ||
385 | |||
386 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
387 | { | ||
388 | if (inv.Value.Name == name) | ||
389 | { | ||
390 | m_host.TaskInventory.LockItemsForRead(false); | ||
391 | return inv.Value.AssetID; | ||
392 | } | ||
393 | } | ||
394 | |||
395 | m_host.TaskInventory.LockItemsForRead(false); | ||
396 | |||
397 | |||
398 | return UUID.Zero; | ||
399 | } | 363 | } |
400 | 364 | ||
401 | |||
402 | /// <summary> | 365 | /// <summary> |
403 | /// accepts a valid UUID, -or- a name of an inventory item. | 366 | /// accepts a valid UUID, -or- a name of an inventory item. |
404 | /// Returns a valid UUID or UUID.Zero if key invalid and item not found | 367 | /// Returns a valid UUID or UUID.Zero if key invalid and item not found |
@@ -408,19 +371,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
408 | /// <returns></returns> | 371 | /// <returns></returns> |
409 | protected UUID KeyOrName(string k) | 372 | protected UUID KeyOrName(string k) |
410 | { | 373 | { |
411 | UUID key = UUID.Zero; | 374 | UUID key; |
412 | 375 | ||
413 | // if we can parse the string as a key, use it. | 376 | // if we can parse the string as a key, use it. |
414 | if (UUID.TryParse(k, out key)) | ||
415 | { | ||
416 | return key; | ||
417 | } | ||
418 | // else try to locate the name in inventory of object. found returns key, | 377 | // else try to locate the name in inventory of object. found returns key, |
419 | // not found returns UUID.Zero which will translate to the default particle texture | 378 | // not found returns UUID.Zero |
420 | else | 379 | if (!UUID.TryParse(k, out key)) |
421 | { | 380 | { |
422 | return InventoryKey(k); | 381 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k); |
382 | |||
383 | if (item != null) | ||
384 | key = item.AssetID; | ||
385 | else | ||
386 | key = UUID.Zero; | ||
423 | } | 387 | } |
388 | |||
389 | return key; | ||
424 | } | 390 | } |
425 | 391 | ||
426 | // convert a LSL_Rotation to a Quaternion | 392 | // convert a LSL_Rotation to a Quaternion |
@@ -1897,14 +1863,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1897 | 1863 | ||
1898 | return rgb; | 1864 | return rgb; |
1899 | } | 1865 | } |
1866 | |||
1900 | if (face >= 0 && face < GetNumberOfSides(part)) | 1867 | if (face >= 0 && face < GetNumberOfSides(part)) |
1901 | { | 1868 | { |
1902 | texcolor = tex.GetFace((uint)face).RGBA; | 1869 | texcolor = tex.GetFace((uint)face).RGBA; |
1903 | rgb.x = texcolor.R; | 1870 | rgb.x = texcolor.R; |
1904 | rgb.y = texcolor.G; | 1871 | rgb.y = texcolor.G; |
1905 | rgb.z = texcolor.B; | 1872 | rgb.z = texcolor.B; |
1873 | |||
1906 | return rgb; | 1874 | return rgb; |
1907 | |||
1908 | } | 1875 | } |
1909 | else | 1876 | else |
1910 | { | 1877 | { |
@@ -3598,17 +3565,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3598 | 3565 | ||
3599 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) | 3566 | if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) |
3600 | { | 3567 | { |
3601 | UUID animID = new UUID(); | ||
3602 | |||
3603 | if (!UUID.TryParse(anim, out animID)) | ||
3604 | { | ||
3605 | animID = InventoryKey(anim); | ||
3606 | } | ||
3607 | |||
3608 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); | 3568 | ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); |
3609 | 3569 | ||
3610 | if (presence != null) | 3570 | if (presence != null) |
3611 | { | 3571 | { |
3572 | UUID animID = KeyOrName(anim); | ||
3573 | |||
3612 | if (animID == UUID.Zero) | 3574 | if (animID == UUID.Zero) |
3613 | presence.Animator.RemoveAnimation(anim); | 3575 | presence.Animator.RemoveAnimation(anim); |
3614 | else | 3576 | else |
@@ -3737,9 +3699,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3737 | } | 3699 | } |
3738 | 3700 | ||
3739 | ScenePresence presence = World.GetScenePresence(agentID); | 3701 | ScenePresence presence = World.GetScenePresence(agentID); |
3740 | |||
3741 | if (presence != null) | 3702 | if (presence != null) |
3742 | { | 3703 | { |
3704 | // If permissions are being requested from an NPC and were not implicitly granted above then | ||
3705 | // auto grant all reuqested permissions if the script is owned by the NPC or the NPCs owner | ||
3706 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); | ||
3707 | if (npcModule != null && npcModule.IsNPC(agentID, World)) | ||
3708 | { | ||
3709 | if (agentID == m_host.ParentGroup.OwnerID || npcModule.GetOwner(agentID) == m_host.ParentGroup.OwnerID) | ||
3710 | { | ||
3711 | lock (m_host.TaskInventory) | ||
3712 | { | ||
3713 | m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; | ||
3714 | m_host.TaskInventory[m_item.ItemID].PermsMask = perm; | ||
3715 | } | ||
3716 | |||
3717 | m_ScriptEngine.PostScriptEvent( | ||
3718 | m_item.ItemID, | ||
3719 | new EventParams( | ||
3720 | "run_time_permissions", new Object[] { new LSL_Integer(perm) }, new DetectParams[0])); | ||
3721 | } | ||
3722 | |||
3723 | // it is an NPC, exit even if the permissions werent granted above, they are not going to answer | ||
3724 | // the question! | ||
3725 | return; | ||
3726 | } | ||
3727 | |||
3743 | string ownerName = resolveName(m_host.ParentGroup.RootPart.OwnerID); | 3728 | string ownerName = resolveName(m_host.ParentGroup.RootPart.OwnerID); |
3744 | if (ownerName == String.Empty) | 3729 | if (ownerName == String.Empty) |
3745 | ownerName = "(hippos)"; | 3730 | ownerName = "(hippos)"; |
@@ -3762,10 +3747,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3762 | } | 3747 | } |
3763 | 3748 | ||
3764 | // Requested agent is not in range, refuse perms | 3749 | // Requested agent is not in range, refuse perms |
3765 | m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( | 3750 | m_ScriptEngine.PostScriptEvent( |
3766 | "run_time_permissions", new Object[] { | 3751 | m_item.ItemID, |
3767 | new LSL_Integer(0) }, | 3752 | new EventParams("run_time_permissions", new Object[] { new LSL_Integer(0) }, new DetectParams[0])); |
3768 | new DetectParams[0])); | ||
3769 | } | 3753 | } |
3770 | 3754 | ||
3771 | void handleScriptAnswer(IClientAPI client, UUID taskID, UUID itemID, int answer) | 3755 | void handleScriptAnswer(IClientAPI client, UUID taskID, UUID itemID, int answer) |
@@ -9456,7 +9440,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9456 | public LSL_String llGetSimulatorHostname() | 9440 | public LSL_String llGetSimulatorHostname() |
9457 | { | 9441 | { |
9458 | m_host.AddScriptLPS(1); | 9442 | m_host.AddScriptLPS(1); |
9459 | return System.Environment.MachineName; | 9443 | IUrlModule UrlModule = World.RequestModuleInterface<IUrlModule>(); |
9444 | return UrlModule.ExternalHostNameForLSL; | ||
9460 | } | 9445 | } |
9461 | 9446 | ||
9462 | // <summary> | 9447 | // <summary> |
@@ -9811,7 +9796,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9811 | 9796 | ||
9812 | GridRegion info; | 9797 | GridRegion info; |
9813 | 9798 | ||
9814 | if (m_ScriptEngine.World.RegionInfo.RegionName == simulator) | 9799 | if (m_ScriptEngine.World.RegionInfo.RegionName == simulator) //Det data for this simulator? |
9800 | |||
9815 | info = new GridRegion(m_ScriptEngine.World.RegionInfo); | 9801 | info = new GridRegion(m_ScriptEngine.World.RegionInfo); |
9816 | else | 9802 | else |
9817 | info = m_ScriptEngine.World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator); | 9803 | info = m_ScriptEngine.World.GridService.GetRegionByName(m_ScriptEngine.World.RegionInfo.ScopeID, simulator); |
@@ -9824,10 +9810,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9824 | ScriptSleep(1000); | 9810 | ScriptSleep(1000); |
9825 | return UUID.Zero.ToString(); | 9811 | return UUID.Zero.ToString(); |
9826 | } | 9812 | } |
9827 | reply = new LSL_Vector( | 9813 | if (m_ScriptEngine.World.RegionInfo.RegionName != simulator) |
9828 | info.RegionLocX, | 9814 | { |
9829 | info.RegionLocY, | 9815 | //Hypergrid Region co-ordinates |
9830 | 0).ToString(); | 9816 | uint rx = 0, ry = 0; |
9817 | Utils.LongToUInts(Convert.ToUInt64(info.RegionSecret), out rx, out ry); | ||
9818 | |||
9819 | reply = new LSL_Vector( | ||
9820 | rx, | ||
9821 | ry, | ||
9822 | 0).ToString(); | ||
9823 | } | ||
9824 | else | ||
9825 | { | ||
9826 | //Local-cooridnates | ||
9827 | reply = new LSL_Vector( | ||
9828 | info.RegionLocX, | ||
9829 | info.RegionLocY, | ||
9830 | 0).ToString(); | ||
9831 | } | ||
9831 | break; | 9832 | break; |
9832 | case ScriptBaseClass.DATA_SIM_STATUS: | 9833 | case ScriptBaseClass.DATA_SIM_STATUS: |
9833 | if (info != null) | 9834 | if (info != null) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 51ace1a..8237b60 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -960,21 +960,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
960 | UUID avatarID = (UUID)avatar; | 960 | UUID avatarID = (UUID)avatar; |
961 | 961 | ||
962 | m_host.AddScriptLPS(1); | 962 | m_host.AddScriptLPS(1); |
963 | |||
964 | // FIXME: What we really want to do here is factor out the similar code in llStopAnimation() to a common | ||
965 | // method (though see that doesn't do the is animation check, which is probably a bug) and have both | ||
966 | // these functions call that common code. However, this does mean navigating the brain-dead requirement | ||
967 | // of calling InitLSL() | ||
963 | if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence) | 968 | if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence) |
964 | { | 969 | { |
965 | ScenePresence target = (ScenePresence)World.Entities[avatarID]; | 970 | ScenePresence target = (ScenePresence)World.Entities[avatarID]; |
966 | if (target != null) | 971 | if (target != null) |
967 | { | 972 | { |
968 | UUID animID = UUID.Zero; | 973 | UUID animID; |
969 | m_host.TaskInventory.LockItemsForRead(true); | 974 | |
970 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 975 | if (!UUID.TryParse(animation, out animID)) |
971 | { | 976 | { |
972 | if (inv.Value.Name == animation) | 977 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(animation); |
973 | { | 978 | if (item != null && item.Type == (int)AssetType.Animation) |
974 | if (inv.Value.Type == (int)AssetType.Animation) | 979 | animID = item.AssetID; |
975 | animID = inv.Value.AssetID; | 980 | else |
976 | continue; | 981 | animID = UUID.Zero; |
977 | } | ||
978 | } | 982 | } |
979 | m_host.TaskInventory.LockItemsForRead(false); | 983 | m_host.TaskInventory.LockItemsForRead(false); |
980 | 984 | ||