From ac12ace6f1f837cfe934ddc69438796ad174c84f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 May 2011 02:46:13 +0100 Subject: Prevent viewer 2 from creating a duplicate outfit inventory links. I believe this is safe since there is a 1-1 correspondence between link item and worn item (i.e. you can't be wearing the same item at two spots simultaneously in one outfit). This should stop lots of duplicate links being created when viewer 2 is used. However, this doesn't prevent broken inventory links, which I believe is timing related since the effect is not consistent (e.g. keep relogging and the viewer should end up seeing them correctly) . I think we actually see this problem on viewer 1 as well. It might be easier just to implement the Fetch*2 inventory caps which are documented at http://wiki.secondlife.com/wiki/Inventory_API. WebFetch* has been deprecated by Linden Lab since viewer 2.5.1 and according to the sl wiki, "has numerous bugs". --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 31 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index cd01a05..523b7f5 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -904,11 +904,25 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Link an inventory item to an existing item. + /// + /// + /// + /// + /// + /// + /// + /// + /// /param> + /// private void HandleLinkInventoryItem(IClientAPI remoteClient, UUID transActionID, UUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, UUID olditemID) { - m_log.DebugFormat("[AGENT INVENTORY]: Received request to create inventory item link {0} in folder {1} pointing to {2}", name, folderID, olditemID); + m_log.DebugFormat( + "[AGENT INVENTORY]: Received request from {0} to create inventory item link {1} in folder {2} pointing to {3}", + remoteClient.Name, name, folderID, olditemID); if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) return; @@ -916,7 +930,20 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence presence; if (TryGetScenePresence(remoteClient.AgentId, out presence)) { -// byte[] data = null; + bool linkAlreadyExists = false; + List existingItems = InventoryService.GetFolderItems(remoteClient.AgentId, folderID); + foreach (InventoryItemBase item in existingItems) + if (item.AssetID == olditemID) + linkAlreadyExists = true; + + if (linkAlreadyExists) + { + m_log.WarnFormat( + "[AGENT INVENTORY]: Ignoring request from {0} to create item link {1} in folder {2} pointing to {3} since a link already exists", + remoteClient.Name, name, folderID, olditemID); + + return; + } AssetBase asset = new AssetBase(); asset.FullID = olditemID; -- cgit v1.1 From 9988bff9e3074f470ac57cd052674bcf816d7d8f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 12 May 2011 03:18:53 +0100 Subject: Add a smidgen of method doc about the fact that item links reuse the asset id item slot --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 523b7f5..a65ceeb 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -907,6 +907,10 @@ namespace OpenSim.Region.Framework.Scenes /// /// Link an inventory item to an existing item. /// + /// + /// The linkee item id is placed in the asset id slot. This appears to be what the viewer expects when + /// it receives inventory information. + /// /// /// /// -- cgit v1.1 From 5f9edd195c702fac57ab76bca1c0357bce224868 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 13 May 2011 03:24:19 +0100 Subject: Fix broken inventory links on viewer 2. It appears that if the viewer requests a folder containing links, we must also send the folders that contain the link targets first. This was tested with Kokua 0.1.0 WIP though I predict it will also work with other viewer 2s --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index a65ceeb..3bf2c2b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1382,11 +1382,28 @@ namespace OpenSim.Region.Framework.Scenes InventoryFolderBase containingFolder = new InventoryFolderBase(folder.ID, client.AgentId); containingFolder = InventoryService.GetFolder(containingFolder); - //m_log.DebugFormat("[AGENT INVENTORY]: Sending inventory folder contents ({0} nodes) for \"{1}\" to {2} {3}", - // contents.Folders.Count + contents.Items.Count, containingFolder.Name, client.FirstName, client.LastName); +// m_log.DebugFormat("[AGENT INVENTORY]: Sending inventory folder contents ({0} nodes) for \"{1}\" to {2} {3}", +// contents.Folders.Count + contents.Items.Count, containingFolder.Name, client.FirstName, client.LastName); if (containingFolder != null && containingFolder != null) + { + // If the folder requested contains links, then we need to send those folders first, otherwise the links + // will be broken in the viewer. + HashSet linkedItemFolderIdsToSend = new HashSet(); + foreach (InventoryItemBase item in contents.Items) + { + if (item.AssetType == (int)AssetType.Link) + { + InventoryItemBase linkedItem = InventoryService.GetItem(new InventoryItemBase(item.AssetID)); + linkedItemFolderIdsToSend.Add(linkedItem.Folder); + } + } + + foreach (UUID linkedItemFolderId in linkedItemFolderIdsToSend) + SendInventoryUpdate(client, new InventoryFolderBase(linkedItemFolderId), false, true); + client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, containingFolder.Version, fetchFolders, fetchItems); + } } /// -- cgit v1.1