Prim inventory phase 4. Properly recover the prim folder ID from storage. Scripts now show up in prim inventories after region restart.
Probably doesn't yet work for any items other than scripts. Still some work to do. No user functionality exposed. Not yet user tieable into normal code.afrisby
parent
1867fbaa67
commit
7cedb09869
|
@ -1151,20 +1151,26 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
MainLog.Instance.Warn(
|
MainLog.Instance.Warn(
|
||||||
"SCENE",
|
"SCENE",
|
||||||
"Couldn't find part {0} in object group {1} ({2}) to retreive prim inventory",
|
"Couldn't find part {0} in object group {1}, {2} to retreive prim inventory",
|
||||||
localID, LocalId, UUID);
|
localID, Name, UUID);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string RequestInventoryFile(uint localID, IXfer xferManager)
|
public void RequestInventoryFile(uint localID, IXfer xferManager)
|
||||||
{
|
{
|
||||||
SceneObjectPart part = GetChildPart(localID);
|
SceneObjectPart part = GetChildPart(localID);
|
||||||
if (part != null)
|
if (part != null)
|
||||||
{
|
{
|
||||||
part.RequestInventoryFile(xferManager);
|
part.RequestInventoryFile(xferManager);
|
||||||
}
|
}
|
||||||
return "";
|
else
|
||||||
|
{
|
||||||
|
MainLog.Instance.Warn(
|
||||||
|
"PRIMINVENTORY",
|
||||||
|
"Couldn't find part {0} in object group {1}, {2} to request inventory data",
|
||||||
|
localID, Name, UUID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AddInventoryItem(IClientAPI remoteClient, uint localID, InventoryItemBase item)
|
public bool AddInventoryItem(IClientAPI remoteClient, uint localID, InventoryItemBase item)
|
||||||
|
@ -1202,7 +1208,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
taskItem.owner_id = new LLUUID(item.avatarID.ToString());
|
taskItem.owner_id = new LLUUID(item.avatarID.ToString());
|
||||||
taskItem.creator_id = new LLUUID(item.creatorsID.ToString());
|
taskItem.creator_id = new LLUUID(item.creatorsID.ToString());
|
||||||
taskItem.type = SceneObjectPart.TaskInventoryItem.Types[item.assetType];
|
taskItem.type = SceneObjectPart.TaskInventoryItem.Types[item.assetType];
|
||||||
taskItem.inv_type = SceneObjectPart.TaskInventoryItem.Types[item.invType];
|
taskItem.inv_type = SceneObjectPart.TaskInventoryItem.InvTypes[item.invType];
|
||||||
part.AddInventoryItem(taskItem);
|
part.AddInventoryItem(taskItem);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,21 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647;
|
private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647;
|
||||||
private const uint FULL_MASK_PERMISSIONS_OWNER = 2147483647;
|
private const uint FULL_MASK_PERMISSIONS_OWNER = 2147483647;
|
||||||
private string m_inventoryFileName = "";
|
private string m_inventoryFileName = "";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The inventory folder for this prim
|
||||||
|
/// </summary>
|
||||||
private LLUUID m_folderID = LLUUID.Zero;
|
private LLUUID m_folderID = LLUUID.Zero;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Exposing this is not particularly good, but it's one of the least evils at the moment to see
|
||||||
|
/// folder id from prim inventory item data, since it's not (yet) actually stored with the prim.
|
||||||
|
/// </summary>
|
||||||
|
public LLUUID FolderID
|
||||||
|
{
|
||||||
|
get { return m_folderID; }
|
||||||
|
set { m_folderID = value; }
|
||||||
|
}
|
||||||
|
|
||||||
[XmlIgnore] public PhysicsActor PhysActor = null;
|
[XmlIgnore] public PhysicsActor PhysActor = null;
|
||||||
|
|
||||||
|
@ -67,14 +81,9 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
= new Dictionary<LLUUID, TaskInventoryItem>();
|
= new Dictionary<LLUUID, TaskInventoryItem>();
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
/// <summary>
|
|
||||||
/// Not really ideal to allow this to be set, but currently expedient for inserting a prim inventory
|
|
||||||
/// from persistence.
|
|
||||||
/// </summary>
|
|
||||||
public IDictionary<LLUUID, TaskInventoryItem> TaskInventory
|
public IDictionary<LLUUID, TaskInventoryItem> TaskInventory
|
||||||
{
|
{
|
||||||
get { return m_taskInventory; }
|
get { return m_taskInventory; }
|
||||||
set { m_taskInventory = value; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LLUUID LastOwnerID;
|
public LLUUID LastOwnerID;
|
||||||
|
@ -1059,6 +1068,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
#region Inventory
|
#region Inventory
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add an item to this prim's inventory.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item"></param>
|
||||||
public void AddInventoryItem(TaskInventoryItem item)
|
public void AddInventoryItem(TaskInventoryItem item)
|
||||||
{
|
{
|
||||||
item.parent_id = m_folderID;
|
item.parent_id = m_folderID;
|
||||||
|
@ -1067,6 +1080,21 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
m_taskInventory.Add(item.item_id, item);
|
m_taskInventory.Add(item.item_id, item);
|
||||||
m_inventorySerial++;
|
m_inventorySerial++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add a whole collection of items to the prim's inventory at once. We assume that the items already
|
||||||
|
/// have all their fields correctly filled out.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="items"></param>
|
||||||
|
public void AddInventoryItems(ICollection<TaskInventoryItem> items)
|
||||||
|
{
|
||||||
|
foreach (TaskInventoryItem item in items)
|
||||||
|
{
|
||||||
|
m_taskInventory.Add(item.item_id, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_inventorySerial++;
|
||||||
|
}
|
||||||
|
|
||||||
public int RemoveInventoryItem(IClientAPI remoteClient, uint localID, LLUUID itemID)
|
public int RemoveInventoryItem(IClientAPI remoteClient, uint localID, LLUUID itemID)
|
||||||
{
|
{
|
||||||
|
@ -1077,7 +1105,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
string type = m_taskInventory[itemID].inv_type;
|
string type = m_taskInventory[itemID].inv_type;
|
||||||
m_taskInventory.Remove(itemID);
|
m_taskInventory.Remove(itemID);
|
||||||
m_inventorySerial++;
|
m_inventorySerial++;
|
||||||
if (type == "lsltext")
|
if (type == "lsl_text")
|
||||||
{
|
{
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
@ -1110,7 +1138,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string RequestInventoryFile(IXfer xferManager)
|
public void RequestInventoryFile(IXfer xferManager)
|
||||||
{
|
{
|
||||||
byte[] fileData = new byte[0];
|
byte[] fileData = new byte[0];
|
||||||
InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, UUID);
|
InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, UUID);
|
||||||
|
@ -1141,12 +1169,16 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
invString.AddNameValueLine("creation_date", item.creation_date.ToString());
|
invString.AddNameValueLine("creation_date", item.creation_date.ToString());
|
||||||
invString.AddSectionEnd();
|
invString.AddSectionEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
fileData = Helpers.StringToField(invString.BuildString);
|
fileData = Helpers.StringToField(invString.BuildString);
|
||||||
|
|
||||||
|
// MainLog.Instance.Verbose(
|
||||||
|
// "PRIMINVENTORY", "RequestInventoryFile fileData: {0}", Helpers.FieldToUTF8String(fileData));
|
||||||
|
|
||||||
if (fileData.Length > 2)
|
if (fileData.Length > 2)
|
||||||
{
|
{
|
||||||
xferManager.AddNewFile(m_inventoryFileName, fileData);
|
xferManager.AddNewFile(m_inventoryFileName, fileData);
|
||||||
}
|
}
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -1707,21 +1739,43 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
public class TaskInventoryItem
|
public class TaskInventoryItem
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Inventory types
|
||||||
|
/// </summary>
|
||||||
|
public static string[] InvTypes = new string[]
|
||||||
|
{
|
||||||
|
"texture",
|
||||||
|
"sound",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"lsl_text",
|
||||||
|
""
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asset types
|
||||||
|
/// </summary>
|
||||||
public static string[] Types = new string[]
|
public static string[] Types = new string[]
|
||||||
{
|
{
|
||||||
"texture",
|
"texture",
|
||||||
"sound",
|
"sound",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"lsltext",
|
"lsltext",
|
||||||
""
|
""
|
||||||
};
|
};
|
||||||
|
|
||||||
public LLUUID item_id = LLUUID.Zero;
|
public LLUUID item_id = LLUUID.Zero;
|
||||||
public LLUUID parent_id = LLUUID.Zero; //parent folder id
|
public LLUUID parent_id = LLUUID.Zero; //parent folder id
|
||||||
|
|
|
@ -340,18 +340,24 @@ namespace OpenSim.DataStore.MonoSqlite
|
||||||
String sql = String.Format("primID = '{0}'", prim.UUID.ToString());
|
String sql = String.Format("primID = '{0}'", prim.UUID.ToString());
|
||||||
DataRow[] dbItemRows = dbItems.Select(sql);
|
DataRow[] dbItemRows = dbItems.Select(sql);
|
||||||
|
|
||||||
IDictionary<LLUUID, SceneObjectPart.TaskInventoryItem> inventory
|
IList<SceneObjectPart.TaskInventoryItem> inventory = new List<SceneObjectPart.TaskInventoryItem>();
|
||||||
= new Dictionary<LLUUID, SceneObjectPart.TaskInventoryItem>();
|
|
||||||
|
|
||||||
foreach (DataRow row in dbItemRows)
|
foreach (DataRow row in dbItemRows)
|
||||||
{
|
{
|
||||||
SceneObjectPart.TaskInventoryItem item = buildItem(row);
|
SceneObjectPart.TaskInventoryItem item = buildItem(row);
|
||||||
inventory.Add(item.item_id, item);
|
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.item_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
prim.TaskInventory = inventory;
|
prim.AddInventoryItems(inventory);
|
||||||
|
|
||||||
|
// XXX A nasty little hack to recover the folder id for the prim (which is currently stored in
|
||||||
|
// every item). This data should really be stored in the prim table itself.
|
||||||
|
if (dbItemRows.Length > 0)
|
||||||
|
{
|
||||||
|
prim.FolderID = inventory[0].parent_id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StoreTerrain(double[,] ter, LLUUID regionID)
|
public void StoreTerrain(double[,] ter, LLUUID regionID)
|
||||||
|
|
Loading…
Reference in New Issue