diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 5536f82fdd..76a859875c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -5635,6 +5635,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return ret; } + public void osRemoveLinkInventory(LSL_Integer linkNumber, LSL_String name) + { + + SceneObjectPart part = GetSingleLinkPart(linkNumber); + if(part == null) + return; + + TaskInventoryItem item = part.Inventory.GetInventoryItem(name); + if (item == null) + return; + + if (item.ItemID == m_item.ItemID) + throw new ScriptDeleteException(); + else + part.Inventory.RemoveInventoryItem(item.ItemID); + } + /// /// Give a specified item from a child prim inventory /// to a destination (object or avatar). @@ -5703,6 +5720,100 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + public void osGiveLinkInventoryList(LSL_Integer linkNumber, LSL_Key destination, LSL_String category, LSL_List inventory) + { + if (inventory.Length == 0) + return; + + SceneObjectPart part = GetSingleLinkPart(linkNumber); + if(part == null) + return; + + if (!UUID.TryParse(destination, out UUID destID) || destID.IsZero()) + return; + + bool isNotOwner = true; + if (!World.TryGetSceneObjectPart(destID, out SceneObjectPart destSop)) + { + if (!World.TryGetScenePresence(destID, out ScenePresence sp)) + { + // we could check if it is a grid user and allow the transfer as in older code + // but that increases security risk + OSSLShoutError("osGiveLinkInventoryList: Unable to give list, destination not found"); + ScriptSleep(100); + return; + } + isNotOwner = sp.UUID.NotEqual(m_host.OwnerID); + } + + List itemList = new(inventory.Length); + foreach (object item in inventory.Data) + { + string rawItemString = item.ToString(); + TaskInventoryItem taskItem = (UUID.TryParse(rawItemString, out UUID itemID)) ? + part.Inventory.GetInventoryItem(itemID) : part.Inventory.GetInventoryItem(rawItemString); + + if(taskItem is null) + continue; + + if ((taskItem.CurrentPermissions & (uint)PermissionMask.Copy) == 0) + continue; + + if (destSop is not null) + { + if(!World.Permissions.CanDoObjectInvToObjectInv(taskItem, m_host, destSop)) + continue; + } + else + { + if(isNotOwner) + { + if ((taskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) + continue; + } + } + + itemList.Add(taskItem.ItemID); + } + + if (itemList.Count == 0) + { + OSSLShoutError("osGiveLinkInventoryList: Unable to give list, no items found"); + ScriptSleep(100); + return; + } + + UUID folderID = m_ScriptEngine.World.MoveTaskInventoryItems(destID, category, part, itemList, false); + + if (folderID.IsZero()) + { + OSSLShoutError("osGiveLinkInventoryList: Unable to give list"); + ScriptSleep(100); + return; + } + + if (destSop is not null) + { + ScriptSleep(100); + return; + } + + if (m_TransferModule != null) + { + byte[] bucket = new byte[] { (byte)AssetType.Folder }; + + Vector3 pos = m_host.AbsolutePosition; + + GridInstantMessage msg = new(World, m_host.OwnerID, m_host.Name, destID, + (byte)InstantMessageDialog.TaskInventoryOffered, + m_host.OwnerID.Equals(m_host.GroupID), string.Format("'{0}'", category), folderID, false, pos,bucket, false); + + m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); + } + + ScriptSleep(3000); + } + public LSL_Key osGetLastChangedEventKey() { DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_item.ItemID, 0); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index aaa79c64ee..d92f50c23f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -570,7 +570,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_List osGetLinkInventoryKeys(LSL_Integer linkNumber, LSL_Integer type); LSL_List osGetInventoryNames(LSL_Integer type); LSL_List osGetLinkInventoryNames(LSL_Integer linkNumber, LSL_Integer type); + void osRemoveLinkInventory(LSL_Integer linkNumber, LSL_String name); void osGiveLinkInventory(LSL_Integer linkNumber, LSL_Key destination, LSL_String inventory); + void osGiveLinkInventoryList(LSL_Integer linkNumber, LSL_Key destination, LSL_String category, LSL_List inventory); LSL_Key osGetLastChangedEventKey(); LSL_Float osGetPSTWallclock(); LSL_Rotation osSlerp(LSL_Rotation a, LSL_Rotation b, LSL_Float amount); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 9f31f80d67..56a44219bc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -1515,12 +1515,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_OSSL_Functions.osGetLinkInventoryDesc(linkNumber, itemNameOrId); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void osRemoveLinkInventory(LSL_Integer linkNumber, LSL_String name) + { + m_OSSL_Functions.osRemoveLinkInventory(linkNumber, name); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void osGiveLinkInventory(LSL_Integer linkNumber, LSL_Key destination, LSL_String inventory) { m_OSSL_Functions.osGiveLinkInventory(linkNumber, destination, inventory); } + public void osGiveLinkInventoryList(LSL_Integer linkNumber, LSL_Key destination, LSL_String category, LSL_List inventory) + { + m_OSSL_Functions.osGiveLinkInventoryList(linkNumber, destination, category, inventory); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public LSL_Key osGetLastChangedEventKey() { diff --git a/bin/ScriptSyntax.xml b/bin/ScriptSyntax.xml index b53d6dd1b8..0461263f1d 100644 --- a/bin/ScriptSyntax.xml +++ b/bin/ScriptSyntax.xml @@ -7378,6 +7378,13 @@ fc2639fd-5d16-66bf-d8ab-2e4d754c816d typetypeinteger + osRemoveLinkInventory + + arguments + linkNumbertypeinteger + nametypeinteger + + osGiveLinkInventory arguments @@ -7386,6 +7393,15 @@ fc2639fd-5d16-66bf-d8ab-2e4d754c816d inventorytypestring + osGiveLinkInventoryList + + arguments + linkNumbertypeinteger + destinationtypekey + categorytypestring + inventorytypestring + + osGetLastChangedEventKey returnkey