diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 380 |
1 files changed, 206 insertions, 174 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 22eedba..b57d912 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -80,7 +80,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
80 | /// </value> | 80 | /// </value> |
81 | protected internal TaskInventoryDictionary Items | 81 | protected internal TaskInventoryDictionary Items |
82 | { | 82 | { |
83 | get { return m_items; } | 83 | get { |
84 | return m_items; | ||
85 | } | ||
84 | set | 86 | set |
85 | { | 87 | { |
86 | m_items = value; | 88 | m_items = value; |
@@ -116,22 +118,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
116 | /// <param name="linkNum">Link number for the part</param> | 118 | /// <param name="linkNum">Link number for the part</param> |
117 | public void ResetInventoryIDs() | 119 | public void ResetInventoryIDs() |
118 | { | 120 | { |
119 | lock (Items) | 121 | m_items.LockItemsForWrite(true); |
122 | |||
123 | if (0 == Items.Count) | ||
120 | { | 124 | { |
121 | if (0 == Items.Count) | 125 | m_items.LockItemsForWrite(false); |
122 | return; | 126 | return; |
127 | } | ||
123 | 128 | ||
124 | HasInventoryChanged = true; | 129 | HasInventoryChanged = true; |
125 | m_part.ParentGroup.HasGroupChanged = true; | 130 | m_part.ParentGroup.HasGroupChanged = true; |
126 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 131 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
127 | Items.Clear(); | 132 | Items.Clear(); |
128 | 133 | ||
129 | foreach (TaskInventoryItem item in items) | 134 | foreach (TaskInventoryItem item in items) |
130 | { | 135 | { |
131 | item.ResetIDs(m_part.UUID); | 136 | item.ResetIDs(m_part.UUID); |
132 | Items.Add(item.ItemID, item); | 137 | Items.Add(item.ItemID, item); |
133 | } | ||
134 | } | 138 | } |
139 | m_items.LockItemsForWrite(false); | ||
135 | } | 140 | } |
136 | 141 | ||
137 | /// <summary> | 142 | /// <summary> |
@@ -140,25 +145,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
140 | /// <param name="ownerId"></param> | 145 | /// <param name="ownerId"></param> |
141 | public void ChangeInventoryOwner(UUID ownerId) | 146 | public void ChangeInventoryOwner(UUID ownerId) |
142 | { | 147 | { |
143 | lock (Items) | 148 | m_items.LockItemsForWrite(true); |
149 | if (0 == Items.Count) | ||
144 | { | 150 | { |
145 | if (0 == Items.Count) | 151 | m_items.LockItemsForWrite(false); |
146 | { | 152 | return; |
147 | return; | 153 | } |
148 | } | ||
149 | 154 | ||
150 | HasInventoryChanged = true; | 155 | HasInventoryChanged = true; |
151 | m_part.ParentGroup.HasGroupChanged = true; | 156 | m_part.ParentGroup.HasGroupChanged = true; |
152 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 157 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
153 | foreach (TaskInventoryItem item in items) | 158 | foreach (TaskInventoryItem item in items) |
159 | { | ||
160 | if (ownerId != item.OwnerID) | ||
154 | { | 161 | { |
155 | if (ownerId != item.OwnerID) | 162 | item.LastOwnerID = item.OwnerID; |
156 | { | 163 | item.OwnerID = ownerId; |
157 | item.LastOwnerID = item.OwnerID; | ||
158 | item.OwnerID = ownerId; | ||
159 | } | ||
160 | } | 164 | } |
161 | } | 165 | } |
166 | m_items.LockItemsForWrite(false); | ||
162 | } | 167 | } |
163 | 168 | ||
164 | /// <summary> | 169 | /// <summary> |
@@ -167,24 +172,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
167 | /// <param name="groupID"></param> | 172 | /// <param name="groupID"></param> |
168 | public void ChangeInventoryGroup(UUID groupID) | 173 | public void ChangeInventoryGroup(UUID groupID) |
169 | { | 174 | { |
170 | lock (Items) | 175 | m_items.LockItemsForWrite(true); |
176 | if (0 == Items.Count) | ||
171 | { | 177 | { |
172 | if (0 == Items.Count) | 178 | m_items.LockItemsForWrite(false); |
173 | { | 179 | return; |
174 | return; | 180 | } |
175 | } | ||
176 | 181 | ||
177 | HasInventoryChanged = true; | 182 | HasInventoryChanged = true; |
178 | m_part.ParentGroup.HasGroupChanged = true; | 183 | m_part.ParentGroup.HasGroupChanged = true; |
179 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 184 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
180 | foreach (TaskInventoryItem item in items) | 185 | foreach (TaskInventoryItem item in items) |
186 | { | ||
187 | if (groupID != item.GroupID) | ||
181 | { | 188 | { |
182 | if (groupID != item.GroupID) | 189 | item.GroupID = groupID; |
183 | { | ||
184 | item.GroupID = groupID; | ||
185 | } | ||
186 | } | 190 | } |
187 | } | 191 | } |
192 | m_items.LockItemsForWrite(false); | ||
188 | } | 193 | } |
189 | 194 | ||
190 | /// <summary> | 195 | /// <summary> |
@@ -192,14 +197,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
192 | /// </summary> | 197 | /// </summary> |
193 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) | 198 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
194 | { | 199 | { |
195 | lock (m_items) | 200 | Items.LockItemsForRead(true); |
201 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
202 | Items.LockItemsForRead(false); | ||
203 | foreach (TaskInventoryItem item in items) | ||
196 | { | 204 | { |
197 | foreach (TaskInventoryItem item in Items.Values) | 205 | if ((int)InventoryType.LSL == item.InvType) |
198 | { | 206 | { |
199 | if ((int)InventoryType.LSL == item.InvType) | 207 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); |
200 | { | ||
201 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | ||
202 | } | ||
203 | } | 208 | } |
204 | } | 209 | } |
205 | } | 210 | } |
@@ -209,17 +214,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
209 | /// </summary> | 214 | /// </summary> |
210 | public void RemoveScriptInstances() | 215 | public void RemoveScriptInstances() |
211 | { | 216 | { |
212 | lock (Items) | 217 | Items.LockItemsForRead(true); |
218 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
219 | Items.LockItemsForRead(false); | ||
220 | |||
221 | foreach (TaskInventoryItem item in items) | ||
213 | { | 222 | { |
214 | foreach (TaskInventoryItem item in Items.Values) | 223 | if ((int)InventoryType.LSL == item.InvType) |
215 | { | 224 | { |
216 | if ((int)InventoryType.LSL == item.InvType) | 225 | RemoveScriptInstance(item.ItemID); |
217 | { | 226 | m_part.RemoveScriptEvents(item.ItemID); |
218 | RemoveScriptInstance(item.ItemID); | ||
219 | m_part.RemoveScriptEvents(item.ItemID); | ||
220 | } | ||
221 | } | 227 | } |
222 | } | 228 | } |
229 | |||
230 | |||
223 | } | 231 | } |
224 | 232 | ||
225 | /// <summary> | 233 | /// <summary> |
@@ -244,8 +252,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
244 | if (stateSource == 1 && // Prim crossing | 252 | if (stateSource == 1 && // Prim crossing |
245 | m_part.ParentGroup.Scene.m_trustBinaries) | 253 | m_part.ParentGroup.Scene.m_trustBinaries) |
246 | { | 254 | { |
255 | m_items.LockItemsForWrite(true); | ||
247 | m_items[item.ItemID].PermsMask = 0; | 256 | m_items[item.ItemID].PermsMask = 0; |
248 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 257 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
258 | m_items.LockItemsForWrite(false); | ||
249 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 259 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
250 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 260 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
251 | m_part.ParentGroup.AddActiveScriptCount(1); | 261 | m_part.ParentGroup.AddActiveScriptCount(1); |
@@ -267,8 +277,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
267 | { | 277 | { |
268 | if (m_part.ParentGroup.m_savedScriptState != null) | 278 | if (m_part.ParentGroup.m_savedScriptState != null) |
269 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 279 | RestoreSavedScriptState(item.OldItemID, item.ItemID); |
280 | m_items.LockItemsForWrite(true); | ||
270 | m_items[item.ItemID].PermsMask = 0; | 281 | m_items[item.ItemID].PermsMask = 0; |
271 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 282 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
283 | m_items.LockItemsForWrite(false); | ||
272 | string script = Utils.BytesToString(asset.Data); | 284 | string script = Utils.BytesToString(asset.Data); |
273 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 285 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
274 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 286 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
@@ -303,14 +315,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
303 | /// </param> | 315 | /// </param> |
304 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | 316 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
305 | { | 317 | { |
306 | lock (m_items) | 318 | m_items.LockItemsForRead(true); |
319 | if (m_items.ContainsKey(itemId)) | ||
307 | { | 320 | { |
308 | if (m_items.ContainsKey(itemId)) | 321 | if (m_items.ContainsKey(itemId)) |
309 | { | 322 | { |
323 | m_items.LockItemsForRead(false); | ||
310 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); | 324 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); |
311 | } | 325 | } |
312 | else | 326 | else |
313 | { | 327 | { |
328 | m_items.LockItemsForRead(false); | ||
314 | m_log.ErrorFormat( | 329 | m_log.ErrorFormat( |
315 | "[PRIM INVENTORY]: " + | 330 | "[PRIM INVENTORY]: " + |
316 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", | 331 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", |
@@ -318,6 +333,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
318 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 333 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
319 | } | 334 | } |
320 | } | 335 | } |
336 | else | ||
337 | { | ||
338 | m_items.LockItemsForRead(false); | ||
339 | m_log.ErrorFormat( | ||
340 | "[PRIM INVENTORY]: " + | ||
341 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", | ||
342 | itemId, m_part.Name, m_part.UUID); | ||
343 | } | ||
344 | |||
321 | } | 345 | } |
322 | 346 | ||
323 | /// <summary> | 347 | /// <summary> |
@@ -349,11 +373,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
349 | /// <returns></returns> | 373 | /// <returns></returns> |
350 | private bool InventoryContainsName(string name) | 374 | private bool InventoryContainsName(string name) |
351 | { | 375 | { |
352 | foreach (TaskInventoryItem item in Items.Values) | 376 | m_items.LockItemsForRead(true); |
377 | foreach (TaskInventoryItem item in m_items.Values) | ||
353 | { | 378 | { |
354 | if (item.Name == name) | 379 | if (item.Name == name) |
380 | { | ||
381 | m_items.LockItemsForRead(false); | ||
355 | return true; | 382 | return true; |
383 | } | ||
356 | } | 384 | } |
385 | m_items.LockItemsForRead(false); | ||
357 | return false; | 386 | return false; |
358 | } | 387 | } |
359 | 388 | ||
@@ -395,7 +424,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
395 | /// <param name="item"></param> | 424 | /// <param name="item"></param> |
396 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 425 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
397 | { | 426 | { |
427 | m_items.LockItemsForRead(true); | ||
398 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); | 428 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); |
429 | m_items.LockItemsForRead(false); | ||
399 | foreach (TaskInventoryItem i in il) | 430 | foreach (TaskInventoryItem i in il) |
400 | { | 431 | { |
401 | if (i.Name == item.Name) | 432 | if (i.Name == item.Name) |
@@ -432,15 +463,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
432 | item.ParentPartID = m_part.UUID; | 463 | item.ParentPartID = m_part.UUID; |
433 | item.Name = name; | 464 | item.Name = name; |
434 | 465 | ||
435 | lock (m_items) | 466 | m_items.LockItemsForWrite(true); |
436 | { | 467 | m_items.Add(item.ItemID, item); |
437 | m_items.Add(item.ItemID, item); | 468 | m_items.LockItemsForWrite(false); |
438 | |||
439 | if (allowedDrop) | 469 | if (allowedDrop) |
440 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); | 470 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); |
441 | else | 471 | else |
442 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 472 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
443 | } | 473 | |
444 | 474 | ||
445 | m_inventorySerial++; | 475 | m_inventorySerial++; |
446 | //m_inventorySerial += 2; | 476 | //m_inventorySerial += 2; |
@@ -457,14 +487,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
457 | /// <param name="items"></param> | 487 | /// <param name="items"></param> |
458 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) | 488 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) |
459 | { | 489 | { |
460 | lock (m_items) | 490 | m_items.LockItemsForWrite(true); |
491 | foreach (TaskInventoryItem item in items) | ||
461 | { | 492 | { |
462 | foreach (TaskInventoryItem item in items) | 493 | m_items.Add(item.ItemID, item); |
463 | { | 494 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
464 | m_items.Add(item.ItemID, item); | ||
465 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
466 | } | ||
467 | } | 495 | } |
496 | m_items.LockItemsForWrite(false); | ||
468 | 497 | ||
469 | m_inventorySerial++; | 498 | m_inventorySerial++; |
470 | } | 499 | } |
@@ -477,8 +506,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
477 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 506 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
478 | { | 507 | { |
479 | TaskInventoryItem item; | 508 | TaskInventoryItem item; |
509 | m_items.LockItemsForRead(true); | ||
480 | m_items.TryGetValue(itemId, out item); | 510 | m_items.TryGetValue(itemId, out item); |
481 | 511 | m_items.LockItemsForRead(false); | |
482 | return item; | 512 | return item; |
483 | } | 513 | } |
484 | 514 | ||
@@ -490,46 +520,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
490 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> | 520 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> |
491 | public bool UpdateInventoryItem(TaskInventoryItem item) | 521 | public bool UpdateInventoryItem(TaskInventoryItem item) |
492 | { | 522 | { |
493 | lock (m_items) | 523 | m_items.LockItemsForWrite(true); |
524 | |||
525 | if (m_items.ContainsKey(item.ItemID)) | ||
494 | { | 526 | { |
495 | if (m_items.ContainsKey(item.ItemID)) | 527 | item.ParentID = m_part.UUID; |
528 | item.ParentPartID = m_part.UUID; | ||
529 | item.Flags = m_items[item.ItemID].Flags; | ||
530 | if (item.AssetID == UUID.Zero) | ||
496 | { | 531 | { |
497 | item.ParentID = m_part.UUID; | 532 | item.AssetID = m_items[item.ItemID].AssetID; |
498 | item.ParentPartID = m_part.UUID; | 533 | } |
499 | item.Flags = m_items[item.ItemID].Flags; | 534 | else if ((InventoryType)item.Type == InventoryType.Notecard) |
500 | if (item.AssetID == UUID.Zero) | 535 | { |
501 | { | 536 | ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); |
502 | item.AssetID = m_items[item.ItemID].AssetID; | ||
503 | } | ||
504 | else if ((InventoryType)item.Type == InventoryType.Notecard) | ||
505 | { | ||
506 | ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); | ||
507 | 537 | ||
508 | if (presence != null) | 538 | if (presence != null) |
509 | { | 539 | { |
510 | presence.ControllingClient.SendAgentAlertMessage( | 540 | presence.ControllingClient.SendAgentAlertMessage( |
511 | "Notecard saved", false); | 541 | "Notecard saved", false); |
512 | } | ||
513 | } | 542 | } |
543 | } | ||
514 | 544 | ||
515 | m_items[item.ItemID] = item; | 545 | m_items[item.ItemID] = item; |
516 | m_inventorySerial++; | 546 | m_inventorySerial++; |
517 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 547 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
518 | |||
519 | HasInventoryChanged = true; | ||
520 | m_part.ParentGroup.HasGroupChanged = true; | ||
521 | 548 | ||
522 | return true; | 549 | HasInventoryChanged = true; |
523 | } | 550 | m_part.ParentGroup.HasGroupChanged = true; |
524 | else | 551 | m_items.LockItemsForWrite(false); |
525 | { | 552 | return true; |
526 | m_log.ErrorFormat( | 553 | } |
527 | "[PRIM INVENTORY]: " + | 554 | else |
528 | "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | 555 | { |
529 | item.ItemID, m_part.Name, m_part.UUID, | 556 | m_log.ErrorFormat( |
530 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 557 | "[PRIM INVENTORY]: " + |
531 | } | 558 | "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", |
559 | item.ItemID, m_part.Name, m_part.UUID, | ||
560 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
532 | } | 561 | } |
562 | m_items.LockItemsForWrite(false); | ||
533 | 563 | ||
534 | return false; | 564 | return false; |
535 | } | 565 | } |
@@ -542,52 +572,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
542 | /// in this prim's inventory.</returns> | 572 | /// in this prim's inventory.</returns> |
543 | public int RemoveInventoryItem(UUID itemID) | 573 | public int RemoveInventoryItem(UUID itemID) |
544 | { | 574 | { |
545 | lock (m_items) | 575 | m_items.LockItemsForRead(true); |
576 | |||
577 | if (m_items.ContainsKey(itemID)) | ||
546 | { | 578 | { |
547 | if (m_items.ContainsKey(itemID)) | 579 | int type = m_items[itemID].InvType; |
580 | m_items.LockItemsForRead(false); | ||
581 | if (type == 10) // Script | ||
548 | { | 582 | { |
549 | int type = m_items[itemID].InvType; | 583 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); |
550 | if (type == 10) // Script | 584 | } |
551 | { | 585 | m_items.LockItemsForWrite(true); |
552 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 586 | m_items.Remove(itemID); |
553 | } | 587 | m_items.LockItemsForWrite(false); |
554 | m_items.Remove(itemID); | 588 | m_inventorySerial++; |
555 | m_inventorySerial++; | 589 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
556 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
557 | |||
558 | HasInventoryChanged = true; | ||
559 | m_part.ParentGroup.HasGroupChanged = true; | ||
560 | 590 | ||
561 | int scriptcount = 0; | 591 | HasInventoryChanged = true; |
562 | lock (m_items) | 592 | m_part.ParentGroup.HasGroupChanged = true; |
563 | { | ||
564 | foreach (TaskInventoryItem item in m_items.Values) | ||
565 | { | ||
566 | if (item.Type == 10) | ||
567 | { | ||
568 | scriptcount++; | ||
569 | } | ||
570 | } | ||
571 | } | ||
572 | 593 | ||
573 | if (scriptcount <= 0) | 594 | int scriptcount = 0; |
595 | m_items.LockItemsForRead(true); | ||
596 | foreach (TaskInventoryItem item in m_items.Values) | ||
597 | { | ||
598 | if (item.Type == 10) | ||
574 | { | 599 | { |
575 | m_part.RemFlag(PrimFlags.Scripted); | 600 | scriptcount++; |
576 | } | 601 | } |
577 | |||
578 | m_part.ScheduleFullUpdate(); | ||
579 | |||
580 | return type; | ||
581 | } | 602 | } |
582 | else | 603 | m_items.LockItemsForRead(false); |
604 | |||
605 | |||
606 | if (scriptcount <= 0) | ||
583 | { | 607 | { |
584 | m_log.ErrorFormat( | 608 | m_part.RemFlag(PrimFlags.Scripted); |
585 | "[PRIM INVENTORY]: " + | ||
586 | "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | ||
587 | itemID, m_part.Name, m_part.UUID, | ||
588 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
589 | } | 609 | } |
610 | |||
611 | m_part.ScheduleFullUpdate(); | ||
612 | |||
613 | return type; | ||
614 | } | ||
615 | else | ||
616 | { | ||
617 | m_log.ErrorFormat( | ||
618 | "[PRIM INVENTORY]: " + | ||
619 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | ||
620 | itemID, m_part.Name, m_part.UUID); | ||
590 | } | 621 | } |
622 | m_items.LockItemsForWrite(false); | ||
591 | 623 | ||
592 | return -1; | 624 | return -1; |
593 | } | 625 | } |
@@ -640,52 +672,53 @@ namespace OpenSim.Region.Framework.Scenes | |||
640 | // isn't available (such as drag from prim inventory to agent inventory) | 672 | // isn't available (such as drag from prim inventory to agent inventory) |
641 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | 673 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); |
642 | 674 | ||
643 | lock (m_items) | 675 | m_items.LockItemsForRead(true); |
676 | |||
677 | foreach (TaskInventoryItem item in m_items.Values) | ||
644 | { | 678 | { |
645 | foreach (TaskInventoryItem item in m_items.Values) | 679 | UUID ownerID = item.OwnerID; |
646 | { | 680 | uint everyoneMask = 0; |
647 | UUID ownerID = item.OwnerID; | 681 | uint baseMask = item.BasePermissions; |
648 | uint everyoneMask = 0; | 682 | uint ownerMask = item.CurrentPermissions; |
649 | uint baseMask = item.BasePermissions; | ||
650 | uint ownerMask = item.CurrentPermissions; | ||
651 | 683 | ||
652 | invString.AddItemStart(); | 684 | invString.AddItemStart(); |
653 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | 685 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); |
654 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | 686 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); |
655 | 687 | ||
656 | invString.AddPermissionsStart(); | 688 | invString.AddPermissionsStart(); |
657 | 689 | ||
658 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | 690 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); |
659 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | 691 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); |
660 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); | 692 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); |
661 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | 693 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); |
662 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | 694 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); |
663 | 695 | ||
664 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | 696 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); |
665 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | 697 | invString.AddNameValueLine("owner_id", ownerID.ToString()); |
666 | 698 | ||
667 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | 699 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); |
668 | 700 | ||
669 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | 701 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); |
670 | invString.AddSectionEnd(); | 702 | invString.AddSectionEnd(); |
671 | 703 | ||
672 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | 704 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); |
673 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); | 705 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); |
674 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); | 706 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); |
675 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | 707 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); |
676 | 708 | ||
677 | invString.AddSaleStart(); | 709 | invString.AddSaleStart(); |
678 | invString.AddNameValueLine("sale_type", "not"); | 710 | invString.AddNameValueLine("sale_type", "not"); |
679 | invString.AddNameValueLine("sale_price", "0"); | 711 | invString.AddNameValueLine("sale_price", "0"); |
680 | invString.AddSectionEnd(); | 712 | invString.AddSectionEnd(); |
681 | 713 | ||
682 | invString.AddNameValueLine("name", item.Name + "|"); | 714 | invString.AddNameValueLine("name", item.Name + "|"); |
683 | invString.AddNameValueLine("desc", item.Description + "|"); | 715 | invString.AddNameValueLine("desc", item.Description + "|"); |
684 | 716 | ||
685 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | 717 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); |
686 | invString.AddSectionEnd(); | 718 | invString.AddSectionEnd(); |
687 | } | ||
688 | } | 719 | } |
720 | int count = m_items.Count; | ||
721 | m_items.LockItemsForRead(false); | ||
689 | 722 | ||
690 | fileData = Utils.StringToBytes(invString.BuildString); | 723 | fileData = Utils.StringToBytes(invString.BuildString); |
691 | 724 | ||
@@ -706,10 +739,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
706 | { | 739 | { |
707 | if (HasInventoryChanged) | 740 | if (HasInventoryChanged) |
708 | { | 741 | { |
709 | lock (Items) | 742 | Items.LockItemsForRead(true); |
710 | { | 743 | datastore.StorePrimInventory(m_part.UUID, Items.Values); |
711 | datastore.StorePrimInventory(m_part.UUID, Items.Values); | 744 | Items.LockItemsForRead(false); |
712 | } | ||
713 | 745 | ||
714 | HasInventoryChanged = false; | 746 | HasInventoryChanged = false; |
715 | } | 747 | } |