From 57519b6dba97d7e7a2de71af9d58c93b4750bde8 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 16 Jan 2008 18:35:34 +0000 Subject: * Store task inventory when an object is taken into agent inventory * This means that you can take an object from a region and rez it somewhere else, with its inventory intact. * As for earlier, at this stage only scripts can be placed in inventory * This isn't an efficient implementation, a better one will probably need to come along soonish --- .../Region/Environment/Scenes/Scene.Inventory.cs | 17 ++-- .../Scenes/SceneObjectGroup.Inventory.cs | 18 ++--- .../Region/Environment/Scenes/SceneObjectGroup.cs | 12 ++- .../Scenes/SceneObjectPart.Inventory.cs | 90 +++++++++++++--------- .../Region/Environment/Scenes/SceneObjectPart.cs | 13 ++++ .../Region/Environment/Scenes/SceneXmlLoader.cs | 4 +- .../OpenSim.DataStore.MSSQL/MSSQLDataStore.cs | 4 +- 7 files changed, 98 insertions(+), 60 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 2fd4301..10f4141 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -184,21 +184,21 @@ namespace OpenSim.Region.Environment.Scenes } // Create new asset - // XXX Hardcoding the numbers is a temporary measure - need an enumeration for this - AssetBase asset = - CreateAsset(item.name, item.desc, 10, 10, data); + // XXX Hardcoding the numbers is a temporary measure - need an enumeration for this + // There may well be one in libsecondlife + AssetBase asset = CreateAsset(item.Name, item.Description, 10, 10, data); AssetCache.AddAsset(asset); // Update item with new asset - item.asset_id = asset.FullID; + item.AssetID = asset.FullID; group.UpdateInventoryItem(item); group.GetProperites(remoteClient); // Trigger rerunning of script (use TriggerRezScript event, see RezScript) if (isScriptRunning) { - group.StopScript(part.LocalID, item.item_id); - group.StartScript(part.LocalID, item.item_id); + group.StopScript(part.LocalID, item.ItemID); + group.StartScript(part.LocalID, item.ItemID); } } @@ -750,12 +750,14 @@ namespace OpenSim.Region.Environment.Scenes private void AddRezObject(string xmlData, LLVector3 pos) { SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); - group.GenerateNewIDs(); + group.ResetIDs(); AddEntity(group); group.AbsolutePosition = pos; SceneObjectPart rootPart = group.GetChildPart(group.UUID); rootPart.ApplySanePermissions(); group.ApplyPhysics(m_physicalPrim); + group.StartScripts(); + //bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0)&& m_physicalPrim); //if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) //{ @@ -772,6 +774,7 @@ namespace OpenSim.Region.Environment.Scenes // rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); // } + // rootPart.ScheduleFullUpdate(); } } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs index a092f5b..c7f5852 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs @@ -169,14 +169,14 @@ namespace OpenSim.Region.Environment.Scenes { TaskInventoryItem taskItem = new TaskInventoryItem(); - taskItem.item_id = newItemId; - taskItem.asset_id = item.assetID; - taskItem.name = item.inventoryName; - taskItem.desc = item.inventoryDescription; - taskItem.owner_id = item.avatarID; - taskItem.creator_id = item.creatorsID; - taskItem.type = item.assetType; - taskItem.inv_type = item.invType; + taskItem.ItemID = newItemId; + taskItem.AssetID = item.assetID; + taskItem.Name = item.inventoryName; + taskItem.Description = item.inventoryDescription; + taskItem.OwnerID = item.avatarID; + taskItem.CreatorID = item.creatorsID; + taskItem.Type = item.assetType; + taskItem.InvType = item.invType; part.AddInventoryItem(taskItem); // It might seem somewhat crude to update the whole group for a single prim inventory change, @@ -250,7 +250,7 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Error( "PRIMINVENTORY", "Couldn't find prim ID {0} to update item {1}, {2}", - item.ParentPartID, item.name, item.item_id); + item.ParentPartID, item.Name, item.ItemID); } return false; diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 2e0b916..0b7f2a4 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -609,15 +609,19 @@ namespace OpenSim.Region.Environment.Scenes SetPartAsNonRoot(newPart); } - - public void GenerateNewIDs() + /// + /// Reset the LLUUIDs for all the prims that make up this group. + /// + /// This is called by methods which want to add a new group to an existing scene, in order + /// to ensure that there are no clashes with groups already present. + /// + public void ResetIDs() { List partsList = new List(m_parts.Values); m_parts.Clear(); foreach (SceneObjectPart part in partsList) { - part.UUID = LLUUID.Random(); - part.LinkNum = m_parts.Count; + part.ResetIDs(m_parts.Count); m_parts.Add(part.UUID, part); } } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs index fc74c4e..5132a6c 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs @@ -57,30 +57,46 @@ namespace OpenSim.Region.Environment.Scenes get { return m_folderID; } set { m_folderID = value; } } + + /// + /// Serial count for inventory file , used to tell if inventory has changed + /// no need for this to be part of Database backup + /// + protected uint m_inventorySerial = 0; + + public uint InventorySerial + { + get { return m_inventorySerial; } + set { m_inventorySerial = value; } + } /// /// Holds in memory prim inventory /// - protected IDictionary m_taskInventory - = new Dictionary(); + protected TaskInventoryDictionary m_taskInventory = new TaskInventoryDictionary(); - [XmlIgnore] - public IDictionary TaskInventory + public TaskInventoryDictionary TaskInventory { get { return m_taskInventory; } + set { m_taskInventory = value; } } /// - /// Serial count for inventory file , used to tell if inventory has changed - /// no need for this to be part of Database backup + /// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating + /// new ones or setting existing UUIDs to the correct parent UUIDs /// - protected uint m_inventorySerial = 0; - - public uint InventorySerial + /// public void AddInventoryItem(TaskInventoryItem item) { - item.parent_id = m_folderID; - item.creation_date = 1000; + item.ParentID = m_folderID; + item.CreationDate = 1000; item.ParentPartID = UUID; - m_taskInventory.Add(item.item_id, item); + m_taskInventory.Add(item.ItemID, item); m_inventorySerial++; } @@ -188,7 +204,7 @@ namespace OpenSim.Region.Environment.Scenes { foreach (TaskInventoryItem item in items) { - m_taskInventory.Add(item.item_id, item); + m_taskInventory.Add(item.ItemID, item); } m_inventorySerial++; @@ -224,9 +240,9 @@ namespace OpenSim.Region.Environment.Scenes /// false if the item did not exist, true if the update occurred succesfully public bool UpdateInventoryItem(TaskInventoryItem item) { - if (m_taskInventory.ContainsKey(item.item_id)) + if (m_taskInventory.ContainsKey(item.ItemID)) { - m_taskInventory[item.item_id] = item; + m_taskInventory[item.ItemID] = item; m_inventorySerial++; return true; @@ -236,7 +252,7 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Error( "PRIMINVENTORY", "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", - item.item_id, Name, UUID); + item.ItemID, Name, UUID); } return false; @@ -252,7 +268,7 @@ namespace OpenSim.Region.Environment.Scenes { if (m_taskInventory.ContainsKey(itemID)) { - int type = m_taskInventory[itemID].inv_type; + int type = m_taskInventory[itemID].InvType; m_taskInventory.Remove(itemID); m_inventorySerial++; @@ -296,8 +312,8 @@ namespace OpenSim.Region.Environment.Scenes foreach (TaskInventoryItem item in m_taskInventory.Values) { invString.AddItemStart(); - invString.AddNameValueLine("item_id", item.item_id.ToString()); - invString.AddNameValueLine("parent_id", item.parent_id.ToString()); + invString.AddNameValueLine("item_id", item.ItemID.ToString()); + invString.AddNameValueLine("parent_id", item.ParentID.ToString()); invString.AddPermissionsStart(); invString.AddNameValueLine("base_mask", "0x7FFFFFFF"); @@ -305,19 +321,19 @@ namespace OpenSim.Region.Environment.Scenes invString.AddNameValueLine("group_mask", "0x7FFFFFFF"); invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF"); invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF"); - invString.AddNameValueLine("creator_id", item.creator_id.ToString()); - invString.AddNameValueLine("owner_id", item.owner_id.ToString()); - invString.AddNameValueLine("last_owner_id", item.last_owner_id.ToString()); - invString.AddNameValueLine("group_id", item.group_id.ToString()); + invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); + invString.AddNameValueLine("owner_id", item.OwnerID.ToString()); + invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); + invString.AddNameValueLine("group_id", item.GroupID.ToString()); invString.AddSectionEnd(); - invString.AddNameValueLine("asset_id", item.asset_id.ToString()); - invString.AddNameValueLine("type", TaskInventoryItem.Types[item.type]); - invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.inv_type]); + invString.AddNameValueLine("asset_id", item.AssetID.ToString()); + invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); + invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); invString.AddNameValueLine("flags", "0x00"); - invString.AddNameValueLine("name", item.name + "|"); - invString.AddNameValueLine("desc", item.desc + "|"); - invString.AddNameValueLine("creation_date", item.creation_date.ToString()); + invString.AddNameValueLine("name", item.Name + "|"); + invString.AddNameValueLine("desc", item.Description + "|"); + invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); invString.AddSectionEnd(); } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index c1522bc..93073c1 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -991,6 +991,19 @@ namespace OpenSim.Region.Environment.Scenes } #endregion + + /// + /// Reset LLUUIDs for this part. This involves generate this part's own LLUUID and + /// generating new LLUUIDs for all the items in the inventory. + /// + ///