From 42bc256e4fdd1b978b59fba117a78899b5a25c49 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 21 Dec 2007 19:47:45 +0000 Subject: Refix bug where inventory textures don't appear in prim edit texture selection box unless previously expanded in inventory. --- .../Cache/UserProfileCacheService.cs | 21 +- OpenSim/Framework/IClientAPI.cs | 4 +- OpenSim/Region/ClientStack/ClientView.cs | 244 ++++++++++++--------- .../Region/Examples/SimpleApp/MyNpcCharacter.cs | 6 +- 4 files changed, 161 insertions(+), 114 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index bf7f5c1..6a7be78 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -176,11 +176,14 @@ namespace OpenSim.Framework.Communications.Cache public void HandleFetchInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) { + // XXX We're not handling sortOrder yet! + InventoryFolderImpl fold = null; if (folderID == libraryRoot.folderID) { - remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, libraryRoot.folderID, - libraryRoot.RequestListOfItems(), libraryRoot.RequestListOfFolders(), libraryRoot.SubFoldersCount); + remoteClient.SendInventoryFolderDetails( + libraryRoot.agentID, libraryRoot.folderID, libraryRoot.RequestListOfItems(), + libraryRoot.RequestListOfFolders(), fetchFolders, fetchItems); return; } @@ -188,7 +191,9 @@ namespace OpenSim.Framework.Communications.Cache if ((fold = libraryRoot.HasSubFolder(folderID)) != null) { System.Console.WriteLine("fetching librarysubfolder"); - remoteClient.SendInventoryFolderDetails(libraryRoot.agentID, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fold.SubFoldersCount); + remoteClient.SendInventoryFolderDetails( + libraryRoot.agentID, folderID, fold.RequestListOfItems(), + fold.RequestListOfFolders(), fetchFolders, fetchItems); return; } @@ -203,15 +208,19 @@ namespace OpenSim.Framework.Communications.Cache System.Console.Write("fetching root folder"); if (fetchItems) { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, - userProfile.RootFolder.RequestListOfItems(), userProfile.RootFolder.RequestListOfFolders(), userProfile.RootFolder.SubFoldersCount); + remoteClient.SendInventoryFolderDetails( + remoteClient.AgentId, folderID, userProfile.RootFolder.RequestListOfItems(), + userProfile.RootFolder.RequestListOfFolders(), + fetchFolders, fetchItems); } } else { if ((fold = userProfile.RootFolder.HasSubFolder(folderID)) != null) { - remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, fold.RequestListOfItems(), fold.RequestListOfFolders(), fold.SubFoldersCount); + remoteClient.SendInventoryFolderDetails( + remoteClient.AgentId, folderID, fold.RequestListOfItems(), + fold.RequestListOfFolders(), fetchFolders, fetchItems); return; } } diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 41afe27..8ba161a 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -540,7 +540,9 @@ namespace OpenSim.Framework void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity); - void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items, List folders, int subFoldersCount); + void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items, + List folders, bool fetchFolders, + bool fetchItems); void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item); /// diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 34186de..10fd7ae 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -898,136 +898,168 @@ namespace OpenSim.Region.ClientStack /// /// Send information about the items contained in a folder to the client. + /// + /// XXX This method needs some refactoring loving /// /// The owner of the folder /// The id of the folder /// The items contained in the folder identified by folderID - /// The number of subfolders contained in the given folder. This is necessary since - /// the client is expecting inventory packets which incorporate this number into the descendents field, even though - /// we send back no details of the folders themselves (only the items). - public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items, List folders, int subFoldersCount) + /// Do we need to send folder information? + /// Do we need to send item information? + public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items, + List folders, + bool fetchFolders, bool fetchItems) { Encoding enc = Encoding.ASCII; uint FULL_MASK_PERMISSIONS = 2147483647; - InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); - - int count = 0; - if (items.Count < 40) - { - descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count]; - // In the very first packet, also include the sub folders count so that the total descendents the - // client receives matches its expectations. Subsequent inventory packets need contain only the count - // of the number of items actually in them. - descend.AgentData.Descendents = items.Count + subFoldersCount; - } - else - { - descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[40]; - // In the very first packet, also include the sub folders count so that the total descendents the - // client receives matches its expectations. Subsequent inventory packets need contain only the count - // of the number of items actually in them. - descend.AgentData.Descendents = 40 + subFoldersCount; - } - - int i = 0; - foreach (InventoryItemBase item in items) + + if (fetchItems) { - descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); - descend.ItemData[i].ItemID = item.inventoryID; - descend.ItemData[i].AssetID = item.assetID; - descend.ItemData[i].CreatorID = item.creatorsID; - descend.ItemData[i].BaseMask = item.inventoryBasePermissions; - descend.ItemData[i].CreationDate = 1000; - descend.ItemData[i].Description = Helpers.StringToField(item.inventoryDescription); - descend.ItemData[i].EveryoneMask = item.inventoryEveryOnePermissions; - descend.ItemData[i].Flags = 1; - descend.ItemData[i].FolderID = item.parentFolderID; - descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); - descend.ItemData[i].GroupMask = 0; - descend.ItemData[i].InvType = (sbyte)item.invType; - descend.ItemData[i].Name = Helpers.StringToField(item.inventoryName); - descend.ItemData[i].NextOwnerMask = item.inventoryNextPermissions; - descend.ItemData[i].OwnerID = item.avatarID; - descend.ItemData[i].OwnerMask = item.inventoryCurrentPermissions; - descend.ItemData[i].SalePrice = 0; - descend.ItemData[i].SaleType = 0; - descend.ItemData[i].Type = (sbyte)item.assetType; - descend.ItemData[i].CRC = - Helpers.InventoryCRC(descend.ItemData[i].CreationDate, descend.ItemData[i].SaleType, - descend.ItemData[i].InvType, descend.ItemData[i].Type, - descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, descend.ItemData[i].SalePrice, - descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, - descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, descend.ItemData[i].EveryoneMask, - descend.ItemData[i].Flags, descend.ItemData[i].OwnerMask, descend.ItemData[i].GroupMask, item.inventoryCurrentPermissions); - - i++; - count++; - if (i == 40) + InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); + + if (items.Count < 40) { - OutPacket(descend, ThrottleOutPacketType.Asset); - - if ((items.Count - count) > 0) + descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count]; + descend.AgentData.Descendents = items.Count; + } + else + { + descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[40]; + descend.AgentData.Descendents = 40; + } + + // Even if we aren't fetching the folders, we still need to include the folder count + // in the total number of descendents. Failure to do so will cause subtle bugs such + // as the failure of textures which haven't been expanded in inventory to show up + // in the texture prim edit selection panel. + if (!fetchFolders) + { + descend.AgentData.Descendents += folders.Count; + } + + int count = 0; + int i = 0; + foreach (InventoryItemBase item in items) + { + descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); + descend.ItemData[i].ItemID = item.inventoryID; + descend.ItemData[i].AssetID = item.assetID; + descend.ItemData[i].CreatorID = item.creatorsID; + descend.ItemData[i].BaseMask = item.inventoryBasePermissions; + descend.ItemData[i].CreationDate = 1000; + descend.ItemData[i].Description = Helpers.StringToField(item.inventoryDescription); + descend.ItemData[i].EveryoneMask = item.inventoryEveryOnePermissions; + descend.ItemData[i].Flags = 1; + descend.ItemData[i].FolderID = item.parentFolderID; + descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); + descend.ItemData[i].GroupMask = 0; + descend.ItemData[i].InvType = (sbyte)item.invType; + descend.ItemData[i].Name = Helpers.StringToField(item.inventoryName); + descend.ItemData[i].NextOwnerMask = item.inventoryNextPermissions; + descend.ItemData[i].OwnerID = item.avatarID; + descend.ItemData[i].OwnerMask = item.inventoryCurrentPermissions; + descend.ItemData[i].SalePrice = 0; + descend.ItemData[i].SaleType = 0; + descend.ItemData[i].Type = (sbyte)item.assetType; + descend.ItemData[i].CRC = + Helpers.InventoryCRC(descend.ItemData[i].CreationDate, descend.ItemData[i].SaleType, + descend.ItemData[i].InvType, descend.ItemData[i].Type, + descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, descend.ItemData[i].SalePrice, + descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, + descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, descend.ItemData[i].EveryoneMask, + descend.ItemData[i].Flags, descend.ItemData[i].OwnerMask, descend.ItemData[i].GroupMask, item.inventoryCurrentPermissions); + + i++; + count++; + if (i == 40) { - descend = CreateInventoryDescendentsPacket(ownerID, folderID); - if ((items.Count - count) < 40) - { - descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count - count]; - descend.AgentData.Descendents = items.Count - count; - } - else + OutPacket(descend, ThrottleOutPacketType.Asset); + + if ((items.Count - count) > 0) { - descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[40]; - descend.AgentData.Descendents = 40; + descend = CreateInventoryDescendentsPacket(ownerID, folderID); + if ((items.Count - count) < 40) + { + descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count - count]; + descend.AgentData.Descendents = items.Count - count; + } + else + { + descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[40]; + descend.AgentData.Descendents = 40; + } + i = 0; } - i = 0; } } - } - - if (i < 40) - { - OutPacket(descend, ThrottleOutPacketType.Asset); + + if (i < 40) + { + OutPacket(descend, ThrottleOutPacketType.Asset); + } } //send subfolders - descend = CreateInventoryDescendentsPacket(ownerID, folderID); - descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders.Count]; - i = 0; - count = 0; - foreach (InventoryFolderBase folder in folders) + if (fetchFolders) { - descend.FolderData[i] = new InventoryDescendentsPacket.FolderDataBlock(); - descend.FolderData[i].FolderID = folder.folderID; - descend.FolderData[i].Name = Helpers.StringToField(folder.name); - descend.FolderData[i].ParentID = folder.parentID; - descend.FolderData[i].Type = (sbyte)folder.type; - i++; - count++; - if (i == 40) + InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); + + if (folders.Count < 40) { - OutPacket(descend, ThrottleOutPacketType.Asset); - - if ((folders.Count - count) > 0) + descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders.Count]; + descend.AgentData.Descendents = folders.Count; + } + else + { + descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[40]; + descend.AgentData.Descendents = 40; + } + + // Not sure if this scenario ever actually occurs, but nonetheless we include the items + // count even if we're not sending item data for the same reasons as above. + if (!fetchItems) + { + descend.AgentData.Descendents += items.Count; + } + + int i = 0; + int count = 0; + foreach (InventoryFolderBase folder in folders) + { + descend.FolderData[i] = new InventoryDescendentsPacket.FolderDataBlock(); + descend.FolderData[i].FolderID = folder.folderID; + descend.FolderData[i].Name = Helpers.StringToField(folder.name); + descend.FolderData[i].ParentID = folder.parentID; + descend.FolderData[i].Type = (sbyte)folder.type; + + i++; + count++; + if (i == 40) { - descend = CreateInventoryDescendentsPacket(ownerID, folderID); - if ((folders.Count - count) < 40) + OutPacket(descend, ThrottleOutPacketType.Asset); + + if ((folders.Count - count) > 0) { - descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[items.Count - count]; - descend.AgentData.Descendents = folders.Count - count; - } - else - { - descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[40]; - descend.AgentData.Descendents = 40; + descend = CreateInventoryDescendentsPacket(ownerID, folderID); + if ((folders.Count - count) < 40) + { + descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders.Count - count]; + descend.AgentData.Descendents = folders.Count - count; + } + else + { + descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[40]; + descend.AgentData.Descendents = 40; + } + i = 0; } - i = 0; } } - } - - if (i < 40) - { - OutPacket(descend, ThrottleOutPacketType.Asset); + + if (i < 40) + { + OutPacket(descend, ThrottleOutPacketType.Asset); + } } } diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs index 4722c13..b31784e 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs @@ -323,7 +323,11 @@ namespace SimpleApp { } - public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List items, List folders, int subFoldersCount) + public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, + List items, + List folders, + bool fetchFolders, + bool fetchItems) { } -- cgit v1.1