From c86259c6710c8ce5c97a7a64bbb96dac35440aec Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 4 May 2010 00:44:05 +0200 Subject: [PATCH] Fix scripted give and interactive give to offline avatars. Both folder and single items are now supported. Magic Boxes, yeah! --- .../Framework/Scenes/Scene.Inventory.cs | 16 ++++++++++ .../Shared/Api/Implementation/LSL_Api.cs | 31 ++++++++++++++----- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 9b838ab330..c105560cbe 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -94,6 +94,22 @@ namespace OpenSim.Region.Framework.Scenes public void AddInventoryItem(UUID AgentID, InventoryItemBase item) { + InventoryFolderBase folder; + + if (item.Folder == UUID.Zero) + { + folder = InventoryService.GetFolderForType(AgentID, (AssetType)item.AssetType); + if (folder == null) + { + folder = InventoryService.GetRootFolder(AgentID); + + if (folder == null) + return; + } + + item.Folder = folder.ID; + } + if (InventoryService.AddItem(item)) { int userlevel = 0; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 228e9b8aa6..d216effb31 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4005,9 +4005,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); } - // check if destination is an avatar - if (World.GetScenePresence(destId) != null) + // check if destination is an object + if (World.GetSceneObjectPart(destId) != null) { + // destination is an object + World.MoveTaskInventoryItem(destId, m_host, objId); + } + else + { + ScenePresence presence = World.GetScenePresence(destId); + + if (presence == null) + { + UserAccount account = + World.UserAccountService.GetUserAccount( + World.RegionInfo.ScopeID, + destId); + + if (account == null) + { + llSay(0, "Can't find destination "+destId.ToString()); + return; + } + } + // destination is an avatar InventoryItemBase agentItem = World.MoveTaskInventoryItem(destId, UUID.Zero, m_host, objId); @@ -4037,12 +4058,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //This delay should only occur when giving inventory to avatars. ScriptSleep(3000); } - else - { - // destination is an object - World.MoveTaskInventoryItem(destId, m_host, objId); - } - } [DebuggerNonUserCode]