From 70361bceb8e9ca99ed950570831ac40af6f63ad0 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sat, 5 Jan 2008 22:48:36 +0000 Subject: Persistent prim inventory phase 3. Now retrieving prim item data from persistent store, but this doesn't yet show up for the client. Still no user functionality and not enabled in normal code. --- .../Region/Environment/Scenes/SceneObjectPart.cs | 13 ++- .../MonoSqliteDataStore.cs | 92 ++++++++++++++++------ 2 files changed, 77 insertions(+), 28 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index c0cfe9f..051884d 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -60,14 +60,21 @@ namespace OpenSim.Region.Environment.Scenes [XmlIgnore] public PhysicsActor PhysActor = null; - // Holds in memory prim inventory - protected Dictionary m_taskInventory + /// + /// Holds in memory prim inventory + /// + protected IDictionary m_taskInventory = new Dictionary(); [XmlIgnore] - public Dictionary TaskInventory + /// + /// Not really ideal to allow this to be set, but currently expedient for inserting a prim inventory + /// from persistence. + /// + public IDictionary TaskInventory { get { return m_taskInventory; } + set { m_taskInventory = value; } } public LLUUID LastOwnerID; diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs index 2de7e25..f9ab0c5 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs @@ -121,6 +121,7 @@ namespace OpenSim.DataStore.MonoSqlite { ds.Tables.Add(createItemsTable()); setupItemsCommands(itemsDa, conn); + itemsDa.Fill(ds.Tables["primitems"]); } ds.Tables.Add(createTerrainTable()); @@ -265,12 +266,14 @@ namespace OpenSim.DataStore.MonoSqlite { try { + SceneObjectPart prim = null; + string uuid = (string) primRow["UUID"]; string objID = (string) primRow["SceneGroupID"]; if (uuid == objID) //is new SceneObjectGroup ? { SceneObjectGroup group = new SceneObjectGroup(); - SceneObjectPart prim = buildPrim(primRow); + prim = buildPrim(primRow); DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); if (shapeRow != null) { @@ -290,7 +293,7 @@ namespace OpenSim.DataStore.MonoSqlite } else { - SceneObjectPart prim = buildPrim(primRow); + prim = buildPrim(primRow); DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); if (shapeRow != null) { @@ -305,8 +308,10 @@ namespace OpenSim.DataStore.MonoSqlite createdObjects[new LLUUID(objID)].AddPart(prim); } - // Add inventory restore code here, probably in a separate method. - + if (persistPrimInventories) + { + LoadItems(prim); + } } catch (Exception e) { @@ -326,25 +331,28 @@ namespace OpenSim.DataStore.MonoSqlite /// Load in a prim's persisted inventory. /// /// - /* - private void LoadPrimInventory(SceneObjectPart prim) + private void LoadItems(SceneObjectPart prim) { - String sql = String.Format("primID = '{0}'", primID); + MainLog.Instance.Verbose("DATASTORE", "Loading inventory for {0}, {1}", prim.Name, prim.UUID); + + DataTable dbItems = ds.Tables["primitems"]; + + String sql = String.Format("primID = '{0}'", prim.UUID.ToString()); DataRow[] dbItemRows = dbItems.Select(sql); - DataRow shapeRow = shapes.Rows.Find(Util.ToRawUuidString(prim.UUID)); - if (shapeRow != null) - { - prim.Shape = buildShape(shapeRow); - } - else - { - MainLog.Instance.Notice( - "No shape found for prim in storage, so setting default box shape"); - prim.Shape = PrimitiveBaseShape.Default; - } + IDictionary inventory + = new Dictionary(); + + foreach (DataRow row in dbItemRows) + { + SceneObjectPart.TaskInventoryItem item = buildItem(row); + inventory.Add(item.item_id, item); + + MainLog.Instance.Verbose("DATASTORE", "Restored item {0}, {1}", item.name, item.item_id); + } + + prim.TaskInventory = inventory; } - */ public void StoreTerrain(double[,] ter, LLUUID regionID) { @@ -699,11 +707,11 @@ namespace OpenSim.DataStore.MonoSqlite createCol(items, "lastOwnerID", typeof (String)); createCol(items, "groupID", typeof (String)); - createCol(items, "nextPermissions", typeof (Int32)); - createCol(items, "currentPermissions", typeof (Int32)); - createCol(items, "basePermissions", typeof (Int32)); - createCol(items, "everyonePermissions", typeof (Int32)); - createCol(items, "groupPermissions", typeof (Int32)); + createCol(items, "nextPermissions", typeof (UInt32)); + createCol(items, "currentPermissions", typeof (UInt32)); + createCol(items, "basePermissions", typeof (UInt32)); + createCol(items, "everyonePermissions", typeof (UInt32)); + createCol(items, "groupPermissions", typeof (UInt32)); items.PrimaryKey = new DataColumn[] {items.Columns["itemID"]}; @@ -877,6 +885,40 @@ namespace OpenSim.DataStore.MonoSqlite return prim; } + + /// + /// Build a prim inventory item from the persisted data. + /// + /// + /// + private SceneObjectPart.TaskInventoryItem buildItem(DataRow row) + { + SceneObjectPart.TaskInventoryItem taskItem = new SceneObjectPart.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.inv_type = (String)row["invType"]; + taskItem.type = (String)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.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"]); + + return taskItem; + } private LandData buildLandData(DataRow row) { @@ -1223,7 +1265,7 @@ namespace OpenSim.DataStore.MonoSqlite /// /// /// - private void addPrimInventory(LLUUID primID, Dictionary items) + private void addPrimInventory(LLUUID primID, IDictionary items) { MainLog.Instance.Verbose("DATASTORE", "Entered addPrimInventory with prim ID {0}", primID); -- cgit v1.1