* 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
ThreadPoolClientBranch
Justin Clarke Casey 2008-01-16 18:35:34 +00:00
parent 795a339af5
commit 57519b6dba
10 changed files with 292 additions and 164 deletions

View File

@ -163,6 +163,8 @@ namespace OpenSim.Framework.Data.MySQL
public void RemoveObject(LLUUID obj, LLUUID regionUUID) 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 prims = m_primTable;
DataTable shapes = m_shapeTable; DataTable shapes = m_shapeTable;
DataTable items = m_itemsTable; DataTable items = m_itemsTable;
@ -187,9 +189,9 @@ namespace OpenSim.Framework.Data.MySQL
String sql = String.Format("primID = '{0}'", uuid); String sql = String.Format("primID = '{0}'", uuid);
DataRow[] itemRows = items.Select(sql); 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); TaskInventoryItem item = buildItem(row);
inventory.Add(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.ItemID);
} }
prim.AddInventoryItems(inventory); 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. // every item). This data should really be stored in the prim table itself.
if (dbItemRows.Length > 0) 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(); TaskInventoryItem taskItem = new TaskInventoryItem();
taskItem.item_id = new LLUUID((String)row["itemID"]); taskItem.ItemID = new LLUUID((String)row["itemID"]);
taskItem.ParentPartID = new LLUUID((String)row["primID"]); taskItem.ParentPartID = new LLUUID((String)row["primID"]);
taskItem.asset_id = new LLUUID((String)row["assetID"]); taskItem.AssetID = new LLUUID((String)row["assetID"]);
taskItem.parent_id = new LLUUID((String)row["parentFolderID"]); taskItem.ParentID = new LLUUID((String)row["parentFolderID"]);
taskItem.inv_type = Convert.ToInt32(row["invType"]); taskItem.InvType = Convert.ToInt32(row["invType"]);
taskItem.type = Convert.ToInt32(row["assetType"]); taskItem.Type = Convert.ToInt32(row["assetType"]);
taskItem.name = (String)row["name"]; taskItem.Name = (String)row["name"];
taskItem.desc = (String)row["description"]; taskItem.Description = (String)row["description"];
taskItem.creation_date = Convert.ToUInt32(row["creationDate"]); taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]);
taskItem.creator_id = new LLUUID((String)row["creatorID"]); taskItem.CreatorID = new LLUUID((String)row["creatorID"]);
taskItem.owner_id = new LLUUID((String)row["ownerID"]); taskItem.OwnerID = new LLUUID((String)row["ownerID"]);
taskItem.last_owner_id = new LLUUID((String)row["lastOwnerID"]); taskItem.LastOwnerID = new LLUUID((String)row["lastOwnerID"]);
taskItem.group_id = new LLUUID((String)row["groupID"]); taskItem.GroupID = new LLUUID((String)row["groupID"]);
taskItem.next_owner_mask = Convert.ToUInt32(row["nextPermissions"]); taskItem.NextOwnerMask = Convert.ToUInt32(row["nextPermissions"]);
taskItem.owner_mask = Convert.ToUInt32(row["currentPermissions"]); taskItem.OwnerMask = Convert.ToUInt32(row["currentPermissions"]);
taskItem.base_mask = Convert.ToUInt32(row["basePermissions"]); taskItem.BaseMask = Convert.ToUInt32(row["basePermissions"]);
taskItem.everyone_mask = Convert.ToUInt32(row["everyonePermissions"]); taskItem.EveryoneMask = Convert.ToUInt32(row["everyonePermissions"]);
taskItem.group_mask = Convert.ToUInt32(row["groupPermissions"]); taskItem.GroupMask = Convert.ToUInt32(row["groupPermissions"]);
return taskItem; return taskItem;
} }
@ -1023,26 +1025,26 @@ namespace OpenSim.Framework.Data.MySQL
private void fillItemRow(DataRow row, TaskInventoryItem taskItem) private void fillItemRow(DataRow row, TaskInventoryItem taskItem)
{ {
row["itemID"] = taskItem.item_id; row["itemID"] = taskItem.ItemID;
row["primID"] = taskItem.ParentPartID; row["primID"] = taskItem.ParentPartID;
row["assetID"] = taskItem.asset_id; row["assetID"] = taskItem.AssetID;
row["parentFolderID"] = taskItem.parent_id; row["parentFolderID"] = taskItem.ParentID;
row["invType"] = taskItem.inv_type; row["invType"] = taskItem.InvType;
row["assetType"] = taskItem.type; row["assetType"] = taskItem.Type;
row["name"] = taskItem.name; row["name"] = taskItem.Name;
row["description"] = taskItem.desc; row["description"] = taskItem.Description;
row["creationDate"] = taskItem.creation_date; row["creationDate"] = taskItem.CreationDate;
row["creatorID"] = taskItem.creator_id; row["creatorID"] = taskItem.CreatorID;
row["ownerID"] = taskItem.owner_id; row["ownerID"] = taskItem.OwnerID;
row["lastOwnerID"] = taskItem.last_owner_id; row["lastOwnerID"] = taskItem.LastOwnerID;
row["groupID"] = taskItem.group_id; row["groupID"] = taskItem.GroupID;
row["nextPermissions"] = taskItem.next_owner_mask; row["nextPermissions"] = taskItem.NextOwnerMask;
row["currentPermissions"] = taskItem.owner_mask; row["currentPermissions"] = taskItem.OwnerMask;
row["basePermissions"] = taskItem.base_mask; row["basePermissions"] = taskItem.BaseMask;
row["everyonePermissions"] = taskItem.everyone_mask; row["everyonePermissions"] = taskItem.EveryoneMask;
row["groupPermissions"] = taskItem.group_mask; row["groupPermissions"] = taskItem.GroupMask;
} }
private void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) private void fillLandRow(DataRow row, LandData land, LLUUID regionUUID)
@ -1216,11 +1218,15 @@ namespace OpenSim.Framework.Data.MySQL
// Build structures for manipulation purposes // Build structures for manipulation purposes
IDictionary<String, DataRow> dbItemsToRemove = new Dictionary<String, DataRow>(); IDictionary<String, DataRow> dbItemsToRemove = new Dictionary<String, DataRow>();
ICollection<TaskInventoryItem> itemsToAdd ICollection<TaskInventoryItem> itemsToAdd = new List<TaskInventoryItem>();
= new List<TaskInventoryItem>();
foreach (DataRow row in dbItemRows) 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); dbItemsToRemove.Add((String)row["itemID"], row);
} }
@ -1232,6 +1238,11 @@ namespace OpenSim.Framework.Data.MySQL
if (dbItemsToRemove.ContainsKey(rawItemId)) 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); dbItemsToRemove.Remove(rawItemId);
} }
else else
@ -1256,8 +1267,8 @@ namespace OpenSim.Framework.Data.MySQL
{ {
MainLog.Instance.Verbose( MainLog.Instance.Verbose(
"DATASTORE", "DATASTORE",
"Adding item {0}, {1} to prim ID {1}", "Adding item {0}, {1} to prim ID {2}",
newItem.name, newItem.item_id, newItem.ParentPartID); newItem.Name, newItem.ItemID, newItem.ParentPartID);
DataRow newItemRow = dbItems.NewRow(); DataRow newItemRow = dbItems.NewRow();
fillItemRow(newItemRow, newItem); fillItemRow(newItemRow, newItem);

View File

@ -205,6 +205,8 @@ namespace OpenSim.Framework.Data.SQLite
public void RemoveObject(LLUUID obj, LLUUID regionUUID) 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 prims = ds.Tables["prims"];
DataTable shapes = ds.Tables["primshapes"]; DataTable shapes = ds.Tables["primshapes"];
DataTable items = ds.Tables["primitems"]; DataTable items = ds.Tables["primitems"];
@ -229,9 +231,9 @@ namespace OpenSim.Framework.Data.SQLite
String sql = String.Format("primID = '{0}'", uuid); String sql = String.Format("primID = '{0}'", uuid);
DataRow[] itemRows = items.Select(sql); 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); TaskInventoryItem item = buildItem(row);
inventory.Add(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.ItemID);
} }
prim.AddInventoryItems(inventory); 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. // every item). This data should really be stored in the prim table itself.
if (dbItemRows.Length > 0) 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(); TaskInventoryItem taskItem = new TaskInventoryItem();
taskItem.item_id = new LLUUID((String)row["itemID"]); taskItem.ItemID = new LLUUID((String)row["itemID"]);
taskItem.ParentPartID = new LLUUID((String)row["primID"]); taskItem.ParentPartID = new LLUUID((String)row["primID"]);
taskItem.asset_id = new LLUUID((String)row["assetID"]); taskItem.AssetID = new LLUUID((String)row["assetID"]);
taskItem.parent_id = new LLUUID((String)row["parentFolderID"]); taskItem.ParentID = new LLUUID((String)row["parentFolderID"]);
taskItem.inv_type = Convert.ToInt32(row["invType"]); taskItem.InvType = Convert.ToInt32(row["invType"]);
taskItem.type = Convert.ToInt32(row["assetType"]); taskItem.Type = Convert.ToInt32(row["assetType"]);
taskItem.name = (String)row["name"]; taskItem.Name = (String)row["name"];
taskItem.desc = (String)row["description"]; taskItem.Description = (String)row["description"];
taskItem.creation_date = Convert.ToUInt32(row["creationDate"]); taskItem.CreationDate = Convert.ToUInt32(row["creationDate"]);
taskItem.creator_id = new LLUUID((String)row["creatorID"]); taskItem.CreatorID = new LLUUID((String)row["creatorID"]);
taskItem.owner_id = new LLUUID((String)row["ownerID"]); taskItem.OwnerID = new LLUUID((String)row["ownerID"]);
taskItem.last_owner_id = new LLUUID((String)row["lastOwnerID"]); taskItem.LastOwnerID = new LLUUID((String)row["lastOwnerID"]);
taskItem.group_id = new LLUUID((String)row["groupID"]); taskItem.GroupID = new LLUUID((String)row["groupID"]);
taskItem.next_owner_mask = Convert.ToUInt32(row["nextPermissions"]); taskItem.NextOwnerMask = Convert.ToUInt32(row["nextPermissions"]);
taskItem.owner_mask = Convert.ToUInt32(row["currentPermissions"]); taskItem.OwnerMask = Convert.ToUInt32(row["currentPermissions"]);
taskItem.base_mask = Convert.ToUInt32(row["basePermissions"]); taskItem.BaseMask = Convert.ToUInt32(row["basePermissions"]);
taskItem.everyone_mask = Convert.ToUInt32(row["everyonePermissions"]); taskItem.EveryoneMask = Convert.ToUInt32(row["everyonePermissions"]);
taskItem.group_mask = Convert.ToUInt32(row["groupPermissions"]); taskItem.GroupMask = Convert.ToUInt32(row["groupPermissions"]);
return taskItem; return taskItem;
} }
@ -1059,26 +1061,26 @@ namespace OpenSim.Framework.Data.SQLite
private void fillItemRow(DataRow row, TaskInventoryItem taskItem) private void fillItemRow(DataRow row, TaskInventoryItem taskItem)
{ {
row["itemID"] = taskItem.item_id; row["itemID"] = taskItem.ItemID;
row["primID"] = taskItem.ParentPartID; row["primID"] = taskItem.ParentPartID;
row["assetID"] = taskItem.asset_id; row["assetID"] = taskItem.AssetID;
row["parentFolderID"] = taskItem.parent_id; row["parentFolderID"] = taskItem.ParentID;
row["invType"] = taskItem.inv_type; row["invType"] = taskItem.InvType;
row["assetType"] = taskItem.type; row["assetType"] = taskItem.Type;
row["name"] = taskItem.name; row["name"] = taskItem.Name;
row["description"] = taskItem.desc; row["description"] = taskItem.Description;
row["creationDate"] = taskItem.creation_date; row["creationDate"] = taskItem.CreationDate;
row["creatorID"] = taskItem.creator_id; row["creatorID"] = taskItem.CreatorID;
row["ownerID"] = taskItem.owner_id; row["ownerID"] = taskItem.OwnerID;
row["lastOwnerID"] = taskItem.last_owner_id; row["lastOwnerID"] = taskItem.LastOwnerID;
row["groupID"] = taskItem.group_id; row["groupID"] = taskItem.GroupID;
row["nextPermissions"] = taskItem.next_owner_mask; row["nextPermissions"] = taskItem.NextOwnerMask;
row["currentPermissions"] = taskItem.owner_mask; row["currentPermissions"] = taskItem.OwnerMask;
row["basePermissions"] = taskItem.base_mask; row["basePermissions"] = taskItem.BaseMask;
row["everyonePermissions"] = taskItem.everyone_mask; row["everyonePermissions"] = taskItem.EveryoneMask;
row["groupPermissions"] = taskItem.group_mask; row["groupPermissions"] = taskItem.GroupMask;
} }
private void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) private void fillLandRow(DataRow row, LandData land, LLUUID regionUUID)
@ -1311,8 +1313,8 @@ namespace OpenSim.Framework.Data.SQLite
{ {
MainLog.Instance.Verbose( MainLog.Instance.Verbose(
"DATASTORE", "DATASTORE",
"Adding item {0}, {1} to prim ID {1}", "Adding item {0}, {1} to prim ID {2}",
newItem.name, newItem.item_id, newItem.ParentPartID); newItem.Name, newItem.ItemID, newItem.ParentPartID);
DataRow newItemRow = dbItems.NewRow(); DataRow newItemRow = dbItems.NewRow();
fillItemRow(newItemRow, newItem); fillItemRow(newItemRow, newItem);

View File

@ -26,11 +26,78 @@
* *
*/ */
using System.Collections.Generic;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using libsecondlife; using libsecondlife;
using System; using System;
namespace OpenSim.Framework namespace OpenSim.Framework
{ {
public class TaskInventoryDictionary : Dictionary<LLUUID, TaskInventoryItem>, 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<LLUUID, TaskInventoryItem>.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<TaskInventoryItem> items
// = (ICollection<TaskInventoryItem>)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);
}
}
/// <summary>
/// Represents an item in a task inventory
/// </summary>
public class TaskInventoryItem public class TaskInventoryItem
{ {
/// <summary> /// <summary>
@ -76,26 +143,36 @@ namespace OpenSim.Framework
String.Empty String.Empty
}; };
public LLUUID item_id = LLUUID.Zero; /// <summary>
public LLUUID parent_id = LLUUID.Zero; //parent folder id /// Reset the LLUUIDs for this item.
/// </summary>
/// <param name="partID">The new part ID to which this item belongs</param>
public void ResetIDs(LLUUID partID)
{
ItemID = LLUUID.Random();
ParentPartID = partID;
}
public uint base_mask = FULL_MASK_PERMISSIONS_GENERAL; public LLUUID ItemID = LLUUID.Zero;
public uint owner_mask = FULL_MASK_PERMISSIONS_GENERAL; public LLUUID ParentID = LLUUID.Zero; //parent folder id
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 LLUUID asset_id = LLUUID.Zero; public uint BaseMask = FULL_MASK_PERMISSIONS_GENERAL;
public int type = 0; public uint OwnerMask = FULL_MASK_PERMISSIONS_GENERAL;
public int inv_type = 0; public uint GroupMask = FULL_MASK_PERMISSIONS_GENERAL;
public uint flags = 0; public uint EveryoneMask = FULL_MASK_PERMISSIONS_GENERAL;
public string name = String.Empty; public uint NextOwnerMask = FULL_MASK_PERMISSIONS_GENERAL;
public string desc = String.Empty; public LLUUID CreatorID = LLUUID.Zero;
public uint creation_date = 0; public LLUUID OwnerID = LLUUID.Zero;
public LLUUID LastOwnerID = LLUUID.Zero;
public LLUUID GroupID = LLUUID.Zero;
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; public LLUUID ParentPartID = LLUUID.Zero;
} }

View File

@ -185,20 +185,20 @@ namespace OpenSim.Region.Environment.Scenes
// Create new asset // Create new asset
// XXX Hardcoding the numbers is a temporary measure - need an enumeration for this // XXX Hardcoding the numbers is a temporary measure - need an enumeration for this
AssetBase asset = // There may well be one in libsecondlife
CreateAsset(item.name, item.desc, 10, 10, data); AssetBase asset = CreateAsset(item.Name, item.Description, 10, 10, data);
AssetCache.AddAsset(asset); AssetCache.AddAsset(asset);
// Update item with new asset // Update item with new asset
item.asset_id = asset.FullID; item.AssetID = asset.FullID;
group.UpdateInventoryItem(item); group.UpdateInventoryItem(item);
group.GetProperites(remoteClient); group.GetProperites(remoteClient);
// Trigger rerunning of script (use TriggerRezScript event, see RezScript) // Trigger rerunning of script (use TriggerRezScript event, see RezScript)
if (isScriptRunning) if (isScriptRunning)
{ {
group.StopScript(part.LocalID, item.item_id); group.StopScript(part.LocalID, item.ItemID);
group.StartScript(part.LocalID, item.item_id); group.StartScript(part.LocalID, item.ItemID);
} }
} }
@ -750,12 +750,14 @@ namespace OpenSim.Region.Environment.Scenes
private void AddRezObject(string xmlData, LLVector3 pos) private void AddRezObject(string xmlData, LLVector3 pos)
{ {
SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData);
group.GenerateNewIDs(); group.ResetIDs();
AddEntity(group); AddEntity(group);
group.AbsolutePosition = pos; group.AbsolutePosition = pos;
SceneObjectPart rootPart = group.GetChildPart(group.UUID); SceneObjectPart rootPart = group.GetChildPart(group.UUID);
rootPart.ApplySanePermissions(); rootPart.ApplySanePermissions();
group.ApplyPhysics(m_physicalPrim); group.ApplyPhysics(m_physicalPrim);
group.StartScripts();
//bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0)&& m_physicalPrim); //bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0)&& m_physicalPrim);
//if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) //if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
//{ //{
@ -772,6 +774,7 @@ namespace OpenSim.Region.Environment.Scenes
// rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); // rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
// } // }
//
rootPart.ScheduleFullUpdate(); rootPart.ScheduleFullUpdate();
} }
} }

View File

@ -169,14 +169,14 @@ namespace OpenSim.Region.Environment.Scenes
{ {
TaskInventoryItem taskItem = new TaskInventoryItem(); TaskInventoryItem taskItem = new TaskInventoryItem();
taskItem.item_id = newItemId; taskItem.ItemID = newItemId;
taskItem.asset_id = item.assetID; taskItem.AssetID = item.assetID;
taskItem.name = item.inventoryName; taskItem.Name = item.inventoryName;
taskItem.desc = item.inventoryDescription; taskItem.Description = item.inventoryDescription;
taskItem.owner_id = item.avatarID; taskItem.OwnerID = item.avatarID;
taskItem.creator_id = item.creatorsID; taskItem.CreatorID = item.creatorsID;
taskItem.type = item.assetType; taskItem.Type = item.assetType;
taskItem.inv_type = item.invType; taskItem.InvType = item.invType;
part.AddInventoryItem(taskItem); part.AddInventoryItem(taskItem);
// It might seem somewhat crude to update the whole group for a single prim inventory change, // 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( MainLog.Instance.Error(
"PRIMINVENTORY", "PRIMINVENTORY",
"Couldn't find prim ID {0} to update item {1}, {2}", "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; return false;

View File

@ -609,15 +609,19 @@ namespace OpenSim.Region.Environment.Scenes
SetPartAsNonRoot(newPart); SetPartAsNonRoot(newPart);
} }
/// <summary>
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.
/// </summary>
public void ResetIDs()
{ {
List<SceneObjectPart> partsList = new List<SceneObjectPart>(m_parts.Values); List<SceneObjectPart> partsList = new List<SceneObjectPart>(m_parts.Values);
m_parts.Clear(); m_parts.Clear();
foreach (SceneObjectPart part in partsList) foreach (SceneObjectPart part in partsList)
{ {
part.UUID = LLUUID.Random(); part.ResetIDs(m_parts.Count);
part.LinkNum = m_parts.Count;
m_parts.Add(part.UUID, part); m_parts.Add(part.UUID, part);
} }
} }

View File

@ -58,18 +58,6 @@ namespace OpenSim.Region.Environment.Scenes
set { m_folderID = value; } set { m_folderID = value; }
} }
/// <summary>
/// Holds in memory prim inventory
/// </summary>
protected IDictionary<LLUUID, TaskInventoryItem> m_taskInventory
= new Dictionary<LLUUID, TaskInventoryItem>();
[XmlIgnore]
public IDictionary<LLUUID, TaskInventoryItem> TaskInventory
{
get { return m_taskInventory; }
}
/// <summary> /// <summary>
/// Serial count for inventory file , used to tell if inventory has changed /// Serial count for inventory file , used to tell if inventory has changed
/// no need for this to be part of Database backup /// no need for this to be part of Database backup
@ -79,8 +67,36 @@ namespace OpenSim.Region.Environment.Scenes
public uint InventorySerial public uint InventorySerial
{ {
get { return m_inventorySerial; } get { return m_inventorySerial; }
set { m_inventorySerial = value; }
} }
/// <summary>
/// Holds in memory prim inventory
/// </summary>
protected TaskInventoryDictionary m_taskInventory = new TaskInventoryDictionary();
public TaskInventoryDictionary TaskInventory
{
get { return m_taskInventory; }
set { m_taskInventory = value; }
}
/// <summary>
/// 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
/// </summary>
/// <param name="linkNum'>Link number for the part</param>
public void ResetInventoryIDs()
{
IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values);
TaskInventory.Clear();
foreach (TaskInventoryItem item in items)
{
item.ResetIDs(UUID);
TaskInventory.Add(item.ItemID, item);
}
}
/// <summary> /// <summary>
/// Start all the scripts contained in this prim's inventory /// Start all the scripts contained in this prim's inventory
@ -90,7 +106,7 @@ namespace OpenSim.Region.Environment.Scenes
foreach (TaskInventoryItem item in m_taskInventory.Values) foreach (TaskInventoryItem item in m_taskInventory.Values)
{ {
// XXX more hardcoding badness. Should be an enum in TaskInventoryItem // XXX more hardcoding badness. Should be an enum in TaskInventoryItem
if (10 == item.type) if (10 == item.Type)
{ {
StartScript(item); StartScript(item);
} }
@ -107,21 +123,21 @@ namespace OpenSim.Region.Environment.Scenes
// MainLog.Instance.Verbose( // MainLog.Instance.Verbose(
// "PRIMINVENTORY", // "PRIMINVENTORY",
// "Starting script {0}, {1} in prim {2}, {3}", // "Starting script {0}, {1} in prim {2}, {3}",
// item.name, item.item_id, Name, UUID); // item.Name, item.ItemID, Name, UUID);
AssetBase rezAsset = m_parentGroup.Scene.AssetCache.GetAsset(item.asset_id, false); AssetBase rezAsset = m_parentGroup.Scene.AssetCache.GetAsset(item.AssetID, false);
if (rezAsset != null) if (rezAsset != null)
{ {
string script = Helpers.FieldToUTF8String(rezAsset.Data); string script = Helpers.FieldToUTF8String(rezAsset.Data);
m_parentGroup.Scene.EventManager.TriggerRezScript(LocalID, item.item_id, script); m_parentGroup.Scene.EventManager.TriggerRezScript(LocalID, item.ItemID, script);
} }
else else
{ {
MainLog.Instance.Error( MainLog.Instance.Error(
"PRIMINVENTORY", "PRIMINVENTORY",
"Couldn't start script {0}, {1} since asset ID {2} could not be found", "Couldn't start script {0}, {1} since asset ID {2} could not be found",
item.name, item.item_id, item.asset_id); item.Name, item.ItemID, item.AssetID);
} }
} }
@ -172,10 +188,10 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="item"></param> /// <param name="item"></param>
public void AddInventoryItem(TaskInventoryItem item) public void AddInventoryItem(TaskInventoryItem item)
{ {
item.parent_id = m_folderID; item.ParentID = m_folderID;
item.creation_date = 1000; item.CreationDate = 1000;
item.ParentPartID = UUID; item.ParentPartID = UUID;
m_taskInventory.Add(item.item_id, item); m_taskInventory.Add(item.ItemID, item);
m_inventorySerial++; m_inventorySerial++;
} }
@ -188,7 +204,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
foreach (TaskInventoryItem item in items) foreach (TaskInventoryItem item in items)
{ {
m_taskInventory.Add(item.item_id, item); m_taskInventory.Add(item.ItemID, item);
} }
m_inventorySerial++; m_inventorySerial++;
@ -224,9 +240,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns>false if the item did not exist, true if the update occurred succesfully</returns> /// <returns>false if the item did not exist, true if the update occurred succesfully</returns>
public bool UpdateInventoryItem(TaskInventoryItem item) 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++; m_inventorySerial++;
return true; return true;
@ -236,7 +252,7 @@ namespace OpenSim.Region.Environment.Scenes
MainLog.Instance.Error( MainLog.Instance.Error(
"PRIMINVENTORY", "PRIMINVENTORY",
"Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", "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; return false;
@ -252,7 +268,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (m_taskInventory.ContainsKey(itemID)) if (m_taskInventory.ContainsKey(itemID))
{ {
int type = m_taskInventory[itemID].inv_type; int type = m_taskInventory[itemID].InvType;
m_taskInventory.Remove(itemID); m_taskInventory.Remove(itemID);
m_inventorySerial++; m_inventorySerial++;
@ -296,8 +312,8 @@ namespace OpenSim.Region.Environment.Scenes
foreach (TaskInventoryItem item in m_taskInventory.Values) foreach (TaskInventoryItem item in m_taskInventory.Values)
{ {
invString.AddItemStart(); invString.AddItemStart();
invString.AddNameValueLine("item_id", item.item_id.ToString()); invString.AddNameValueLine("item_id", item.ItemID.ToString());
invString.AddNameValueLine("parent_id", item.parent_id.ToString()); invString.AddNameValueLine("parent_id", item.ParentID.ToString());
invString.AddPermissionsStart(); invString.AddPermissionsStart();
invString.AddNameValueLine("base_mask", "0x7FFFFFFF"); invString.AddNameValueLine("base_mask", "0x7FFFFFFF");
@ -305,19 +321,19 @@ namespace OpenSim.Region.Environment.Scenes
invString.AddNameValueLine("group_mask", "0x7FFFFFFF"); invString.AddNameValueLine("group_mask", "0x7FFFFFFF");
invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF"); invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF");
invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF"); invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF");
invString.AddNameValueLine("creator_id", item.creator_id.ToString()); invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
invString.AddNameValueLine("owner_id", item.owner_id.ToString()); invString.AddNameValueLine("owner_id", item.OwnerID.ToString());
invString.AddNameValueLine("last_owner_id", item.last_owner_id.ToString()); invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
invString.AddNameValueLine("group_id", item.group_id.ToString()); invString.AddNameValueLine("group_id", item.GroupID.ToString());
invString.AddSectionEnd(); invString.AddSectionEnd();
invString.AddNameValueLine("asset_id", item.asset_id.ToString()); invString.AddNameValueLine("asset_id", item.AssetID.ToString());
invString.AddNameValueLine("type", TaskInventoryItem.Types[item.type]); invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.inv_type]); invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
invString.AddNameValueLine("flags", "0x00"); invString.AddNameValueLine("flags", "0x00");
invString.AddNameValueLine("name", item.name + "|"); invString.AddNameValueLine("name", item.Name + "|");
invString.AddNameValueLine("desc", item.desc + "|"); invString.AddNameValueLine("desc", item.Description + "|");
invString.AddNameValueLine("creation_date", item.creation_date.ToString()); invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
invString.AddSectionEnd(); invString.AddSectionEnd();
} }

View File

@ -992,6 +992,19 @@ namespace OpenSim.Region.Environment.Scenes
#endregion #endregion
/// <summary>
/// Reset LLUUIDs for this part. This involves generate this part's own LLUUID and
/// generating new LLUUIDs for all the items in the inventory.
/// </summary>
/// <param name="linkNum'>Link number for the part</param>
public void ResetIDs(int linkNum)
{
UUID = LLUUID.Random();
LinkNum = linkNum;
ResetInventoryIDs();
}
#region Update Scheduling #region Update Scheduling
/// <summary> /// <summary>

View File

@ -68,7 +68,7 @@ namespace OpenSim.Region.Environment.Scenes
m_regInfo.RegionHandle, aPrimNode.OuterXml); m_regInfo.RegionHandle, aPrimNode.OuterXml);
if (newIDS) if (newIDS)
{ {
obj.GenerateNewIDs(); obj.ResetIDs();
} }
//if we want this to be a import method then we need new uuids for the object to avoid any clashes //if we want this to be a import method then we need new uuids for the object to avoid any clashes
//obj.RegenerateFullIDs(); //obj.RegenerateFullIDs();

View File

@ -140,6 +140,8 @@ namespace OpenSim.DataStore.MSSQL
public void RemoveObject(LLUUID obj, LLUUID regionUUID) 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 prims = ds.Tables["prims"];
DataTable shapes = ds.Tables["primshapes"]; DataTable shapes = ds.Tables["primshapes"];