aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-01-16 18:35:34 +0000
committerJustin Clarke Casey2008-01-16 18:35:34 +0000
commit57519b6dba97d7e7a2de71af9d58c93b4750bde8 (patch)
tree9597647ee1e70e50215b90bb116fede1ca7f8e27 /OpenSim/Region
parentFirst part of changing prim's permission flags to use the correct enum (libsl... (diff)
downloadopensim-SC-57519b6dba97d7e7a2de71af9d58c93b4750bde8.zip
opensim-SC-57519b6dba97d7e7a2de71af9d58c93b4750bde8.tar.gz
opensim-SC-57519b6dba97d7e7a2de71af9d58c93b4750bde8.tar.bz2
opensim-SC-57519b6dba97d7e7a2de71af9d58c93b4750bde8.tar.xz
* 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
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs17
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs18
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs12
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs90
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs13
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs4
-rw-r--r--OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs4
7 files changed, 98 insertions, 60 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 2fd4301..10f4141 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -184,21 +184,21 @@ namespace OpenSim.Region.Environment.Scenes
184 } 184 }
185 185
186 // Create new asset 186 // Create new asset
187 // XXX Hardcoding the numbers is a temporary measure - need an enumeration for this 187 // XXX Hardcoding the numbers is a temporary measure - need an enumeration for this
188 AssetBase asset = 188 // There may well be one in libsecondlife
189 CreateAsset(item.name, item.desc, 10, 10, data); 189 AssetBase asset = CreateAsset(item.Name, item.Description, 10, 10, data);
190 AssetCache.AddAsset(asset); 190 AssetCache.AddAsset(asset);
191 191
192 // Update item with new asset 192 // Update item with new asset
193 item.asset_id = asset.FullID; 193 item.AssetID = asset.FullID;
194 group.UpdateInventoryItem(item); 194 group.UpdateInventoryItem(item);
195 group.GetProperites(remoteClient); 195 group.GetProperites(remoteClient);
196 196
197 // Trigger rerunning of script (use TriggerRezScript event, see RezScript) 197 // Trigger rerunning of script (use TriggerRezScript event, see RezScript)
198 if (isScriptRunning) 198 if (isScriptRunning)
199 { 199 {
200 group.StopScript(part.LocalID, item.item_id); 200 group.StopScript(part.LocalID, item.ItemID);
201 group.StartScript(part.LocalID, item.item_id); 201 group.StartScript(part.LocalID, item.ItemID);
202 } 202 }
203 } 203 }
204 204
@@ -750,12 +750,14 @@ namespace OpenSim.Region.Environment.Scenes
750 private void AddRezObject(string xmlData, LLVector3 pos) 750 private void AddRezObject(string xmlData, LLVector3 pos)
751 { 751 {
752 SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); 752 SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData);
753 group.GenerateNewIDs(); 753 group.ResetIDs();
754 AddEntity(group); 754 AddEntity(group);
755 group.AbsolutePosition = pos; 755 group.AbsolutePosition = pos;
756 SceneObjectPart rootPart = group.GetChildPart(group.UUID); 756 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
757 rootPart.ApplySanePermissions(); 757 rootPart.ApplySanePermissions();
758 group.ApplyPhysics(m_physicalPrim); 758 group.ApplyPhysics(m_physicalPrim);
759 group.StartScripts();
760
759 //bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0)&& m_physicalPrim); 761 //bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0)&& m_physicalPrim);
760 //if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) 762 //if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0)
761 //{ 763 //{
@@ -772,6 +774,7 @@ namespace OpenSim.Region.Environment.Scenes
772 // rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); 774 // rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
773 775
774 // } 776 // }
777 //
775 rootPart.ScheduleFullUpdate(); 778 rootPart.ScheduleFullUpdate();
776 } 779 }
777 } 780 }
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
index a092f5b..c7f5852 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
@@ -169,14 +169,14 @@ namespace OpenSim.Region.Environment.Scenes
169 { 169 {
170 TaskInventoryItem taskItem = new TaskInventoryItem(); 170 TaskInventoryItem taskItem = new TaskInventoryItem();
171 171
172 taskItem.item_id = newItemId; 172 taskItem.ItemID = newItemId;
173 taskItem.asset_id = item.assetID; 173 taskItem.AssetID = item.assetID;
174 taskItem.name = item.inventoryName; 174 taskItem.Name = item.inventoryName;
175 taskItem.desc = item.inventoryDescription; 175 taskItem.Description = item.inventoryDescription;
176 taskItem.owner_id = item.avatarID; 176 taskItem.OwnerID = item.avatarID;
177 taskItem.creator_id = item.creatorsID; 177 taskItem.CreatorID = item.creatorsID;
178 taskItem.type = item.assetType; 178 taskItem.Type = item.assetType;
179 taskItem.inv_type = item.invType; 179 taskItem.InvType = item.invType;
180 part.AddInventoryItem(taskItem); 180 part.AddInventoryItem(taskItem);
181 181
182 // It might seem somewhat crude to update the whole group for a single prim inventory change, 182 // 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
250 MainLog.Instance.Error( 250 MainLog.Instance.Error(
251 "PRIMINVENTORY", 251 "PRIMINVENTORY",
252 "Couldn't find prim ID {0} to update item {1}, {2}", 252 "Couldn't find prim ID {0} to update item {1}, {2}",
253 item.ParentPartID, item.name, item.item_id); 253 item.ParentPartID, item.Name, item.ItemID);
254 } 254 }
255 255
256 return false; 256 return false;
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 2e0b916..0b7f2a4 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -609,15 +609,19 @@ namespace OpenSim.Region.Environment.Scenes
609 SetPartAsNonRoot(newPart); 609 SetPartAsNonRoot(newPart);
610 } 610 }
611 611
612 612 /// <summary>
613 public void GenerateNewIDs() 613 /// Reset the LLUUIDs for all the prims that make up this group.
614 ///
615 /// This is called by methods which want to add a new group to an existing scene, in order
616 /// to ensure that there are no clashes with groups already present.
617 /// </summary>
618 public void ResetIDs()
614 { 619 {
615 List<SceneObjectPart> partsList = new List<SceneObjectPart>(m_parts.Values); 620 List<SceneObjectPart> partsList = new List<SceneObjectPart>(m_parts.Values);
616 m_parts.Clear(); 621 m_parts.Clear();
617 foreach (SceneObjectPart part in partsList) 622 foreach (SceneObjectPart part in partsList)
618 { 623 {
619 part.UUID = LLUUID.Random(); 624 part.ResetIDs(m_parts.Count);
620 part.LinkNum = m_parts.Count;
621 m_parts.Add(part.UUID, part); 625 m_parts.Add(part.UUID, part);
622 } 626 }
623 } 627 }
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index fc74c4e..5132a6c 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -57,30 +57,46 @@ namespace OpenSim.Region.Environment.Scenes
57 get { return m_folderID; } 57 get { return m_folderID; }
58 set { m_folderID = value; } 58 set { m_folderID = value; }
59 } 59 }
60
61 /// <summary>
62 /// Serial count for inventory file , used to tell if inventory has changed
63 /// no need for this to be part of Database backup
64 /// </summary>
65 protected uint m_inventorySerial = 0;
66
67 public uint InventorySerial
68 {
69 get { return m_inventorySerial; }
70 set { m_inventorySerial = value; }
71 }
60 72
61 /// <summary> 73 /// <summary>
62 /// Holds in memory prim inventory 74 /// Holds in memory prim inventory
63 /// </summary> 75 /// </summary>
64 protected IDictionary<LLUUID, TaskInventoryItem> m_taskInventory 76 protected TaskInventoryDictionary m_taskInventory = new TaskInventoryDictionary();
65 = new Dictionary<LLUUID, TaskInventoryItem>();
66 77
67 [XmlIgnore] 78 public TaskInventoryDictionary TaskInventory
68 public IDictionary<LLUUID, TaskInventoryItem> TaskInventory
69 { 79 {
70 get { return m_taskInventory; } 80 get { return m_taskInventory; }
81 set { m_taskInventory = value; }
71 } 82 }
72 83
73 /// <summary> 84 /// <summary>
74 /// Serial count for inventory file , used to tell if inventory has changed 85 /// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating
75 /// no need for this to be part of Database backup 86 /// new ones or setting existing UUIDs to the correct parent UUIDs
76 /// </summary> 87 /// </summary>
77 protected uint m_inventorySerial = 0; 88 /// <param name="linkNum'>Link number for the part</param>
78 89 public void ResetInventoryIDs()
79 public uint InventorySerial
80 { 90 {
81 get { return m_inventorySerial; } 91 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values);
82 } 92 TaskInventory.Clear();
83 93
94 foreach (TaskInventoryItem item in items)
95 {
96 item.ResetIDs(UUID);
97 TaskInventory.Add(item.ItemID, item);
98 }
99 }
84 100
85 /// <summary> 101 /// <summary>
86 /// Start all the scripts contained in this prim's inventory 102 /// Start all the scripts contained in this prim's inventory
@@ -90,7 +106,7 @@ namespace OpenSim.Region.Environment.Scenes
90 foreach (TaskInventoryItem item in m_taskInventory.Values) 106 foreach (TaskInventoryItem item in m_taskInventory.Values)
91 { 107 {
92 // XXX more hardcoding badness. Should be an enum in TaskInventoryItem 108 // XXX more hardcoding badness. Should be an enum in TaskInventoryItem
93 if (10 == item.type) 109 if (10 == item.Type)
94 { 110 {
95 StartScript(item); 111 StartScript(item);
96 } 112 }
@@ -107,21 +123,21 @@ namespace OpenSim.Region.Environment.Scenes
107// MainLog.Instance.Verbose( 123// MainLog.Instance.Verbose(
108// "PRIMINVENTORY", 124// "PRIMINVENTORY",
109// "Starting script {0}, {1} in prim {2}, {3}", 125// "Starting script {0}, {1} in prim {2}, {3}",
110// item.name, item.item_id, Name, UUID); 126// item.Name, item.ItemID, Name, UUID);
111 127
112 AssetBase rezAsset = m_parentGroup.Scene.AssetCache.GetAsset(item.asset_id, false); 128 AssetBase rezAsset = m_parentGroup.Scene.AssetCache.GetAsset(item.AssetID, false);
113 129
114 if (rezAsset != null) 130 if (rezAsset != null)
115 { 131 {
116 string script = Helpers.FieldToUTF8String(rezAsset.Data); 132 string script = Helpers.FieldToUTF8String(rezAsset.Data);
117 m_parentGroup.Scene.EventManager.TriggerRezScript(LocalID, item.item_id, script); 133 m_parentGroup.Scene.EventManager.TriggerRezScript(LocalID, item.ItemID, script);
118 } 134 }
119 else 135 else
120 { 136 {
121 MainLog.Instance.Error( 137 MainLog.Instance.Error(
122 "PRIMINVENTORY", 138 "PRIMINVENTORY",
123 "Couldn't start script {0}, {1} since asset ID {2} could not be found", 139 "Couldn't start script {0}, {1} since asset ID {2} could not be found",
124 item.name, item.item_id, item.asset_id); 140 item.Name, item.ItemID, item.AssetID);
125 } 141 }
126 } 142 }
127 143
@@ -172,10 +188,10 @@ namespace OpenSim.Region.Environment.Scenes
172 /// <param name="item"></param> 188 /// <param name="item"></param>
173 public void AddInventoryItem(TaskInventoryItem item) 189 public void AddInventoryItem(TaskInventoryItem item)
174 { 190 {
175 item.parent_id = m_folderID; 191 item.ParentID = m_folderID;
176 item.creation_date = 1000; 192 item.CreationDate = 1000;
177 item.ParentPartID = UUID; 193 item.ParentPartID = UUID;
178 m_taskInventory.Add(item.item_id, item); 194 m_taskInventory.Add(item.ItemID, item);
179 m_inventorySerial++; 195 m_inventorySerial++;
180 } 196 }
181 197
@@ -188,7 +204,7 @@ namespace OpenSim.Region.Environment.Scenes
188 { 204 {
189 foreach (TaskInventoryItem item in items) 205 foreach (TaskInventoryItem item in items)
190 { 206 {
191 m_taskInventory.Add(item.item_id, item); 207 m_taskInventory.Add(item.ItemID, item);
192 } 208 }
193 209
194 m_inventorySerial++; 210 m_inventorySerial++;
@@ -224,9 +240,9 @@ namespace OpenSim.Region.Environment.Scenes
224 /// <returns>false if the item did not exist, true if the update occurred succesfully</returns> 240 /// <returns>false if the item did not exist, true if the update occurred succesfully</returns>
225 public bool UpdateInventoryItem(TaskInventoryItem item) 241 public bool UpdateInventoryItem(TaskInventoryItem item)
226 { 242 {
227 if (m_taskInventory.ContainsKey(item.item_id)) 243 if (m_taskInventory.ContainsKey(item.ItemID))
228 { 244 {
229 m_taskInventory[item.item_id] = item; 245 m_taskInventory[item.ItemID] = item;
230 m_inventorySerial++; 246 m_inventorySerial++;
231 247
232 return true; 248 return true;
@@ -236,7 +252,7 @@ namespace OpenSim.Region.Environment.Scenes
236 MainLog.Instance.Error( 252 MainLog.Instance.Error(
237 "PRIMINVENTORY", 253 "PRIMINVENTORY",
238 "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", 254 "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
239 item.item_id, Name, UUID); 255 item.ItemID, Name, UUID);
240 } 256 }
241 257
242 return false; 258 return false;
@@ -252,7 +268,7 @@ namespace OpenSim.Region.Environment.Scenes
252 { 268 {
253 if (m_taskInventory.ContainsKey(itemID)) 269 if (m_taskInventory.ContainsKey(itemID))
254 { 270 {
255 int type = m_taskInventory[itemID].inv_type; 271 int type = m_taskInventory[itemID].InvType;
256 m_taskInventory.Remove(itemID); 272 m_taskInventory.Remove(itemID);
257 m_inventorySerial++; 273 m_inventorySerial++;
258 274
@@ -296,8 +312,8 @@ namespace OpenSim.Region.Environment.Scenes
296 foreach (TaskInventoryItem item in m_taskInventory.Values) 312 foreach (TaskInventoryItem item in m_taskInventory.Values)
297 { 313 {
298 invString.AddItemStart(); 314 invString.AddItemStart();
299 invString.AddNameValueLine("item_id", item.item_id.ToString()); 315 invString.AddNameValueLine("item_id", item.ItemID.ToString());
300 invString.AddNameValueLine("parent_id", item.parent_id.ToString()); 316 invString.AddNameValueLine("parent_id", item.ParentID.ToString());
301 317
302 invString.AddPermissionsStart(); 318 invString.AddPermissionsStart();
303 invString.AddNameValueLine("base_mask", "0x7FFFFFFF"); 319 invString.AddNameValueLine("base_mask", "0x7FFFFFFF");
@@ -305,19 +321,19 @@ namespace OpenSim.Region.Environment.Scenes
305 invString.AddNameValueLine("group_mask", "0x7FFFFFFF"); 321 invString.AddNameValueLine("group_mask", "0x7FFFFFFF");
306 invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF"); 322 invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF");
307 invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF"); 323 invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF");
308 invString.AddNameValueLine("creator_id", item.creator_id.ToString()); 324 invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
309 invString.AddNameValueLine("owner_id", item.owner_id.ToString()); 325 invString.AddNameValueLine("owner_id", item.OwnerID.ToString());
310 invString.AddNameValueLine("last_owner_id", item.last_owner_id.ToString()); 326 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
311 invString.AddNameValueLine("group_id", item.group_id.ToString()); 327 invString.AddNameValueLine("group_id", item.GroupID.ToString());
312 invString.AddSectionEnd(); 328 invString.AddSectionEnd();
313 329
314 invString.AddNameValueLine("asset_id", item.asset_id.ToString()); 330 invString.AddNameValueLine("asset_id", item.AssetID.ToString());
315 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.type]); 331 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
316 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.inv_type]); 332 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
317 invString.AddNameValueLine("flags", "0x00"); 333 invString.AddNameValueLine("flags", "0x00");
318 invString.AddNameValueLine("name", item.name + "|"); 334 invString.AddNameValueLine("name", item.Name + "|");
319 invString.AddNameValueLine("desc", item.desc + "|"); 335 invString.AddNameValueLine("desc", item.Description + "|");
320 invString.AddNameValueLine("creation_date", item.creation_date.ToString()); 336 invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
321 invString.AddSectionEnd(); 337 invString.AddSectionEnd();
322 } 338 }
323 339
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index c1522bc..93073c1 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -991,6 +991,19 @@ namespace OpenSim.Region.Environment.Scenes
991 } 991 }
992 992
993 #endregion 993 #endregion
994
995 /// <summary>
996 /// Reset LLUUIDs for this part. This involves generate this part's own LLUUID and
997 /// generating new LLUUIDs for all the items in the inventory.
998 /// </summary>
999 /// <param name="linkNum'>Link number for the part</param>
1000 public void ResetIDs(int linkNum)
1001 {
1002 UUID = LLUUID.Random();
1003 LinkNum = linkNum;
1004
1005 ResetInventoryIDs();
1006 }
994 1007
995 #region Update Scheduling 1008 #region Update Scheduling
996 1009
diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
index 8c4a951..3b4deaf 100644
--- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Region.Environment.Scenes
68 m_regInfo.RegionHandle, aPrimNode.OuterXml); 68 m_regInfo.RegionHandle, aPrimNode.OuterXml);
69 if (newIDS) 69 if (newIDS)
70 { 70 {
71 obj.GenerateNewIDs(); 71 obj.ResetIDs();
72 } 72 }
73 //if we want this to be a import method then we need new uuids for the object to avoid any clashes 73 //if we want this to be a import method then we need new uuids for the object to avoid any clashes
74 //obj.RegenerateFullIDs(); 74 //obj.RegenerateFullIDs();
@@ -189,4 +189,4 @@ namespace OpenSim.Region.Environment.Scenes
189 file.Close(); 189 file.Close();
190 } 190 }
191 } 191 }
192} \ No newline at end of file 192}
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs
index d6c4675..7884277 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.MSSQL/MSSQLDataStore.cs
@@ -140,6 +140,8 @@ namespace OpenSim.DataStore.MSSQL
140 140
141 public void RemoveObject(LLUUID obj, LLUUID regionUUID) 141 public void RemoveObject(LLUUID obj, LLUUID regionUUID)
142 { 142 {
143 MainLog.Instance.Verbose("DATASTORE", "Removing obj: {0} from region: {1}", obj.UUID, regionUUID);
144
143 DataTable prims = ds.Tables["prims"]; 145 DataTable prims = ds.Tables["prims"];
144 DataTable shapes = ds.Tables["primshapes"]; 146 DataTable shapes = ds.Tables["primshapes"];
145 147
@@ -1087,4 +1089,4 @@ namespace OpenSim.DataStore.MSSQL
1087 } 1089 }
1088 } 1090 }
1089 } 1091 }
1090} \ No newline at end of file 1092}