From 209b6babb5f10c60f00b09940ec061e8b7161941 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 12 Nov 2022 19:35:45 +0000 Subject: [PATCH] mantis 9036: do not allow ForceAttachToAvatarFromInventory to attach coalesced inventory assets --- .../Shared/Api/Implementation/OSSL_Api.cs | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 3cc88414a8..e4b74c92de 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -4236,43 +4236,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void ForceAttachToAvatarFromInventory(UUID avatarId, string itemName, int attachmentPoint) { IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; - - if (attachmentsModule == null) + if (attachmentsModule is null) return; InitLSL(); TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName); - - if (item == null) + if (item is null) { - m_LSL_Api.llSay(0, string.Format("Could not find object '{0}'", itemName)); + m_LSL_Api?.llSay(0, string.Format("Could not find object '{0}'", itemName)); throw new Exception(String.Format("The inventory item '{0}' could not be found", itemName)); } if (item.InvType != (int)InventoryType.Object) { - // FIXME: Temporary null check for regression tests since they dont' have the infrastructure to set - // up the api reference. - if (m_LSL_Api != null) - m_LSL_Api.llSay(0, string.Format("Unable to attach, item '{0}' is not an object.", itemName)); - + m_LSL_Api?.llSay(0, string.Format("Unable to attach, item '{0}' is not an object.", itemName)); throw new Exception(String.Format("The inventory item '{0}' is not an object", itemName)); } - ScenePresence sp = World.GetScenePresence(avatarId); + if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) != 0) + { + m_LSL_Api?.llSay(0, string.Format("Unable to attach coalesced object, item '{0}' ", itemName)); + throw new Exception(String.Format("The inventory item '{0}' is a coalesced object", itemName)); + } - if (sp == null) + ScenePresence sp = World.GetScenePresence(avatarId); + if (sp is null) return; InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID, out string message); - if (newItem == null) + if (newItem is null) { m_log.ErrorFormat( "[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}: {4}", itemName, m_host.Name, attachmentPoint, World.Name, message); - m_LSL_Api.llSay(0, message); + m_LSL_Api?.llSay(0, message); return; }