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 eb7f5ff..c3c6342 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -82,7 +82,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
82 | /// </value> | 82 | /// </value> |
83 | protected internal TaskInventoryDictionary Items | 83 | protected internal TaskInventoryDictionary Items |
84 | { | 84 | { |
85 | get { return m_items; } | 85 | get { |
86 | return m_items; | ||
87 | } | ||
86 | set | 88 | set |
87 | { | 89 | { |
88 | m_items = value; | 90 | m_items = value; |
@@ -118,22 +120,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
118 | /// <param name="linkNum">Link number for the part</param> | 120 | /// <param name="linkNum">Link number for the part</param> |
119 | public void ResetInventoryIDs() | 121 | public void ResetInventoryIDs() |
120 | { | 122 | { |
121 | lock (Items) | 123 | m_items.LockItemsForWrite(true); |
124 | |||
125 | if (0 == Items.Count) | ||
122 | { | 126 | { |
123 | if (0 == Items.Count) | 127 | m_items.LockItemsForWrite(false); |
124 | return; | 128 | return; |
129 | } | ||
125 | 130 | ||
126 | HasInventoryChanged = true; | 131 | HasInventoryChanged = true; |
127 | m_part.ParentGroup.HasGroupChanged = true; | 132 | m_part.ParentGroup.HasGroupChanged = true; |
128 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 133 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
129 | Items.Clear(); | 134 | Items.Clear(); |
130 | 135 | ||
131 | foreach (TaskInventoryItem item in items) | 136 | foreach (TaskInventoryItem item in items) |
132 | { | 137 | { |
133 | item.ResetIDs(m_part.UUID); | 138 | item.ResetIDs(m_part.UUID); |
134 | Items.Add(item.ItemID, item); | 139 | Items.Add(item.ItemID, item); |
135 | } | ||
136 | } | 140 | } |
141 | m_items.LockItemsForWrite(false); | ||
137 | } | 142 | } |
138 | 143 | ||
139 | /// <summary> | 144 | /// <summary> |
@@ -142,25 +147,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
142 | /// <param name="ownerId"></param> | 147 | /// <param name="ownerId"></param> |
143 | public void ChangeInventoryOwner(UUID ownerId) | 148 | public void ChangeInventoryOwner(UUID ownerId) |
144 | { | 149 | { |
145 | lock (Items) | 150 | m_items.LockItemsForWrite(true); |
151 | if (0 == Items.Count) | ||
146 | { | 152 | { |
147 | if (0 == Items.Count) | 153 | m_items.LockItemsForWrite(false); |
148 | { | 154 | return; |
149 | return; | 155 | } |
150 | } | ||
151 | 156 | ||
152 | HasInventoryChanged = true; | 157 | HasInventoryChanged = true; |
153 | m_part.ParentGroup.HasGroupChanged = true; | 158 | m_part.ParentGroup.HasGroupChanged = true; |
154 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 159 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
155 | foreach (TaskInventoryItem item in items) | 160 | foreach (TaskInventoryItem item in items) |
161 | { | ||
162 | if (ownerId != item.OwnerID) | ||
156 | { | 163 | { |
157 | if (ownerId != item.OwnerID) | 164 | item.LastOwnerID = item.OwnerID; |
158 | { | 165 | item.OwnerID = ownerId; |
159 | item.LastOwnerID = item.OwnerID; | ||
160 | item.OwnerID = ownerId; | ||
161 | } | ||
162 | } | 166 | } |
163 | } | 167 | } |
168 | m_items.LockItemsForWrite(false); | ||
164 | } | 169 | } |
165 | 170 | ||
166 | /// <summary> | 171 | /// <summary> |
@@ -169,24 +174,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
169 | /// <param name="groupID"></param> | 174 | /// <param name="groupID"></param> |
170 | public void ChangeInventoryGroup(UUID groupID) | 175 | public void ChangeInventoryGroup(UUID groupID) |
171 | { | 176 | { |
172 | lock (Items) | 177 | m_items.LockItemsForWrite(true); |
178 | if (0 == Items.Count) | ||
173 | { | 179 | { |
174 | if (0 == Items.Count) | 180 | m_items.LockItemsForWrite(false); |
175 | { | 181 | return; |
176 | return; | 182 | } |
177 | } | ||
178 | 183 | ||
179 | HasInventoryChanged = true; | 184 | HasInventoryChanged = true; |
180 | m_part.ParentGroup.HasGroupChanged = true; | 185 | m_part.ParentGroup.HasGroupChanged = true; |
181 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 186 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
182 | foreach (TaskInventoryItem item in items) | 187 | foreach (TaskInventoryItem item in items) |
188 | { | ||
189 | if (groupID != item.GroupID) | ||
183 | { | 190 | { |
184 | if (groupID != item.GroupID) | 191 | item.GroupID = groupID; |
185 | { | ||
186 | item.GroupID = groupID; | ||
187 | } | ||
188 | } | 192 | } |
189 | } | 193 | } |
194 | m_items.LockItemsForWrite(false); | ||
190 | } | 195 | } |
191 | 196 | ||
192 | /// <summary> | 197 | /// <summary> |
@@ -194,14 +199,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
194 | /// </summary> | 199 | /// </summary> |
195 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) | 200 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
196 | { | 201 | { |
197 | lock (m_items) | 202 | Items.LockItemsForRead(true); |
203 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
204 | Items.LockItemsForRead(false); | ||
205 | foreach (TaskInventoryItem item in items) | ||
198 | { | 206 | { |
199 | foreach (TaskInventoryItem item in Items.Values) | 207 | if ((int)InventoryType.LSL == item.InvType) |
200 | { | 208 | { |
201 | if ((int)InventoryType.LSL == item.InvType) | 209 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); |
202 | { | ||
203 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | ||
204 | } | ||
205 | } | 210 | } |
206 | } | 211 | } |
207 | } | 212 | } |
@@ -232,17 +237,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
232 | /// </summary> | 237 | /// </summary> |
233 | public void RemoveScriptInstances() | 238 | public void RemoveScriptInstances() |
234 | { | 239 | { |
235 | lock (Items) | 240 | Items.LockItemsForRead(true); |
241 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
242 | Items.LockItemsForRead(false); | ||
243 | |||
244 | foreach (TaskInventoryItem item in items) | ||
236 | { | 245 | { |
237 | foreach (TaskInventoryItem item in Items.Values) | 246 | if ((int)InventoryType.LSL == item.InvType) |
238 | { | 247 | { |
239 | if ((int)InventoryType.LSL == item.InvType) | 248 | RemoveScriptInstance(item.ItemID); |
240 | { | 249 | m_part.RemoveScriptEvents(item.ItemID); |
241 | RemoveScriptInstance(item.ItemID); | ||
242 | m_part.RemoveScriptEvents(item.ItemID); | ||
243 | } | ||
244 | } | 250 | } |
245 | } | 251 | } |
252 | |||
253 | |||
246 | } | 254 | } |
247 | 255 | ||
248 | /// <summary> | 256 | /// <summary> |
@@ -267,8 +275,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
267 | if (stateSource == 1 && // Prim crossing | 275 | if (stateSource == 1 && // Prim crossing |
268 | m_part.ParentGroup.Scene.m_trustBinaries) | 276 | m_part.ParentGroup.Scene.m_trustBinaries) |
269 | { | 277 | { |
278 | m_items.LockItemsForWrite(true); | ||
270 | m_items[item.ItemID].PermsMask = 0; | 279 | m_items[item.ItemID].PermsMask = 0; |
271 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 280 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
281 | m_items.LockItemsForWrite(false); | ||
272 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 282 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
273 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 283 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
274 | m_part.ParentGroup.AddActiveScriptCount(1); | 284 | m_part.ParentGroup.AddActiveScriptCount(1); |
@@ -290,8 +300,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
290 | { | 300 | { |
291 | if (m_part.ParentGroup.m_savedScriptState != null) | 301 | if (m_part.ParentGroup.m_savedScriptState != null) |
292 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 302 | RestoreSavedScriptState(item.OldItemID, item.ItemID); |
303 | m_items.LockItemsForWrite(true); | ||
293 | m_items[item.ItemID].PermsMask = 0; | 304 | m_items[item.ItemID].PermsMask = 0; |
294 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 305 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
306 | m_items.LockItemsForWrite(false); | ||
295 | string script = Utils.BytesToString(asset.Data); | 307 | string script = Utils.BytesToString(asset.Data); |
296 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 308 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
297 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 309 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
@@ -367,14 +379,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
367 | /// </param> | 379 | /// </param> |
368 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | 380 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
369 | { | 381 | { |
370 | lock (m_items) | 382 | m_items.LockItemsForRead(true); |
383 | if (m_items.ContainsKey(itemId)) | ||
371 | { | 384 | { |
372 | if (m_items.ContainsKey(itemId)) | 385 | if (m_items.ContainsKey(itemId)) |
373 | { | 386 | { |
387 | m_items.LockItemsForRead(false); | ||
374 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); | 388 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); |
375 | } | 389 | } |
376 | else | 390 | else |
377 | { | 391 | { |
392 | m_items.LockItemsForRead(false); | ||
378 | m_log.ErrorFormat( | 393 | m_log.ErrorFormat( |
379 | "[PRIM INVENTORY]: " + | 394 | "[PRIM INVENTORY]: " + |
380 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", | 395 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", |
@@ -382,6 +397,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
382 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 397 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
383 | } | 398 | } |
384 | } | 399 | } |
400 | else | ||
401 | { | ||
402 | m_items.LockItemsForRead(false); | ||
403 | m_log.ErrorFormat( | ||
404 | "[PRIM INVENTORY]: " + | ||
405 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", | ||
406 | itemId, m_part.Name, m_part.UUID); | ||
407 | } | ||
408 | |||
385 | } | 409 | } |
386 | 410 | ||
387 | /// <summary> | 411 | /// <summary> |
@@ -413,11 +437,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
413 | /// <returns></returns> | 437 | /// <returns></returns> |
414 | private bool InventoryContainsName(string name) | 438 | private bool InventoryContainsName(string name) |
415 | { | 439 | { |
416 | foreach (TaskInventoryItem item in Items.Values) | 440 | m_items.LockItemsForRead(true); |
441 | foreach (TaskInventoryItem item in m_items.Values) | ||
417 | { | 442 | { |
418 | if (item.Name == name) | 443 | if (item.Name == name) |
444 | { | ||
445 | m_items.LockItemsForRead(false); | ||
419 | return true; | 446 | return true; |
447 | } | ||
420 | } | 448 | } |
449 | m_items.LockItemsForRead(false); | ||
421 | return false; | 450 | return false; |
422 | } | 451 | } |
423 | 452 | ||
@@ -459,7 +488,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
459 | /// <param name="item"></param> | 488 | /// <param name="item"></param> |
460 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 489 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
461 | { | 490 | { |
491 | m_items.LockItemsForRead(true); | ||
462 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); | 492 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); |
493 | m_items.LockItemsForRead(false); | ||
463 | foreach (TaskInventoryItem i in il) | 494 | foreach (TaskInventoryItem i in il) |
464 | { | 495 | { |
465 | if (i.Name == item.Name) | 496 | if (i.Name == item.Name) |
@@ -496,15 +527,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
496 | item.ParentPartID = m_part.UUID; | 527 | item.ParentPartID = m_part.UUID; |
497 | item.Name = name; | 528 | item.Name = name; |
498 | 529 | ||
499 | lock (m_items) | 530 | m_items.LockItemsForWrite(true); |
500 | { | 531 | m_items.Add(item.ItemID, item); |
501 | m_items.Add(item.ItemID, item); | 532 | m_items.LockItemsForWrite(false); |
502 | |||
503 | if (allowedDrop) | 533 | if (allowedDrop) |
504 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); | 534 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); |
505 | else | 535 | else |
506 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 536 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
507 | } | 537 | |
508 | 538 | ||
509 | m_inventorySerial++; | 539 | m_inventorySerial++; |
510 | //m_inventorySerial += 2; | 540 | //m_inventorySerial += 2; |
@@ -521,14 +551,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
521 | /// <param name="items"></param> | 551 | /// <param name="items"></param> |
522 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) | 552 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) |
523 | { | 553 | { |
524 | lock (m_items) | 554 | m_items.LockItemsForWrite(true); |
555 | foreach (TaskInventoryItem item in items) | ||
525 | { | 556 | { |
526 | foreach (TaskInventoryItem item in items) | 557 | m_items.Add(item.ItemID, item); |
527 | { | 558 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
528 | m_items.Add(item.ItemID, item); | ||
529 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
530 | } | ||
531 | } | 559 | } |
560 | m_items.LockItemsForWrite(false); | ||
532 | 561 | ||
533 | m_inventorySerial++; | 562 | m_inventorySerial++; |
534 | } | 563 | } |
@@ -541,8 +570,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
541 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 570 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
542 | { | 571 | { |
543 | TaskInventoryItem item; | 572 | TaskInventoryItem item; |
573 | m_items.LockItemsForRead(true); | ||
544 | m_items.TryGetValue(itemId, out item); | 574 | m_items.TryGetValue(itemId, out item); |
545 | 575 | m_items.LockItemsForRead(false); | |
546 | return item; | 576 | return item; |
547 | } | 577 | } |
548 | 578 | ||
@@ -554,46 +584,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
554 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> | 584 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> |
555 | public bool UpdateInventoryItem(TaskInventoryItem item) | 585 | public bool UpdateInventoryItem(TaskInventoryItem item) |
556 | { | 586 | { |
557 | lock (m_items) | 587 | m_items.LockItemsForWrite(true); |
588 | |||
589 | if (m_items.ContainsKey(item.ItemID)) | ||
558 | { | 590 | { |
559 | if (m_items.ContainsKey(item.ItemID)) | 591 | item.ParentID = m_part.UUID; |
592 | item.ParentPartID = m_part.UUID; | ||
593 | item.Flags = m_items[item.ItemID].Flags; | ||
594 | if (item.AssetID == UUID.Zero) | ||
560 | { | 595 | { |
561 | item.ParentID = m_part.UUID; | 596 | item.AssetID = m_items[item.ItemID].AssetID; |
562 | item.ParentPartID = m_part.UUID; | 597 | } |
563 | item.Flags = m_items[item.ItemID].Flags; | 598 | else if ((InventoryType)item.Type == InventoryType.Notecard) |
564 | if (item.AssetID == UUID.Zero) | 599 | { |
565 | { | 600 | ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); |
566 | item.AssetID = m_items[item.ItemID].AssetID; | ||
567 | } | ||
568 | else if ((InventoryType)item.Type == InventoryType.Notecard) | ||
569 | { | ||
570 | ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); | ||
571 | 601 | ||
572 | if (presence != null) | 602 | if (presence != null) |
573 | { | 603 | { |
574 | presence.ControllingClient.SendAgentAlertMessage( | 604 | presence.ControllingClient.SendAgentAlertMessage( |
575 | "Notecard saved", false); | 605 | "Notecard saved", false); |
576 | } | ||
577 | } | 606 | } |
607 | } | ||
578 | 608 | ||
579 | m_items[item.ItemID] = item; | 609 | m_items[item.ItemID] = item; |
580 | m_inventorySerial++; | 610 | m_inventorySerial++; |
581 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 611 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
582 | |||
583 | HasInventoryChanged = true; | ||
584 | m_part.ParentGroup.HasGroupChanged = true; | ||
585 | 612 | ||
586 | return true; | 613 | HasInventoryChanged = true; |
587 | } | 614 | m_part.ParentGroup.HasGroupChanged = true; |
588 | else | 615 | m_items.LockItemsForWrite(false); |
589 | { | 616 | return true; |
590 | m_log.ErrorFormat( | 617 | } |
591 | "[PRIM INVENTORY]: " + | 618 | else |
592 | "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | 619 | { |
593 | item.ItemID, m_part.Name, m_part.UUID, | 620 | m_log.ErrorFormat( |
594 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 621 | "[PRIM INVENTORY]: " + |
595 | } | 622 | "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", |
623 | item.ItemID, m_part.Name, m_part.UUID, | ||
624 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
596 | } | 625 | } |
626 | m_items.LockItemsForWrite(false); | ||
597 | 627 | ||
598 | return false; | 628 | return false; |
599 | } | 629 | } |
@@ -606,52 +636,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
606 | /// in this prim's inventory.</returns> | 636 | /// in this prim's inventory.</returns> |
607 | public int RemoveInventoryItem(UUID itemID) | 637 | public int RemoveInventoryItem(UUID itemID) |
608 | { | 638 | { |
609 | lock (m_items) | 639 | m_items.LockItemsForRead(true); |
640 | |||
641 | if (m_items.ContainsKey(itemID)) | ||
610 | { | 642 | { |
611 | if (m_items.ContainsKey(itemID)) | 643 | int type = m_items[itemID].InvType; |
644 | m_items.LockItemsForRead(false); | ||
645 | if (type == 10) // Script | ||
612 | { | 646 | { |
613 | int type = m_items[itemID].InvType; | 647 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); |
614 | if (type == 10) // Script | 648 | } |
615 | { | 649 | m_items.LockItemsForWrite(true); |
616 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 650 | m_items.Remove(itemID); |
617 | } | 651 | m_items.LockItemsForWrite(false); |
618 | m_items.Remove(itemID); | 652 | m_inventorySerial++; |
619 | m_inventorySerial++; | 653 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
620 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
621 | |||
622 | HasInventoryChanged = true; | ||
623 | m_part.ParentGroup.HasGroupChanged = true; | ||
624 | 654 | ||
625 | int scriptcount = 0; | 655 | HasInventoryChanged = true; |
626 | lock (m_items) | 656 | m_part.ParentGroup.HasGroupChanged = true; |
627 | { | ||
628 | foreach (TaskInventoryItem item in m_items.Values) | ||
629 | { | ||
630 | if (item.Type == 10) | ||
631 | { | ||
632 | scriptcount++; | ||
633 | } | ||
634 | } | ||
635 | } | ||
636 | 657 | ||
637 | if (scriptcount <= 0) | 658 | int scriptcount = 0; |
659 | m_items.LockItemsForRead(true); | ||
660 | foreach (TaskInventoryItem item in m_items.Values) | ||
661 | { | ||
662 | if (item.Type == 10) | ||
638 | { | 663 | { |
639 | m_part.RemFlag(PrimFlags.Scripted); | 664 | scriptcount++; |
640 | } | 665 | } |
641 | |||
642 | m_part.ScheduleFullUpdate(); | ||
643 | |||
644 | return type; | ||
645 | } | 666 | } |
646 | else | 667 | m_items.LockItemsForRead(false); |
668 | |||
669 | |||
670 | if (scriptcount <= 0) | ||
647 | { | 671 | { |
648 | m_log.ErrorFormat( | 672 | m_part.RemFlag(PrimFlags.Scripted); |
649 | "[PRIM INVENTORY]: " + | ||
650 | "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | ||
651 | itemID, m_part.Name, m_part.UUID, | ||
652 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
653 | } | 673 | } |
674 | |||
675 | m_part.ScheduleFullUpdate(); | ||
676 | |||
677 | return type; | ||
678 | } | ||
679 | else | ||
680 | { | ||
681 | m_log.ErrorFormat( | ||
682 | "[PRIM INVENTORY]: " + | ||
683 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | ||
684 | itemID, m_part.Name, m_part.UUID); | ||
654 | } | 685 | } |
686 | m_items.LockItemsForWrite(false); | ||
655 | 687 | ||
656 | return -1; | 688 | return -1; |
657 | } | 689 | } |
@@ -704,52 +736,53 @@ namespace OpenSim.Region.Framework.Scenes | |||
704 | // isn't available (such as drag from prim inventory to agent inventory) | 736 | // isn't available (such as drag from prim inventory to agent inventory) |
705 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | 737 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); |
706 | 738 | ||
707 | lock (m_items) | 739 | m_items.LockItemsForRead(true); |
740 | |||
741 | foreach (TaskInventoryItem item in m_items.Values) | ||
708 | { | 742 | { |
709 | foreach (TaskInventoryItem item in m_items.Values) | 743 | UUID ownerID = item.OwnerID; |
710 | { | 744 | uint everyoneMask = 0; |
711 | UUID ownerID = item.OwnerID; | 745 | uint baseMask = item.BasePermissions; |
712 | uint everyoneMask = 0; | 746 | uint ownerMask = item.CurrentPermissions; |
713 | uint baseMask = item.BasePermissions; | ||
714 | uint ownerMask = item.CurrentPermissions; | ||
715 | 747 | ||
716 | invString.AddItemStart(); | 748 | invString.AddItemStart(); |
717 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | 749 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); |
718 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | 750 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); |
719 | 751 | ||
720 | invString.AddPermissionsStart(); | 752 | invString.AddPermissionsStart(); |
721 | 753 | ||
722 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | 754 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); |
723 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | 755 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); |
724 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); | 756 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); |
725 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | 757 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); |
726 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | 758 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); |
727 | 759 | ||
728 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | 760 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); |
729 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | 761 | invString.AddNameValueLine("owner_id", ownerID.ToString()); |
730 | 762 | ||
731 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | 763 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); |
732 | 764 | ||
733 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | 765 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); |
734 | invString.AddSectionEnd(); | 766 | invString.AddSectionEnd(); |
735 | 767 | ||
736 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | 768 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); |
737 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); | 769 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); |
738 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); | 770 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); |
739 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | 771 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); |
740 | 772 | ||
741 | invString.AddSaleStart(); | 773 | invString.AddSaleStart(); |
742 | invString.AddNameValueLine("sale_type", "not"); | 774 | invString.AddNameValueLine("sale_type", "not"); |
743 | invString.AddNameValueLine("sale_price", "0"); | 775 | invString.AddNameValueLine("sale_price", "0"); |
744 | invString.AddSectionEnd(); | 776 | invString.AddSectionEnd(); |
745 | 777 | ||
746 | invString.AddNameValueLine("name", item.Name + "|"); | 778 | invString.AddNameValueLine("name", item.Name + "|"); |
747 | invString.AddNameValueLine("desc", item.Description + "|"); | 779 | invString.AddNameValueLine("desc", item.Description + "|"); |
748 | 780 | ||
749 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | 781 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); |
750 | invString.AddSectionEnd(); | 782 | invString.AddSectionEnd(); |
751 | } | ||
752 | } | 783 | } |
784 | int count = m_items.Count; | ||
785 | m_items.LockItemsForRead(false); | ||
753 | 786 | ||
754 | fileData = Utils.StringToBytes(invString.BuildString); | 787 | fileData = Utils.StringToBytes(invString.BuildString); |
755 | 788 | ||
@@ -770,10 +803,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
770 | { | 803 | { |
771 | if (HasInventoryChanged) | 804 | if (HasInventoryChanged) |
772 | { | 805 | { |
773 | lock (Items) | 806 | Items.LockItemsForRead(true); |
774 | { | 807 | datastore.StorePrimInventory(m_part.UUID, Items.Values); |
775 | datastore.StorePrimInventory(m_part.UUID, Items.Values); | 808 | Items.LockItemsForRead(false); |
776 | } | ||
777 | 809 | ||
778 | HasInventoryChanged = false; | 810 | HasInventoryChanged = false; |
779 | } | 811 | } |