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 47e4ad0..0321c41 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -81,7 +81,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
81 | /// </value> | 81 | /// </value> |
82 | protected internal TaskInventoryDictionary Items | 82 | protected internal TaskInventoryDictionary Items |
83 | { | 83 | { |
84 | get { return m_items; } | 84 | get { |
85 | return m_items; | ||
86 | } | ||
85 | set | 87 | set |
86 | { | 88 | { |
87 | m_items = value; | 89 | m_items = value; |
@@ -117,22 +119,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
117 | /// <param name="linkNum">Link number for the part</param> | 119 | /// <param name="linkNum">Link number for the part</param> |
118 | public void ResetInventoryIDs() | 120 | public void ResetInventoryIDs() |
119 | { | 121 | { |
120 | lock (Items) | 122 | m_items.LockItemsForWrite(true); |
123 | |||
124 | if (0 == Items.Count) | ||
121 | { | 125 | { |
122 | if (0 == Items.Count) | 126 | m_items.LockItemsForWrite(false); |
123 | return; | 127 | return; |
128 | } | ||
124 | 129 | ||
125 | HasInventoryChanged = true; | 130 | HasInventoryChanged = true; |
126 | m_part.ParentGroup.HasGroupChanged = true; | 131 | m_part.ParentGroup.HasGroupChanged = true; |
127 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 132 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
128 | Items.Clear(); | 133 | Items.Clear(); |
129 | 134 | ||
130 | foreach (TaskInventoryItem item in items) | 135 | foreach (TaskInventoryItem item in items) |
131 | { | 136 | { |
132 | item.ResetIDs(m_part.UUID); | 137 | item.ResetIDs(m_part.UUID); |
133 | Items.Add(item.ItemID, item); | 138 | Items.Add(item.ItemID, item); |
134 | } | ||
135 | } | 139 | } |
140 | m_items.LockItemsForWrite(false); | ||
136 | } | 141 | } |
137 | 142 | ||
138 | /// <summary> | 143 | /// <summary> |
@@ -141,25 +146,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
141 | /// <param name="ownerId"></param> | 146 | /// <param name="ownerId"></param> |
142 | public void ChangeInventoryOwner(UUID ownerId) | 147 | public void ChangeInventoryOwner(UUID ownerId) |
143 | { | 148 | { |
144 | lock (Items) | 149 | m_items.LockItemsForWrite(true); |
150 | if (0 == Items.Count) | ||
145 | { | 151 | { |
146 | if (0 == Items.Count) | 152 | m_items.LockItemsForWrite(false); |
147 | { | 153 | return; |
148 | return; | 154 | } |
149 | } | ||
150 | 155 | ||
151 | HasInventoryChanged = true; | 156 | HasInventoryChanged = true; |
152 | m_part.ParentGroup.HasGroupChanged = true; | 157 | m_part.ParentGroup.HasGroupChanged = true; |
153 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 158 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
154 | foreach (TaskInventoryItem item in items) | 159 | foreach (TaskInventoryItem item in items) |
160 | { | ||
161 | if (ownerId != item.OwnerID) | ||
155 | { | 162 | { |
156 | if (ownerId != item.OwnerID) | 163 | item.LastOwnerID = item.OwnerID; |
157 | { | 164 | item.OwnerID = ownerId; |
158 | item.LastOwnerID = item.OwnerID; | ||
159 | item.OwnerID = ownerId; | ||
160 | } | ||
161 | } | 165 | } |
162 | } | 166 | } |
167 | m_items.LockItemsForWrite(false); | ||
163 | } | 168 | } |
164 | 169 | ||
165 | /// <summary> | 170 | /// <summary> |
@@ -168,24 +173,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
168 | /// <param name="groupID"></param> | 173 | /// <param name="groupID"></param> |
169 | public void ChangeInventoryGroup(UUID groupID) | 174 | public void ChangeInventoryGroup(UUID groupID) |
170 | { | 175 | { |
171 | lock (Items) | 176 | m_items.LockItemsForWrite(true); |
177 | if (0 == Items.Count) | ||
172 | { | 178 | { |
173 | if (0 == Items.Count) | 179 | m_items.LockItemsForWrite(false); |
174 | { | 180 | return; |
175 | return; | 181 | } |
176 | } | ||
177 | 182 | ||
178 | HasInventoryChanged = true; | 183 | HasInventoryChanged = true; |
179 | m_part.ParentGroup.HasGroupChanged = true; | 184 | m_part.ParentGroup.HasGroupChanged = true; |
180 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 185 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
181 | foreach (TaskInventoryItem item in items) | 186 | foreach (TaskInventoryItem item in items) |
187 | { | ||
188 | if (groupID != item.GroupID) | ||
182 | { | 189 | { |
183 | if (groupID != item.GroupID) | 190 | item.GroupID = groupID; |
184 | { | ||
185 | item.GroupID = groupID; | ||
186 | } | ||
187 | } | 191 | } |
188 | } | 192 | } |
193 | m_items.LockItemsForWrite(false); | ||
189 | } | 194 | } |
190 | 195 | ||
191 | /// <summary> | 196 | /// <summary> |
@@ -193,14 +198,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
193 | /// </summary> | 198 | /// </summary> |
194 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) | 199 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
195 | { | 200 | { |
196 | lock (m_items) | 201 | Items.LockItemsForRead(true); |
202 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
203 | Items.LockItemsForRead(false); | ||
204 | foreach (TaskInventoryItem item in items) | ||
197 | { | 205 | { |
198 | foreach (TaskInventoryItem item in Items.Values) | 206 | if ((int)InventoryType.LSL == item.InvType) |
199 | { | 207 | { |
200 | if ((int)InventoryType.LSL == item.InvType) | 208 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); |
201 | { | ||
202 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | ||
203 | } | ||
204 | } | 209 | } |
205 | } | 210 | } |
206 | } | 211 | } |
@@ -210,17 +215,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
210 | /// </summary> | 215 | /// </summary> |
211 | public void RemoveScriptInstances() | 216 | public void RemoveScriptInstances() |
212 | { | 217 | { |
213 | lock (Items) | 218 | Items.LockItemsForRead(true); |
219 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
220 | Items.LockItemsForRead(false); | ||
221 | |||
222 | foreach (TaskInventoryItem item in items) | ||
214 | { | 223 | { |
215 | foreach (TaskInventoryItem item in Items.Values) | 224 | if ((int)InventoryType.LSL == item.InvType) |
216 | { | 225 | { |
217 | if ((int)InventoryType.LSL == item.InvType) | 226 | RemoveScriptInstance(item.ItemID); |
218 | { | 227 | m_part.RemoveScriptEvents(item.ItemID); |
219 | RemoveScriptInstance(item.ItemID); | ||
220 | m_part.RemoveScriptEvents(item.ItemID); | ||
221 | } | ||
222 | } | 228 | } |
223 | } | 229 | } |
230 | |||
231 | |||
224 | } | 232 | } |
225 | 233 | ||
226 | /// <summary> | 234 | /// <summary> |
@@ -245,8 +253,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
245 | if (stateSource == 1 && // Prim crossing | 253 | if (stateSource == 1 && // Prim crossing |
246 | m_part.ParentGroup.Scene.m_trustBinaries) | 254 | m_part.ParentGroup.Scene.m_trustBinaries) |
247 | { | 255 | { |
256 | m_items.LockItemsForWrite(true); | ||
248 | m_items[item.ItemID].PermsMask = 0; | 257 | m_items[item.ItemID].PermsMask = 0; |
249 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 258 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
259 | m_items.LockItemsForWrite(false); | ||
250 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 260 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
251 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 261 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
252 | m_part.ParentGroup.AddActiveScriptCount(1); | 262 | m_part.ParentGroup.AddActiveScriptCount(1); |
@@ -268,8 +278,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
268 | { | 278 | { |
269 | if (m_part.ParentGroup.m_savedScriptState != null) | 279 | if (m_part.ParentGroup.m_savedScriptState != null) |
270 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 280 | RestoreSavedScriptState(item.OldItemID, item.ItemID); |
281 | m_items.LockItemsForWrite(true); | ||
271 | m_items[item.ItemID].PermsMask = 0; | 282 | m_items[item.ItemID].PermsMask = 0; |
272 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 283 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
284 | m_items.LockItemsForWrite(false); | ||
273 | string script = Utils.BytesToString(asset.Data); | 285 | string script = Utils.BytesToString(asset.Data); |
274 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 286 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
275 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 287 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
@@ -344,14 +356,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
344 | /// </param> | 356 | /// </param> |
345 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | 357 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
346 | { | 358 | { |
347 | lock (m_items) | 359 | m_items.LockItemsForRead(true); |
360 | if (m_items.ContainsKey(itemId)) | ||
348 | { | 361 | { |
349 | if (m_items.ContainsKey(itemId)) | 362 | if (m_items.ContainsKey(itemId)) |
350 | { | 363 | { |
364 | m_items.LockItemsForRead(false); | ||
351 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); | 365 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); |
352 | } | 366 | } |
353 | else | 367 | else |
354 | { | 368 | { |
369 | m_items.LockItemsForRead(false); | ||
355 | m_log.ErrorFormat( | 370 | m_log.ErrorFormat( |
356 | "[PRIM INVENTORY]: " + | 371 | "[PRIM INVENTORY]: " + |
357 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", | 372 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", |
@@ -359,6 +374,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
359 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 374 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
360 | } | 375 | } |
361 | } | 376 | } |
377 | else | ||
378 | { | ||
379 | m_items.LockItemsForRead(false); | ||
380 | m_log.ErrorFormat( | ||
381 | "[PRIM INVENTORY]: " + | ||
382 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", | ||
383 | itemId, m_part.Name, m_part.UUID); | ||
384 | } | ||
385 | |||
362 | } | 386 | } |
363 | 387 | ||
364 | /// <summary> | 388 | /// <summary> |
@@ -390,11 +414,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
390 | /// <returns></returns> | 414 | /// <returns></returns> |
391 | private bool InventoryContainsName(string name) | 415 | private bool InventoryContainsName(string name) |
392 | { | 416 | { |
393 | foreach (TaskInventoryItem item in Items.Values) | 417 | m_items.LockItemsForRead(true); |
418 | foreach (TaskInventoryItem item in m_items.Values) | ||
394 | { | 419 | { |
395 | if (item.Name == name) | 420 | if (item.Name == name) |
421 | { | ||
422 | m_items.LockItemsForRead(false); | ||
396 | return true; | 423 | return true; |
424 | } | ||
397 | } | 425 | } |
426 | m_items.LockItemsForRead(false); | ||
398 | return false; | 427 | return false; |
399 | } | 428 | } |
400 | 429 | ||
@@ -436,7 +465,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
436 | /// <param name="item"></param> | 465 | /// <param name="item"></param> |
437 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 466 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
438 | { | 467 | { |
468 | m_items.LockItemsForRead(true); | ||
439 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); | 469 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); |
470 | m_items.LockItemsForRead(false); | ||
440 | foreach (TaskInventoryItem i in il) | 471 | foreach (TaskInventoryItem i in il) |
441 | { | 472 | { |
442 | if (i.Name == item.Name) | 473 | if (i.Name == item.Name) |
@@ -473,15 +504,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
473 | item.ParentPartID = m_part.UUID; | 504 | item.ParentPartID = m_part.UUID; |
474 | item.Name = name; | 505 | item.Name = name; |
475 | 506 | ||
476 | lock (m_items) | 507 | m_items.LockItemsForWrite(true); |
477 | { | 508 | m_items.Add(item.ItemID, item); |
478 | m_items.Add(item.ItemID, item); | 509 | m_items.LockItemsForWrite(false); |
479 | |||
480 | if (allowedDrop) | 510 | if (allowedDrop) |
481 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); | 511 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); |
482 | else | 512 | else |
483 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 513 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
484 | } | 514 | |
485 | 515 | ||
486 | m_inventorySerial++; | 516 | m_inventorySerial++; |
487 | //m_inventorySerial += 2; | 517 | //m_inventorySerial += 2; |
@@ -498,14 +528,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
498 | /// <param name="items"></param> | 528 | /// <param name="items"></param> |
499 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) | 529 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) |
500 | { | 530 | { |
501 | lock (m_items) | 531 | m_items.LockItemsForWrite(true); |
532 | foreach (TaskInventoryItem item in items) | ||
502 | { | 533 | { |
503 | foreach (TaskInventoryItem item in items) | 534 | m_items.Add(item.ItemID, item); |
504 | { | 535 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
505 | m_items.Add(item.ItemID, item); | ||
506 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
507 | } | ||
508 | } | 536 | } |
537 | m_items.LockItemsForWrite(false); | ||
509 | 538 | ||
510 | m_inventorySerial++; | 539 | m_inventorySerial++; |
511 | } | 540 | } |
@@ -518,8 +547,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
518 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 547 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
519 | { | 548 | { |
520 | TaskInventoryItem item; | 549 | TaskInventoryItem item; |
550 | m_items.LockItemsForRead(true); | ||
521 | m_items.TryGetValue(itemId, out item); | 551 | m_items.TryGetValue(itemId, out item); |
522 | 552 | m_items.LockItemsForRead(false); | |
523 | return item; | 553 | return item; |
524 | } | 554 | } |
525 | 555 | ||
@@ -531,46 +561,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
531 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> | 561 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> |
532 | public bool UpdateInventoryItem(TaskInventoryItem item) | 562 | public bool UpdateInventoryItem(TaskInventoryItem item) |
533 | { | 563 | { |
534 | lock (m_items) | 564 | m_items.LockItemsForWrite(true); |
565 | |||
566 | if (m_items.ContainsKey(item.ItemID)) | ||
535 | { | 567 | { |
536 | if (m_items.ContainsKey(item.ItemID)) | 568 | item.ParentID = m_part.UUID; |
569 | item.ParentPartID = m_part.UUID; | ||
570 | item.Flags = m_items[item.ItemID].Flags; | ||
571 | if (item.AssetID == UUID.Zero) | ||
537 | { | 572 | { |
538 | item.ParentID = m_part.UUID; | 573 | item.AssetID = m_items[item.ItemID].AssetID; |
539 | item.ParentPartID = m_part.UUID; | 574 | } |
540 | item.Flags = m_items[item.ItemID].Flags; | 575 | else if ((InventoryType)item.Type == InventoryType.Notecard) |
541 | if (item.AssetID == UUID.Zero) | 576 | { |
542 | { | 577 | ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); |
543 | item.AssetID = m_items[item.ItemID].AssetID; | ||
544 | } | ||
545 | else if ((InventoryType)item.Type == InventoryType.Notecard) | ||
546 | { | ||
547 | ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); | ||
548 | 578 | ||
549 | if (presence != null) | 579 | if (presence != null) |
550 | { | 580 | { |
551 | presence.ControllingClient.SendAgentAlertMessage( | 581 | presence.ControllingClient.SendAgentAlertMessage( |
552 | "Notecard saved", false); | 582 | "Notecard saved", false); |
553 | } | ||
554 | } | 583 | } |
584 | } | ||
555 | 585 | ||
556 | m_items[item.ItemID] = item; | 586 | m_items[item.ItemID] = item; |
557 | m_inventorySerial++; | 587 | m_inventorySerial++; |
558 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 588 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
559 | |||
560 | HasInventoryChanged = true; | ||
561 | m_part.ParentGroup.HasGroupChanged = true; | ||
562 | 589 | ||
563 | return true; | 590 | HasInventoryChanged = true; |
564 | } | 591 | m_part.ParentGroup.HasGroupChanged = true; |
565 | else | 592 | m_items.LockItemsForWrite(false); |
566 | { | 593 | return true; |
567 | m_log.ErrorFormat( | 594 | } |
568 | "[PRIM INVENTORY]: " + | 595 | else |
569 | "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | 596 | { |
570 | item.ItemID, m_part.Name, m_part.UUID, | 597 | m_log.ErrorFormat( |
571 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 598 | "[PRIM INVENTORY]: " + |
572 | } | 599 | "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", |
600 | item.ItemID, m_part.Name, m_part.UUID, | ||
601 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
573 | } | 602 | } |
603 | m_items.LockItemsForWrite(false); | ||
574 | 604 | ||
575 | return false; | 605 | return false; |
576 | } | 606 | } |
@@ -583,52 +613,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
583 | /// in this prim's inventory.</returns> | 613 | /// in this prim's inventory.</returns> |
584 | public int RemoveInventoryItem(UUID itemID) | 614 | public int RemoveInventoryItem(UUID itemID) |
585 | { | 615 | { |
586 | lock (m_items) | 616 | m_items.LockItemsForRead(true); |
617 | |||
618 | if (m_items.ContainsKey(itemID)) | ||
587 | { | 619 | { |
588 | if (m_items.ContainsKey(itemID)) | 620 | int type = m_items[itemID].InvType; |
621 | m_items.LockItemsForRead(false); | ||
622 | if (type == 10) // Script | ||
589 | { | 623 | { |
590 | int type = m_items[itemID].InvType; | 624 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); |
591 | if (type == 10) // Script | 625 | } |
592 | { | 626 | m_items.LockItemsForWrite(true); |
593 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 627 | m_items.Remove(itemID); |
594 | } | 628 | m_items.LockItemsForWrite(false); |
595 | m_items.Remove(itemID); | 629 | m_inventorySerial++; |
596 | m_inventorySerial++; | 630 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
597 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
598 | |||
599 | HasInventoryChanged = true; | ||
600 | m_part.ParentGroup.HasGroupChanged = true; | ||
601 | 631 | ||
602 | int scriptcount = 0; | 632 | HasInventoryChanged = true; |
603 | lock (m_items) | 633 | m_part.ParentGroup.HasGroupChanged = true; |
604 | { | ||
605 | foreach (TaskInventoryItem item in m_items.Values) | ||
606 | { | ||
607 | if (item.Type == 10) | ||
608 | { | ||
609 | scriptcount++; | ||
610 | } | ||
611 | } | ||
612 | } | ||
613 | 634 | ||
614 | if (scriptcount <= 0) | 635 | int scriptcount = 0; |
636 | m_items.LockItemsForRead(true); | ||
637 | foreach (TaskInventoryItem item in m_items.Values) | ||
638 | { | ||
639 | if (item.Type == 10) | ||
615 | { | 640 | { |
616 | m_part.RemFlag(PrimFlags.Scripted); | 641 | scriptcount++; |
617 | } | 642 | } |
618 | |||
619 | m_part.ScheduleFullUpdate(); | ||
620 | |||
621 | return type; | ||
622 | } | 643 | } |
623 | else | 644 | m_items.LockItemsForRead(false); |
645 | |||
646 | |||
647 | if (scriptcount <= 0) | ||
624 | { | 648 | { |
625 | m_log.ErrorFormat( | 649 | m_part.RemFlag(PrimFlags.Scripted); |
626 | "[PRIM INVENTORY]: " + | ||
627 | "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | ||
628 | itemID, m_part.Name, m_part.UUID, | ||
629 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
630 | } | 650 | } |
651 | |||
652 | m_part.ScheduleFullUpdate(); | ||
653 | |||
654 | return type; | ||
655 | } | ||
656 | else | ||
657 | { | ||
658 | m_log.ErrorFormat( | ||
659 | "[PRIM INVENTORY]: " + | ||
660 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | ||
661 | itemID, m_part.Name, m_part.UUID); | ||
631 | } | 662 | } |
663 | m_items.LockItemsForWrite(false); | ||
632 | 664 | ||
633 | return -1; | 665 | return -1; |
634 | } | 666 | } |
@@ -681,52 +713,53 @@ namespace OpenSim.Region.Framework.Scenes | |||
681 | // isn't available (such as drag from prim inventory to agent inventory) | 713 | // isn't available (such as drag from prim inventory to agent inventory) |
682 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | 714 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); |
683 | 715 | ||
684 | lock (m_items) | 716 | m_items.LockItemsForRead(true); |
717 | |||
718 | foreach (TaskInventoryItem item in m_items.Values) | ||
685 | { | 719 | { |
686 | foreach (TaskInventoryItem item in m_items.Values) | 720 | UUID ownerID = item.OwnerID; |
687 | { | 721 | uint everyoneMask = 0; |
688 | UUID ownerID = item.OwnerID; | 722 | uint baseMask = item.BasePermissions; |
689 | uint everyoneMask = 0; | 723 | uint ownerMask = item.CurrentPermissions; |
690 | uint baseMask = item.BasePermissions; | ||
691 | uint ownerMask = item.CurrentPermissions; | ||
692 | 724 | ||
693 | invString.AddItemStart(); | 725 | invString.AddItemStart(); |
694 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | 726 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); |
695 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | 727 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); |
696 | 728 | ||
697 | invString.AddPermissionsStart(); | 729 | invString.AddPermissionsStart(); |
698 | 730 | ||
699 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | 731 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); |
700 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | 732 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); |
701 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); | 733 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); |
702 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | 734 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); |
703 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | 735 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); |
704 | 736 | ||
705 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | 737 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); |
706 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | 738 | invString.AddNameValueLine("owner_id", ownerID.ToString()); |
707 | 739 | ||
708 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | 740 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); |
709 | 741 | ||
710 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | 742 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); |
711 | invString.AddSectionEnd(); | 743 | invString.AddSectionEnd(); |
712 | 744 | ||
713 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | 745 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); |
714 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); | 746 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); |
715 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); | 747 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); |
716 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | 748 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); |
717 | 749 | ||
718 | invString.AddSaleStart(); | 750 | invString.AddSaleStart(); |
719 | invString.AddNameValueLine("sale_type", "not"); | 751 | invString.AddNameValueLine("sale_type", "not"); |
720 | invString.AddNameValueLine("sale_price", "0"); | 752 | invString.AddNameValueLine("sale_price", "0"); |
721 | invString.AddSectionEnd(); | 753 | invString.AddSectionEnd(); |
722 | 754 | ||
723 | invString.AddNameValueLine("name", item.Name + "|"); | 755 | invString.AddNameValueLine("name", item.Name + "|"); |
724 | invString.AddNameValueLine("desc", item.Description + "|"); | 756 | invString.AddNameValueLine("desc", item.Description + "|"); |
725 | 757 | ||
726 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | 758 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); |
727 | invString.AddSectionEnd(); | 759 | invString.AddSectionEnd(); |
728 | } | ||
729 | } | 760 | } |
761 | int count = m_items.Count; | ||
762 | m_items.LockItemsForRead(false); | ||
730 | 763 | ||
731 | fileData = Utils.StringToBytes(invString.BuildString); | 764 | fileData = Utils.StringToBytes(invString.BuildString); |
732 | 765 | ||
@@ -747,10 +780,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
747 | { | 780 | { |
748 | if (HasInventoryChanged) | 781 | if (HasInventoryChanged) |
749 | { | 782 | { |
750 | lock (Items) | 783 | Items.LockItemsForRead(true); |
751 | { | 784 | datastore.StorePrimInventory(m_part.UUID, Items.Values); |
752 | datastore.StorePrimInventory(m_part.UUID, Items.Values); | 785 | Items.LockItemsForRead(false); |
753 | } | ||
754 | 786 | ||
755 | HasInventoryChanged = false; | 787 | HasInventoryChanged = false; |
756 | } | 788 | } |