From b33da2538ed728bdc97cca20ada36913097160b0 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Wed, 16 Jan 2008 20:27:12 +0000
Subject: * Fix mantis 345 - it is now possible to duplicate prims directly in
the region again without breakage * This includes their inventories * Also,
this revision properly synchronizes prim inventory crud.
---
OpenSim/Region/Environment/Scenes/InnerScene.cs | 7 +-
.../Region/Environment/Scenes/SceneObjectGroup.cs | 6 +-
.../Scenes/SceneObjectPart.Inventory.cs | 209 ++++++++++++---------
.../Region/Environment/Scenes/SceneObjectPart.cs | 8 +-
4 files changed, 133 insertions(+), 97 deletions(-)
(limited to 'OpenSim/Region/Environment')
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 0116428..9aa3f20 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -928,17 +928,22 @@ namespace OpenSim.Region.Environment.Scenes
{
SceneObjectGroup copy = originPrim.Copy(AgentID, GroupID);
copy.AbsolutePosition = copy.AbsolutePosition + offset;
+ copy.ResetIDs();
+
lock (Entities)
{
Entities.Add(copy.UUID, copy);
}
+
m_numPrim++;
+
+ copy.StartScripts();
copy.ScheduleGroupForFullUpdate();
}
}
else
{
- MainLog.Instance.Warn("client", "Attempted to duplicate nonexistant prim");
+ MainLog.Instance.Warn("SCENE", "Attempted to duplicate nonexistant prim id {0}", GroupID);
}
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 0b7f2a4..3327fea 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -572,9 +572,8 @@ namespace OpenSim.Region.Environment.Scenes
///
public void CopyRootPart(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID)
{
- SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate(), OwnerID, GroupID);
+ SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate(), OwnerID, GroupID, m_parts.Count);
newPart.SetParent(this);
- newPart.LinkNum = m_parts.Count;
m_parts.Add(newPart.UUID, newPart);
SetPartAsRoot(newPart);
}
@@ -602,9 +601,8 @@ namespace OpenSim.Region.Environment.Scenes
///
public void CopyPart(SceneObjectPart part, LLUUID cAgentID, LLUUID cGroupID)
{
- SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate(), OwnerID, GroupID);
+ SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate(), OwnerID, GroupID, m_parts.Count);
newPart.SetParent(this);
- newPart.LinkNum = m_parts.Count;
m_parts.Add(newPart.UUID, newPart);
SetPartAsNonRoot(newPart);
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index 5132a6c..be2ddae 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -88,13 +88,16 @@ namespace OpenSim.Region.Environment.Scenes
///
@@ -191,7 +199,12 @@ namespace OpenSim.Region.Environment.Scenes
item.ParentID = m_folderID;
item.CreationDate = 1000;
item.ParentPartID = UUID;
- m_taskInventory.Add(item.ItemID, item);
+
+ lock (m_taskInventory)
+ {
+ m_taskInventory.Add(item.ItemID, item);
+ }
+
m_inventorySerial++;
}
@@ -202,9 +215,12 @@ namespace OpenSim.Region.Environment.Scenes
///
public void AddInventoryItems(ICollection items)
{
- foreach (TaskInventoryItem item in items)
- {
- m_taskInventory.Add(item.ItemID, item);
+ lock (m_taskInventory)
+ {
+ foreach (TaskInventoryItem item in items)
+ {
+ m_taskInventory.Add(item.ItemID, item);
+ }
}
m_inventorySerial++;
@@ -217,16 +233,19 @@ namespace OpenSim.Region.Environment.Scenes
/// null if the item does not exist
public TaskInventoryItem GetInventoryItem(LLUUID itemID)
{
- if (m_taskInventory.ContainsKey(itemID))
- {
- return m_taskInventory[itemID];
- }
- else
- {
- MainLog.Instance.Error(
- "PRIMINVENTORY",
- "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
- itemID, Name, UUID);
+ lock (m_taskInventory)
+ {
+ if (m_taskInventory.ContainsKey(itemID))
+ {
+ return m_taskInventory[itemID];
+ }
+ else
+ {
+ MainLog.Instance.Error(
+ "PRIMINVENTORY",
+ "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
+ itemID, Name, UUID);
+ }
}
return null;
@@ -240,20 +259,23 @@ 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.ItemID))
- {
- m_taskInventory[item.ItemID] = item;
- m_inventorySerial++;
-
- return true;
+ lock (m_taskInventory)
+ {
+ if (m_taskInventory.ContainsKey(item.ItemID))
+ {
+ m_taskInventory[item.ItemID] = item;
+ m_inventorySerial++;
+
+ return true;
+ }
+ else
+ {
+ MainLog.Instance.Error(
+ "PRIMINVENTORY",
+ "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
+ item.ItemID, Name, UUID);
+ }
}
- else
- {
- MainLog.Instance.Error(
- "PRIMINVENTORY",
- "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
- item.ItemID, Name, UUID);
- }
return false;
}
@@ -266,21 +288,24 @@ namespace OpenSim.Region.Environment.Scenes
/// in this prim's inventory.
public int RemoveInventoryItem(LLUUID itemID)
{
- if (m_taskInventory.ContainsKey(itemID))
- {
- int type = m_taskInventory[itemID].InvType;
- m_taskInventory.Remove(itemID);
- m_inventorySerial++;
-
- return type;
+ lock (m_taskInventory)
+ {
+ if (m_taskInventory.ContainsKey(itemID))
+ {
+ int type = m_taskInventory[itemID].InvType;
+ m_taskInventory.Remove(itemID);
+ m_inventorySerial++;
+
+ return type;
+ }
+ else
+ {
+ MainLog.Instance.Error(
+ "PRIMINVENTORY",
+ "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
+ itemID, Name, UUID);
+ }
}
- else
- {
- MainLog.Instance.Error(
- "PRIMINVENTORY",
- "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
- itemID, Name, UUID);
- }
return -1;
}
@@ -309,32 +334,36 @@ namespace OpenSim.Region.Environment.Scenes
{
byte[] fileData = new byte[0];
InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, UUID);
- foreach (TaskInventoryItem item in m_taskInventory.Values)
- {
- invString.AddItemStart();
- invString.AddNameValueLine("item_id", item.ItemID.ToString());
- invString.AddNameValueLine("parent_id", item.ParentID.ToString());
-
- invString.AddPermissionsStart();
- invString.AddNameValueLine("base_mask", "0x7FFFFFFF");
- invString.AddNameValueLine("owner_mask", "0x7FFFFFFF");
- invString.AddNameValueLine("group_mask", "0x7FFFFFFF");
- invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF");
- invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF");
- 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.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.Description + "|");
- invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
- invString.AddSectionEnd();
+
+ lock (m_taskInventory)
+ {
+ foreach (TaskInventoryItem item in m_taskInventory.Values)
+ {
+ invString.AddItemStart();
+ invString.AddNameValueLine("item_id", item.ItemID.ToString());
+ invString.AddNameValueLine("parent_id", item.ParentID.ToString());
+
+ invString.AddPermissionsStart();
+ invString.AddNameValueLine("base_mask", "0x7FFFFFFF");
+ invString.AddNameValueLine("owner_mask", "0x7FFFFFFF");
+ invString.AddNameValueLine("group_mask", "0x7FFFFFFF");
+ invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF");
+ invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF");
+ 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.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.Description + "|");
+ invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
+ invString.AddSectionEnd();
+ }
}
fileData = Helpers.StringToField(invString.BuildString);
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 93073c1..7866739 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -952,10 +952,10 @@ namespace OpenSim.Region.Environment.Scenes
#region Copying
///
- ///
+ /// Duplicates this part.
///
///
- public SceneObjectPart Copy(uint localID, LLUUID AgentID, LLUUID GroupID)
+ public SceneObjectPart Copy(uint localID, LLUUID AgentID, LLUUID GroupID, int linkNum)
{
SceneObjectPart dupe = (SceneObjectPart) MemberwiseClone();
dupe.m_shape = m_shape.Copy();
@@ -977,6 +977,10 @@ namespace OpenSim.Region.Environment.Scenes
dupe.ObjectSaleType = ObjectSaleType;
dupe.SalePrice = SalePrice;
dupe.Category = Category;
+
+ dupe.TaskInventory = (TaskInventoryDictionary)dupe.TaskInventory.Clone();
+
+ dupe.ResetIDs(linkNum);
// This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
dupe.LastOwnerID = ObjectOwner;
--
cgit v1.1