* 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)
{
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<String, DataRow> dbItemsToRemove = new Dictionary<String, DataRow>();
ICollection<TaskInventoryItem> itemsToAdd
= new List<TaskInventoryItem>();
ICollection<TaskInventoryItem> itemsToAdd = new List<TaskInventoryItem>();
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);

View File

@ -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);

View File

@ -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<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
{
/// <summary>
@ -75,27 +142,37 @@ namespace OpenSim.Framework
"lsltext",
String.Empty
};
/// <summary>
/// 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 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;
}

View File

@ -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();
}
}

View File

@ -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;

View File

@ -609,15 +609,19 @@ namespace OpenSim.Region.Environment.Scenes
SetPartAsNonRoot(newPart);
}
public void GenerateNewIDs()
/// <summary>
/// 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);
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);
}
}

View File

@ -57,19 +57,7 @@ namespace OpenSim.Region.Environment.Scenes
get { return m_folderID; }
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>
/// 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; }
}
/// <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>
/// 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)
{
// XXX more hardcoding badness. Should be an enum in TaskInventoryItem
if (10 == item.type)
if (10 == item.Type)
{
StartScript(item);
}
@ -107,21 +123,21 @@ namespace OpenSim.Region.Environment.Scenes
// MainLog.Instance.Verbose(
// "PRIMINVENTORY",
// "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)
{
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
{
MainLog.Instance.Error(
"PRIMINVENTORY",
"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>
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
/// <returns>false if the item did not exist, true if the update occurred succesfully</returns>
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();
}

View File

@ -991,6 +991,19 @@ namespace OpenSim.Region.Environment.Scenes
}
#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

View File

@ -68,7 +68,7 @@ namespace OpenSim.Region.Environment.Scenes
m_regInfo.RegionHandle, aPrimNode.OuterXml);
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
//obj.RegenerateFullIDs();
@ -189,4 +189,4 @@ namespace OpenSim.Region.Environment.Scenes
file.Close();
}
}
}
}

View File

@ -140,6 +140,8 @@ namespace OpenSim.DataStore.MSSQL
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"];
@ -1087,4 +1089,4 @@ namespace OpenSim.DataStore.MSSQL
}
}
}
}
}