aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-01-16 20:27:12 +0000
committerJustin Clarke Casey2008-01-16 20:27:12 +0000
commitb33da2538ed728bdc97cca20ada36913097160b0 (patch)
tree0464763a340891a49134d7bd66468302bc38dcad /OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
parent* Fixed a packet counting issue that I introduced (diff)
downloadopensim-SC_OLD-b33da2538ed728bdc97cca20ada36913097160b0.zip
opensim-SC_OLD-b33da2538ed728bdc97cca20ada36913097160b0.tar.gz
opensim-SC_OLD-b33da2538ed728bdc97cca20ada36913097160b0.tar.bz2
opensim-SC_OLD-b33da2538ed728bdc97cca20ada36913097160b0.tar.xz
* 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.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs209
1 files changed, 119 insertions, 90 deletions
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
88 /// <param name="linkNum'>Link number for the part</param> 88 /// <param name="linkNum'>Link number for the part</param>
89 public void ResetInventoryIDs() 89 public void ResetInventoryIDs()
90 { 90 {
91 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values); 91 lock (TaskInventory)
92 TaskInventory.Clear(); 92 {
93 93 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(TaskInventory.Values);
94 foreach (TaskInventoryItem item in items) 94 TaskInventory.Clear();
95 { 95
96 item.ResetIDs(UUID); 96 foreach (TaskInventoryItem item in items)
97 TaskInventory.Add(item.ItemID, item); 97 {
98 item.ResetIDs(UUID);
99 TaskInventory.Add(item.ItemID, item);
100 }
98 } 101 }
99 } 102 }
100 103
@@ -103,12 +106,15 @@ namespace OpenSim.Region.Environment.Scenes
103 /// </summary> 106 /// </summary>
104 public void StartScripts() 107 public void StartScripts()
105 { 108 {
106 foreach (TaskInventoryItem item in m_taskInventory.Values) 109 lock (m_taskInventory)
107 { 110 {
108 // XXX more hardcoding badness. Should be an enum in TaskInventoryItem 111 foreach (TaskInventoryItem item in m_taskInventory.Values)
109 if (10 == item.Type)
110 { 112 {
111 StartScript(item); 113 // XXX more hardcoding badness. Should be an enum in TaskInventoryItem
114 if (10 == item.Type)
115 {
116 StartScript(item);
117 }
112 } 118 }
113 } 119 }
114 } 120 }
@@ -149,18 +155,20 @@ namespace OpenSim.Region.Environment.Scenes
149 /// </param> 155 /// </param>
150 public void StartScript(LLUUID itemId) 156 public void StartScript(LLUUID itemId)
151 { 157 {
152 if (m_taskInventory.ContainsKey(itemId)) 158 lock (m_taskInventory)
153 { 159 {
154 StartScript(m_taskInventory[itemId]); 160 if (m_taskInventory.ContainsKey(itemId))
155 } 161 {
156 else 162 StartScript(m_taskInventory[itemId]);
157 { 163 }
158 MainLog.Instance.Error( 164 else
159 "PRIMINVENTORY", 165 {
160 "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", 166 MainLog.Instance.Error(
161 itemId, Name, UUID); 167 "PRIMINVENTORY",
162 } 168 "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}",
163 169 itemId, Name, UUID);
170 }
171 }
164 } 172 }
165 173
166 /// <summary> 174 /// <summary>
@@ -191,7 +199,12 @@ namespace OpenSim.Region.Environment.Scenes
191 item.ParentID = m_folderID; 199 item.ParentID = m_folderID;
192 item.CreationDate = 1000; 200 item.CreationDate = 1000;
193 item.ParentPartID = UUID; 201 item.ParentPartID = UUID;
194 m_taskInventory.Add(item.ItemID, item); 202
203 lock (m_taskInventory)
204 {
205 m_taskInventory.Add(item.ItemID, item);
206 }
207
195 m_inventorySerial++; 208 m_inventorySerial++;
196 } 209 }
197 210
@@ -202,9 +215,12 @@ namespace OpenSim.Region.Environment.Scenes
202 /// <param name="items"></param> 215 /// <param name="items"></param>
203 public void AddInventoryItems(ICollection<TaskInventoryItem> items) 216 public void AddInventoryItems(ICollection<TaskInventoryItem> items)
204 { 217 {
205 foreach (TaskInventoryItem item in items) 218 lock (m_taskInventory)
206 { 219 {
207 m_taskInventory.Add(item.ItemID, item); 220 foreach (TaskInventoryItem item in items)
221 {
222 m_taskInventory.Add(item.ItemID, item);
223 }
208 } 224 }
209 225
210 m_inventorySerial++; 226 m_inventorySerial++;
@@ -217,16 +233,19 @@ namespace OpenSim.Region.Environment.Scenes
217 /// <returns>null if the item does not exist</returns> 233 /// <returns>null if the item does not exist</returns>
218 public TaskInventoryItem GetInventoryItem(LLUUID itemID) 234 public TaskInventoryItem GetInventoryItem(LLUUID itemID)
219 { 235 {
220 if (m_taskInventory.ContainsKey(itemID)) 236 lock (m_taskInventory)
221 { 237 {
222 return m_taskInventory[itemID]; 238 if (m_taskInventory.ContainsKey(itemID))
223 } 239 {
224 else 240 return m_taskInventory[itemID];
225 { 241 }
226 MainLog.Instance.Error( 242 else
227 "PRIMINVENTORY", 243 {
228 "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", 244 MainLog.Instance.Error(
229 itemID, Name, UUID); 245 "PRIMINVENTORY",
246 "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
247 itemID, Name, UUID);
248 }
230 } 249 }
231 250
232 return null; 251 return null;
@@ -240,20 +259,23 @@ namespace OpenSim.Region.Environment.Scenes
240 /// <returns>false if the item did not exist, true if the update occurred succesfully</returns> 259 /// <returns>false if the item did not exist, true if the update occurred succesfully</returns>
241 public bool UpdateInventoryItem(TaskInventoryItem item) 260 public bool UpdateInventoryItem(TaskInventoryItem item)
242 { 261 {
243 if (m_taskInventory.ContainsKey(item.ItemID)) 262 lock (m_taskInventory)
244 { 263 {
245 m_taskInventory[item.ItemID] = item; 264 if (m_taskInventory.ContainsKey(item.ItemID))
246 m_inventorySerial++; 265 {
247 266 m_taskInventory[item.ItemID] = item;
248 return true; 267 m_inventorySerial++;
268
269 return true;
270 }
271 else
272 {
273 MainLog.Instance.Error(
274 "PRIMINVENTORY",
275 "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
276 item.ItemID, Name, UUID);
277 }
249 } 278 }
250 else
251 {
252 MainLog.Instance.Error(
253 "PRIMINVENTORY",
254 "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
255 item.ItemID, Name, UUID);
256 }
257 279
258 return false; 280 return false;
259 } 281 }
@@ -266,21 +288,24 @@ namespace OpenSim.Region.Environment.Scenes
266 /// in this prim's inventory.</returns> 288 /// in this prim's inventory.</returns>
267 public int RemoveInventoryItem(LLUUID itemID) 289 public int RemoveInventoryItem(LLUUID itemID)
268 { 290 {
269 if (m_taskInventory.ContainsKey(itemID)) 291 lock (m_taskInventory)
270 { 292 {
271 int type = m_taskInventory[itemID].InvType; 293 if (m_taskInventory.ContainsKey(itemID))
272 m_taskInventory.Remove(itemID); 294 {
273 m_inventorySerial++; 295 int type = m_taskInventory[itemID].InvType;
274 296 m_taskInventory.Remove(itemID);
275 return type; 297 m_inventorySerial++;
298
299 return type;
300 }
301 else
302 {
303 MainLog.Instance.Error(
304 "PRIMINVENTORY",
305 "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
306 itemID, Name, UUID);
307 }
276 } 308 }
277 else
278 {
279 MainLog.Instance.Error(
280 "PRIMINVENTORY",
281 "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
282 itemID, Name, UUID);
283 }
284 309
285 return -1; 310 return -1;
286 } 311 }
@@ -309,32 +334,36 @@ namespace OpenSim.Region.Environment.Scenes
309 { 334 {
310 byte[] fileData = new byte[0]; 335 byte[] fileData = new byte[0];
311 InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, UUID); 336 InventoryStringBuilder invString = new InventoryStringBuilder(m_folderID, UUID);
312 foreach (TaskInventoryItem item in m_taskInventory.Values) 337
313 { 338 lock (m_taskInventory)
314 invString.AddItemStart(); 339 {
315 invString.AddNameValueLine("item_id", item.ItemID.ToString()); 340 foreach (TaskInventoryItem item in m_taskInventory.Values)
316 invString.AddNameValueLine("parent_id", item.ParentID.ToString()); 341 {
317 342 invString.AddItemStart();
318 invString.AddPermissionsStart(); 343 invString.AddNameValueLine("item_id", item.ItemID.ToString());
319 invString.AddNameValueLine("base_mask", "0x7FFFFFFF"); 344 invString.AddNameValueLine("parent_id", item.ParentID.ToString());
320 invString.AddNameValueLine("owner_mask", "0x7FFFFFFF"); 345
321 invString.AddNameValueLine("group_mask", "0x7FFFFFFF"); 346 invString.AddPermissionsStart();
322 invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF"); 347 invString.AddNameValueLine("base_mask", "0x7FFFFFFF");
323 invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF"); 348 invString.AddNameValueLine("owner_mask", "0x7FFFFFFF");
324 invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); 349 invString.AddNameValueLine("group_mask", "0x7FFFFFFF");
325 invString.AddNameValueLine("owner_id", item.OwnerID.ToString()); 350 invString.AddNameValueLine("everyone_mask", "0x7FFFFFFF");
326 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); 351 invString.AddNameValueLine("next_owner_mask", "0x7FFFFFFF");
327 invString.AddNameValueLine("group_id", item.GroupID.ToString()); 352 invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
328 invString.AddSectionEnd(); 353 invString.AddNameValueLine("owner_id", item.OwnerID.ToString());
329 354 invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
330 invString.AddNameValueLine("asset_id", item.AssetID.ToString()); 355 invString.AddNameValueLine("group_id", item.GroupID.ToString());
331 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); 356 invString.AddSectionEnd();
332 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); 357
333 invString.AddNameValueLine("flags", "0x00"); 358 invString.AddNameValueLine("asset_id", item.AssetID.ToString());
334 invString.AddNameValueLine("name", item.Name + "|"); 359 invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
335 invString.AddNameValueLine("desc", item.Description + "|"); 360 invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
336 invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); 361 invString.AddNameValueLine("flags", "0x00");
337 invString.AddSectionEnd(); 362 invString.AddNameValueLine("name", item.Name + "|");
363 invString.AddNameValueLine("desc", item.Description + "|");
364 invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
365 invString.AddSectionEnd();
366 }
338 } 367 }
339 368
340 fileData = Helpers.StringToField(invString.BuildString); 369 fileData = Helpers.StringToField(invString.BuildString);