diff --git a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs index 26985b3f17..183a2f93cc 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLDataStore.cs @@ -163,6 +163,8 @@ namespace OpenSim.Framework.Data.MySQL public void RemoveObject(LLUUID obj, LLUUID regionUUID) { + MainLog.Instance.Verbose("DATASTORE", "Removing obj: {0} from region: {1}", obj.UUID, regionUUID); + DataTable prims = m_primTable; DataTable shapes = m_shapeTable; DataTable items = m_itemsTable; @@ -187,9 +189,9 @@ namespace OpenSim.Framework.Data.MySQL String sql = String.Format("primID = '{0}'", uuid); DataRow[] itemRows = items.Select(sql); - foreach (DataRow itemsRow in itemRows) + foreach (DataRow itemRow in itemRows) { - shapeRow.Delete(); + itemRow.Delete(); } } @@ -307,7 +309,7 @@ namespace OpenSim.Framework.Data.MySQL TaskInventoryItem item = buildItem(row); inventory.Add(item); - MainLog.Instance.Verbose("DATASTORE", "Restored item {0}, {1}", item.name, item.item_id); + MainLog.Instance.Verbose("DATASTORE", "Restored item {0}, {1}", item.Name, item.ItemID); } prim.AddInventoryItems(inventory); @@ -316,7 +318,7 @@ namespace OpenSim.Framework.Data.MySQL // every item). This data should really be stored in the prim table itself. if (dbItemRows.Length > 0) { - prim.FolderID = inventory[0].parent_id; + prim.FolderID = inventory[0].ParentID; } } @@ -853,27 +855,27 @@ namespace OpenSim.Framework.Data.MySQL { TaskInventoryItem taskItem = new TaskInventoryItem(); - taskItem.item_id = new LLUUID((String)row["itemID"]); - taskItem.ParentPartID = new LLUUID((String)row["primID"]); - taskItem.asset_id = new LLUUID((String)row["assetID"]); - taskItem.parent_id = new LLUUID((String)row["parentFolderID"]); + taskItem.ItemID = new LLUUID((String)row["itemID"]); + taskItem.ParentPartID = new LLUUID((String)row["primID"]); + taskItem.AssetID = new LLUUID((String)row["assetID"]); + taskItem.ParentID = new LLUUID((String)row["parentFolderID"]); - taskItem.inv_type = Convert.ToInt32(row["invType"]); - taskItem.type = Convert.ToInt32(row["assetType"]); + taskItem.InvType = Convert.ToInt32(row["invType"]); + taskItem.Type = Convert.ToInt32(row["assetType"]); - taskItem.name = (String)row["name"]; - taskItem.desc = (String)row["description"]; - taskItem.creation_date = Convert.ToUInt32(row["creationDate"]); - taskItem.creator_id = new LLUUID((String)row["creatorID"]); - taskItem.owner_id = new LLUUID((String)row["ownerID"]); - taskItem.last_owner_id = new LLUUID((String)row["lastOwnerID"]); - taskItem.group_id = new LLUUID((String)row["groupID"]); + taskItem.Name = (String)row["name"]; + taskItem.Description = (String)row["description"]; + taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); + taskItem.CreatorID = new LLUUID((String)row["creatorID"]); + taskItem.OwnerID = new LLUUID((String)row["ownerID"]); + taskItem.LastOwnerID = new LLUUID((String)row["lastOwnerID"]); + taskItem.GroupID = new LLUUID((String)row["groupID"]); - taskItem.next_owner_mask = Convert.ToUInt32(row["nextPermissions"]); - taskItem.owner_mask = Convert.ToUInt32(row["currentPermissions"]); - taskItem.base_mask = Convert.ToUInt32(row["basePermissions"]); - taskItem.everyone_mask = Convert.ToUInt32(row["everyonePermissions"]); - taskItem.group_mask = Convert.ToUInt32(row["groupPermissions"]); + taskItem.NextOwnerMask = Convert.ToUInt32(row["nextPermissions"]); + taskItem.OwnerMask = Convert.ToUInt32(row["currentPermissions"]); + taskItem.BaseMask = Convert.ToUInt32(row["basePermissions"]); + taskItem.EveryoneMask = Convert.ToUInt32(row["everyonePermissions"]); + taskItem.GroupMask = Convert.ToUInt32(row["groupPermissions"]); return taskItem; } @@ -1023,26 +1025,26 @@ namespace OpenSim.Framework.Data.MySQL private void fillItemRow(DataRow row, TaskInventoryItem taskItem) { - row["itemID"] = taskItem.item_id; + row["itemID"] = taskItem.ItemID; row["primID"] = taskItem.ParentPartID; - row["assetID"] = taskItem.asset_id; - row["parentFolderID"] = taskItem.parent_id; + row["assetID"] = taskItem.AssetID; + row["parentFolderID"] = taskItem.ParentID; - row["invType"] = taskItem.inv_type; - row["assetType"] = taskItem.type; + row["invType"] = taskItem.InvType; + row["assetType"] = taskItem.Type; - row["name"] = taskItem.name; - row["description"] = taskItem.desc; - row["creationDate"] = taskItem.creation_date; - row["creatorID"] = taskItem.creator_id; - row["ownerID"] = taskItem.owner_id; - row["lastOwnerID"] = taskItem.last_owner_id; - row["groupID"] = taskItem.group_id; - row["nextPermissions"] = taskItem.next_owner_mask; - row["currentPermissions"] = taskItem.owner_mask; - row["basePermissions"] = taskItem.base_mask; - row["everyonePermissions"] = taskItem.everyone_mask; - row["groupPermissions"] = taskItem.group_mask; + row["name"] = taskItem.Name; + row["description"] = taskItem.Description; + row["creationDate"] = taskItem.CreationDate; + row["creatorID"] = taskItem.CreatorID; + row["ownerID"] = taskItem.OwnerID; + row["lastOwnerID"] = taskItem.LastOwnerID; + row["groupID"] = taskItem.GroupID; + row["nextPermissions"] = taskItem.NextOwnerMask; + row["currentPermissions"] = taskItem.OwnerMask; + row["basePermissions"] = taskItem.BaseMask; + row["everyonePermissions"] = taskItem.EveryoneMask; + row["groupPermissions"] = taskItem.GroupMask; } private void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) @@ -1216,11 +1218,15 @@ namespace OpenSim.Framework.Data.MySQL // Build structures for manipulation purposes IDictionary dbItemsToRemove = new Dictionary(); - ICollection itemsToAdd - = new List(); + ICollection itemsToAdd = new List(); foreach (DataRow row in dbItemRows) { + MainLog.Instance.Verbose( + "DATASTORE", + "Found item {0}, {1} in prim id {2}", + row["name"], row["itemID"], primID); + dbItemsToRemove.Add((String)row["itemID"], row); } @@ -1232,6 +1238,11 @@ namespace OpenSim.Framework.Data.MySQL if (dbItemsToRemove.ContainsKey(rawItemId)) { + MainLog.Instance.Verbose( + "DATASTORE", + "Discarding item {0}, {1} from remove candidates for prim id {2}", + items[itemId].Name, rawItemId, primID); + dbItemsToRemove.Remove(rawItemId); } else @@ -1256,8 +1267,8 @@ namespace OpenSim.Framework.Data.MySQL { MainLog.Instance.Verbose( "DATASTORE", - "Adding item {0}, {1} to prim ID {1}", - newItem.name, newItem.item_id, newItem.ParentPartID); + "Adding item {0}, {1} to prim ID {2}", + newItem.Name, newItem.ItemID, newItem.ParentPartID); DataRow newItemRow = dbItems.NewRow(); fillItemRow(newItemRow, newItem); diff --git a/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs b/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs index 1fd5c47e1d..94c05e1b29 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteRegionData.cs @@ -205,6 +205,8 @@ namespace OpenSim.Framework.Data.SQLite public void RemoveObject(LLUUID obj, LLUUID regionUUID) { + MainLog.Instance.Verbose("DATASTORE", "Removing obj: {0} from region: {1}", obj.UUID, regionUUID); + DataTable prims = ds.Tables["prims"]; DataTable shapes = ds.Tables["primshapes"]; DataTable items = ds.Tables["primitems"]; @@ -229,9 +231,9 @@ namespace OpenSim.Framework.Data.SQLite String sql = String.Format("primID = '{0}'", uuid); DataRow[] itemRows = items.Select(sql); - foreach (DataRow itemsRow in itemRows) + foreach (DataRow itemRow in itemRows) { - itemsRow.Delete(); + itemRow.Delete(); } } @@ -351,7 +353,7 @@ namespace OpenSim.Framework.Data.SQLite TaskInventoryItem item = buildItem(row); inventory.Add(item); - MainLog.Instance.Verbose("DATASTORE", "Restored item {0}, {1}", item.name, item.item_id); + MainLog.Instance.Verbose("DATASTORE", "Restored item {0}, {1}", item.Name, item.ItemID); } prim.AddInventoryItems(inventory); @@ -360,7 +362,7 @@ namespace OpenSim.Framework.Data.SQLite // every item). This data should really be stored in the prim table itself. if (dbItemRows.Length > 0) { - prim.FolderID = inventory[0].parent_id; + prim.FolderID = inventory[0].ParentID; } } @@ -889,27 +891,27 @@ namespace OpenSim.Framework.Data.SQLite { TaskInventoryItem taskItem = new TaskInventoryItem(); - taskItem.item_id = new LLUUID((String)row["itemID"]); - taskItem.ParentPartID = new LLUUID((String)row["primID"]); - taskItem.asset_id = new LLUUID((String)row["assetID"]); - taskItem.parent_id = new LLUUID((String)row["parentFolderID"]); + taskItem.ItemID = new LLUUID((String)row["itemID"]); + taskItem.ParentPartID = new LLUUID((String)row["primID"]); + taskItem.AssetID = new LLUUID((String)row["assetID"]); + taskItem.ParentID = new LLUUID((String)row["parentFolderID"]); - taskItem.inv_type = Convert.ToInt32(row["invType"]); - taskItem.type = Convert.ToInt32(row["assetType"]); + taskItem.InvType = Convert.ToInt32(row["invType"]); + taskItem.Type = Convert.ToInt32(row["assetType"]); - taskItem.name = (String)row["name"]; - taskItem.desc = (String)row["description"]; - taskItem.creation_date = Convert.ToUInt32(row["creationDate"]); - taskItem.creator_id = new LLUUID((String)row["creatorID"]); - taskItem.owner_id = new LLUUID((String)row["ownerID"]); - taskItem.last_owner_id = new LLUUID((String)row["lastOwnerID"]); - taskItem.group_id = new LLUUID((String)row["groupID"]); + taskItem.Name = (String)row["name"]; + taskItem.Description = (String)row["description"]; + taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]); + taskItem.CreatorID = new LLUUID((String)row["creatorID"]); + taskItem.OwnerID = new LLUUID((String)row["ownerID"]); + taskItem.LastOwnerID = new LLUUID((String)row["lastOwnerID"]); + taskItem.GroupID = new LLUUID((String)row["groupID"]); - taskItem.next_owner_mask = Convert.ToUInt32(row["nextPermissions"]); - taskItem.owner_mask = Convert.ToUInt32(row["currentPermissions"]); - taskItem.base_mask = Convert.ToUInt32(row["basePermissions"]); - taskItem.everyone_mask = Convert.ToUInt32(row["everyonePermissions"]); - taskItem.group_mask = Convert.ToUInt32(row["groupPermissions"]); + taskItem.NextOwnerMask = Convert.ToUInt32(row["nextPermissions"]); + taskItem.OwnerMask = Convert.ToUInt32(row["currentPermissions"]); + taskItem.BaseMask = Convert.ToUInt32(row["basePermissions"]); + taskItem.EveryoneMask = Convert.ToUInt32(row["everyonePermissions"]); + taskItem.GroupMask = Convert.ToUInt32(row["groupPermissions"]); return taskItem; } @@ -1059,26 +1061,26 @@ namespace OpenSim.Framework.Data.SQLite private void fillItemRow(DataRow row, TaskInventoryItem taskItem) { - row["itemID"] = taskItem.item_id; + row["itemID"] = taskItem.ItemID; row["primID"] = taskItem.ParentPartID; - row["assetID"] = taskItem.asset_id; - row["parentFolderID"] = taskItem.parent_id; + row["assetID"] = taskItem.AssetID; + row["parentFolderID"] = taskItem.ParentID; - row["invType"] = taskItem.inv_type; - row["assetType"] = taskItem.type; + row["invType"] = taskItem.InvType; + row["assetType"] = taskItem.Type; - row["name"] = taskItem.name; - row["description"] = taskItem.desc; - row["creationDate"] = taskItem.creation_date; - row["creatorID"] = taskItem.creator_id; - row["ownerID"] = taskItem.owner_id; - row["lastOwnerID"] = taskItem.last_owner_id; - row["groupID"] = taskItem.group_id; - row["nextPermissions"] = taskItem.next_owner_mask; - row["currentPermissions"] = taskItem.owner_mask; - row["basePermissions"] = taskItem.base_mask; - row["everyonePermissions"] = taskItem.everyone_mask; - row["groupPermissions"] = taskItem.group_mask; + row["name"] = taskItem.Name; + row["description"] = taskItem.Description; + row["creationDate"] = taskItem.CreationDate; + row["creatorID"] = taskItem.CreatorID; + row["ownerID"] = taskItem.OwnerID; + row["lastOwnerID"] = taskItem.LastOwnerID; + row["groupID"] = taskItem.GroupID; + row["nextPermissions"] = taskItem.NextOwnerMask; + row["currentPermissions"] = taskItem.OwnerMask; + row["basePermissions"] = taskItem.BaseMask; + row["everyonePermissions"] = taskItem.EveryoneMask; + row["groupPermissions"] = taskItem.GroupMask; } private void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) @@ -1311,8 +1313,8 @@ namespace OpenSim.Framework.Data.SQLite { MainLog.Instance.Verbose( "DATASTORE", - "Adding item {0}, {1} to prim ID {1}", - newItem.name, newItem.item_id, newItem.ParentPartID); + "Adding item {0}, {1} to prim ID {2}", + newItem.Name, newItem.ItemID, newItem.ParentPartID); DataRow newItemRow = dbItems.NewRow(); fillItemRow(newItemRow, newItem); diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs index 107993b72f..6e163a9090 100644 --- a/OpenSim/Framework/TaskInventoryItem.cs +++ b/OpenSim/Framework/TaskInventoryItem.cs @@ -26,11 +26,78 @@ * */ +using System.Collections.Generic; +using System.Xml; +using System.Xml.Schema; +using System.Xml.Serialization; + using libsecondlife; using System; namespace OpenSim.Framework -{ +{ + public class TaskInventoryDictionary : Dictionary, IXmlSerializable + { + private static XmlSerializer tiiSerializer = new XmlSerializer(typeof(TaskInventoryItem)); + + // The alternative of simply serializing the list doesn't appear to work on mono, since + // we get a + // + // System.TypeInitializationException: An exception was thrown by the type initializer for OpenSim.Framework.TaskInventoryDictionary ---> System.ArgumentOutOfRangeException: < 0 + // Parameter name: length + // at System.String.Substring (Int32 startIndex, Int32 length) [0x00088] in /build/buildd/mono-1.2.4/mcs/class/corlib/System/String.cs:381 + // at System.Xml.Serialization.TypeTranslator.GetTypeData (System.Type runtimeType, System.String xmlDataType) [0x001f6] in /build/buildd/mono-1.2.4/mcs/class/System.XML/System.Xml.Serialization/TypeTranslator.cs:217 + // ... +// private static XmlSerializer tiiSerializer +// = new XmlSerializer(typeof(Dictionary.ValueCollection)); + + // see IXmlSerializable + public XmlSchema GetSchema() + { + return null; + } + + // see IXmlSerializable + public void ReadXml(XmlReader reader) + { + reader.Read(); + while (tiiSerializer.CanDeserialize(reader)) + { + TaskInventoryItem item = (TaskInventoryItem)tiiSerializer.Deserialize(reader); + Add(item.ItemID, item); + } + +// reader.Read(); +// while (reader.Name.Equals("TaskInventoryItem")) +// { +// TaskInventoryItem item = (TaskInventoryItem)tiiSerializer.Deserialize(reader); +// Add(item.ItemID, item); +// } + +// ICollection items +// = (ICollection)tiiSerializer.Deserialize(reader); +// +// foreach (TaskInventoryItem item in items) +// { +// Add(item.ItemID, item); +// } + } + + // see IXmlSerializable + public void WriteXml(XmlWriter writer) + { + foreach (TaskInventoryItem item in Values) + { + tiiSerializer.Serialize(writer, item); + } + + //tiiSerializer.Serialize(writer, Values); + } + } + + /// + /// Represents an item in a task inventory + /// public class TaskInventoryItem { /// @@ -75,27 +142,37 @@ namespace OpenSim.Framework "lsltext", String.Empty }; + + /// + /// Reset the LLUUIDs for this item. + /// + /// The new part ID to which this item belongs + public void ResetIDs(LLUUID partID) + { + ItemID = LLUUID.Random(); + ParentPartID = partID; + } - public LLUUID item_id = LLUUID.Zero; - public LLUUID parent_id = LLUUID.Zero; //parent folder id + public LLUUID ItemID = LLUUID.Zero; + public LLUUID ParentID = LLUUID.Zero; //parent folder id - public uint base_mask = FULL_MASK_PERMISSIONS_GENERAL; - public uint owner_mask = FULL_MASK_PERMISSIONS_GENERAL; - public uint group_mask = FULL_MASK_PERMISSIONS_GENERAL; - public uint everyone_mask = FULL_MASK_PERMISSIONS_GENERAL; - public uint next_owner_mask = FULL_MASK_PERMISSIONS_GENERAL; - public LLUUID creator_id = LLUUID.Zero; - public LLUUID owner_id = LLUUID.Zero; - public LLUUID last_owner_id = LLUUID.Zero; - public LLUUID group_id = LLUUID.Zero; + public uint BaseMask = FULL_MASK_PERMISSIONS_GENERAL; + public uint OwnerMask = FULL_MASK_PERMISSIONS_GENERAL; + public uint GroupMask = FULL_MASK_PERMISSIONS_GENERAL; + public uint EveryoneMask = FULL_MASK_PERMISSIONS_GENERAL; + public uint NextOwnerMask = FULL_MASK_PERMISSIONS_GENERAL; + public LLUUID CreatorID = LLUUID.Zero; + public LLUUID OwnerID = LLUUID.Zero; + public LLUUID LastOwnerID = LLUUID.Zero; + public LLUUID GroupID = LLUUID.Zero; - public LLUUID asset_id = LLUUID.Zero; - public int type = 0; - public int inv_type = 0; - public uint flags = 0; - public string name = String.Empty; - public string desc = String.Empty; - public uint creation_date = 0; + public LLUUID AssetID = LLUUID.Zero; + public int Type = 0; + public int InvType = 0; + public uint Flags = 0; + public string Name = String.Empty; + public string Description = String.Empty; + public uint CreationDate = 0; public LLUUID ParentPartID = LLUUID.Zero; } diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 2fd43019bb..10f4141fed 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 a092f5b6f2..c7f58521cf 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 2e0b916923..0b7f2a4b33 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 fc74c4e334..5132a6c861 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs @@ -57,19 +57,7 @@ namespace OpenSim.Region.Environment.Scenes get { return m_folderID; } set { m_folderID = value; } } - - /// - /// Holds in memory prim inventory - /// - protected IDictionary m_taskInventory - = new Dictionary(); - - [XmlIgnore] - public IDictionary TaskInventory - { - get { return m_taskInventory; } - } - + /// /// Serial count for inventory file , used to tell if inventory has changed /// no need for this to be part of Database backup @@ -79,8 +67,36 @@ namespace OpenSim.Region.Environment.Scenes public uint InventorySerial { get { return m_inventorySerial; } + set { m_inventorySerial = value; } + } + + /// + /// Holds in memory prim inventory + /// + protected TaskInventoryDictionary m_taskInventory = new TaskInventoryDictionary(); + + public TaskInventoryDictionary TaskInventory + { + get { return m_taskInventory; } + set { m_taskInventory = value; } } + /// + /// 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 + /// + /// 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 c1522bce3c..93073c1d01 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. + /// + ///