diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 592 |
1 files changed, 288 insertions, 304 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 04e3221..013285f 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 | } |
@@ -235,16 +240,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
235 | /// </param> | 240 | /// </param> |
236 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | 241 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) |
237 | { | 242 | { |
238 | lock (Items) | 243 | Items.LockItemsForRead(true); |
244 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
245 | Items.LockItemsForRead(false); | ||
246 | |||
247 | foreach (TaskInventoryItem item in items) | ||
239 | { | 248 | { |
240 | foreach (TaskInventoryItem item in Items.Values) | 249 | if ((int)InventoryType.LSL == item.InvType) |
241 | { | 250 | { |
242 | if ((int)InventoryType.LSL == item.InvType) | 251 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); |
243 | { | 252 | m_part.RemoveScriptEvents(item.ItemID); |
244 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); | ||
245 | } | ||
246 | } | 253 | } |
247 | } | 254 | } |
255 | |||
256 | |||
248 | } | 257 | } |
249 | 258 | ||
250 | /// <summary> | 259 | /// <summary> |
@@ -269,12 +278,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
269 | if (stateSource == 1 && // Prim crossing | 278 | if (stateSource == 1 && // Prim crossing |
270 | m_part.ParentGroup.Scene.m_trustBinaries) | 279 | m_part.ParentGroup.Scene.m_trustBinaries) |
271 | { | 280 | { |
272 | lock (m_items) | 281 | m_items.LockItemsForWrite(true); |
273 | { | 282 | m_items[item.ItemID].PermsMask = 0; |
274 | m_items[item.ItemID].PermsMask = 0; | 283 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
275 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 284 | m_items.LockItemsForWrite(false); |
276 | } | ||
277 | |||
278 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 285 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
279 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 286 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
280 | m_part.ParentGroup.AddActiveScriptCount(1); | 287 | m_part.ParentGroup.AddActiveScriptCount(1); |
@@ -282,36 +289,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
282 | return; | 289 | return; |
283 | } | 290 | } |
284 | 291 | ||
285 | m_part.ParentGroup.Scene.AssetService.Get( | 292 | m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString(), this, delegate(string id, object sender, AssetBase asset) |
286 | item.AssetID.ToString(), this, delegate(string id, object sender, AssetBase asset) | 293 | { |
287 | { | 294 | if (null == asset) |
288 | if (null == asset) | 295 | { |
289 | { | 296 | m_log.ErrorFormat( |
290 | m_log.ErrorFormat( | 297 | "[PRIM INVENTORY]: " + |
291 | "[PRIM INVENTORY]: " + | 298 | "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", |
292 | "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", | 299 | item.Name, item.ItemID, m_part.AbsolutePosition, |
293 | item.Name, item.ItemID, m_part.AbsolutePosition, | 300 | m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); |
294 | m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); | 301 | } |
295 | } | 302 | else |
296 | else | 303 | { |
297 | { | 304 | if (m_part.ParentGroup.m_savedScriptState != null) |
298 | if (m_part.ParentGroup.m_savedScriptState != null) | 305 | RestoreSavedScriptState(item.OldItemID, item.ItemID); |
299 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 306 | m_items.LockItemsForWrite(true); |
300 | 307 | m_items[item.ItemID].PermsMask = 0; | |
301 | lock (m_items) | 308 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
302 | { | 309 | m_items.LockItemsForWrite(false); |
303 | m_items[item.ItemID].PermsMask = 0; | 310 | string script = Utils.BytesToString(asset.Data); |
304 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 311 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
305 | } | 312 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
306 | 313 | m_part.ParentGroup.AddActiveScriptCount(1); | |
307 | string script = Utils.BytesToString(asset.Data); | 314 | m_part.ScheduleFullUpdate(); |
308 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 315 | } |
309 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 316 | }); |
310 | m_part.ParentGroup.AddActiveScriptCount(1); | ||
311 | m_part.ScheduleFullUpdate(); | ||
312 | } | ||
313 | } | ||
314 | ); | ||
315 | } | 317 | } |
316 | } | 318 | } |
317 | 319 | ||
@@ -378,14 +380,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
378 | /// </param> | 380 | /// </param> |
379 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | 381 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
380 | { | 382 | { |
381 | lock (m_items) | 383 | m_items.LockItemsForRead(true); |
384 | if (m_items.ContainsKey(itemId)) | ||
382 | { | 385 | { |
383 | if (m_items.ContainsKey(itemId)) | 386 | if (m_items.ContainsKey(itemId)) |
384 | { | 387 | { |
388 | m_items.LockItemsForRead(false); | ||
385 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); | 389 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); |
386 | } | 390 | } |
387 | else | 391 | else |
388 | { | 392 | { |
393 | m_items.LockItemsForRead(false); | ||
389 | m_log.ErrorFormat( | 394 | m_log.ErrorFormat( |
390 | "[PRIM INVENTORY]: " + | 395 | "[PRIM INVENTORY]: " + |
391 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", | 396 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", |
@@ -393,6 +398,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
393 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 398 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
394 | } | 399 | } |
395 | } | 400 | } |
401 | else | ||
402 | { | ||
403 | m_items.LockItemsForRead(false); | ||
404 | m_log.ErrorFormat( | ||
405 | "[PRIM INVENTORY]: " + | ||
406 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", | ||
407 | itemId, m_part.Name, m_part.UUID); | ||
408 | } | ||
409 | |||
396 | } | 410 | } |
397 | 411 | ||
398 | /// <summary> | 412 | /// <summary> |
@@ -405,15 +419,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
405 | /// </param> | 419 | /// </param> |
406 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) | 420 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) |
407 | { | 421 | { |
408 | bool scriptPresent = false; | 422 | if (m_items.ContainsKey(itemId)) |
409 | |||
410 | lock (m_items) | ||
411 | { | ||
412 | if (m_items.ContainsKey(itemId)) | ||
413 | scriptPresent = true; | ||
414 | } | ||
415 | |||
416 | if (scriptPresent) | ||
417 | { | 423 | { |
418 | if (!sceneObjectBeingDeleted) | 424 | if (!sceneObjectBeingDeleted) |
419 | m_part.RemoveScriptEvents(itemId); | 425 | m_part.RemoveScriptEvents(itemId); |
@@ -439,11 +445,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
439 | /// <returns></returns> | 445 | /// <returns></returns> |
440 | private bool InventoryContainsName(string name) | 446 | private bool InventoryContainsName(string name) |
441 | { | 447 | { |
442 | foreach (TaskInventoryItem item in Items.Values) | 448 | m_items.LockItemsForRead(true); |
449 | foreach (TaskInventoryItem item in m_items.Values) | ||
443 | { | 450 | { |
444 | if (item.Name == name) | 451 | if (item.Name == name) |
452 | { | ||
453 | m_items.LockItemsForRead(false); | ||
445 | return true; | 454 | return true; |
455 | } | ||
446 | } | 456 | } |
457 | m_items.LockItemsForRead(false); | ||
447 | return false; | 458 | return false; |
448 | } | 459 | } |
449 | 460 | ||
@@ -485,13 +496,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
485 | /// <param name="item"></param> | 496 | /// <param name="item"></param> |
486 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 497 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
487 | { | 498 | { |
488 | List<TaskInventoryItem> il; | 499 | m_items.LockItemsForRead(true); |
489 | 500 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); | |
490 | lock (m_items) | 501 | m_items.LockItemsForRead(false); |
491 | { | ||
492 | il = new List<TaskInventoryItem>(m_items.Values); | ||
493 | } | ||
494 | |||
495 | foreach (TaskInventoryItem i in il) | 502 | foreach (TaskInventoryItem i in il) |
496 | { | 503 | { |
497 | if (i.Name == item.Name) | 504 | if (i.Name == item.Name) |
@@ -528,15 +535,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
528 | item.ParentPartID = m_part.UUID; | 535 | item.ParentPartID = m_part.UUID; |
529 | item.Name = name; | 536 | item.Name = name; |
530 | 537 | ||
531 | lock (m_items) | 538 | m_items.LockItemsForWrite(true); |
532 | { | 539 | m_items.Add(item.ItemID, item); |
533 | m_items.Add(item.ItemID, item); | 540 | m_items.LockItemsForWrite(false); |
534 | |||
535 | if (allowedDrop) | 541 | if (allowedDrop) |
536 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); | 542 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); |
537 | else | 543 | else |
538 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 544 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
539 | } | 545 | |
540 | 546 | ||
541 | m_inventorySerial++; | 547 | m_inventorySerial++; |
542 | //m_inventorySerial += 2; | 548 | //m_inventorySerial += 2; |
@@ -553,14 +559,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
553 | /// <param name="items"></param> | 559 | /// <param name="items"></param> |
554 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) | 560 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) |
555 | { | 561 | { |
556 | lock (m_items) | 562 | m_items.LockItemsForWrite(true); |
563 | foreach (TaskInventoryItem item in items) | ||
557 | { | 564 | { |
558 | foreach (TaskInventoryItem item in items) | 565 | m_items.Add(item.ItemID, item); |
559 | { | 566 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
560 | m_items.Add(item.ItemID, item); | ||
561 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
562 | } | ||
563 | } | 567 | } |
568 | m_items.LockItemsForWrite(false); | ||
564 | 569 | ||
565 | m_inventorySerial++; | 570 | m_inventorySerial++; |
566 | } | 571 | } |
@@ -573,10 +578,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
573 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 578 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
574 | { | 579 | { |
575 | TaskInventoryItem item; | 580 | TaskInventoryItem item; |
576 | 581 | m_items.LockItemsForRead(true); | |
577 | lock (m_items) | 582 | m_items.TryGetValue(itemId, out item); |
578 | m_items.TryGetValue(itemId, out item); | 583 | m_items.LockItemsForRead(false); |
579 | |||
580 | return item; | 584 | return item; |
581 | } | 585 | } |
582 | 586 | ||
@@ -612,46 +616,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
612 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> | 616 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> |
613 | public bool UpdateInventoryItem(TaskInventoryItem item) | 617 | public bool UpdateInventoryItem(TaskInventoryItem item) |
614 | { | 618 | { |
615 | lock (m_items) | 619 | m_items.LockItemsForWrite(true); |
620 | |||
621 | if (m_items.ContainsKey(item.ItemID)) | ||
616 | { | 622 | { |
617 | if (m_items.ContainsKey(item.ItemID)) | 623 | item.ParentID = m_part.UUID; |
624 | item.ParentPartID = m_part.UUID; | ||
625 | item.Flags = m_items[item.ItemID].Flags; | ||
626 | if (item.AssetID == UUID.Zero) | ||
618 | { | 627 | { |
619 | item.ParentID = m_part.UUID; | 628 | item.AssetID = m_items[item.ItemID].AssetID; |
620 | item.ParentPartID = m_part.UUID; | 629 | } |
621 | item.Flags = m_items[item.ItemID].Flags; | 630 | else if ((InventoryType)item.Type == InventoryType.Notecard) |
622 | if (item.AssetID == UUID.Zero) | 631 | { |
623 | { | 632 | ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); |
624 | item.AssetID = m_items[item.ItemID].AssetID; | ||
625 | } | ||
626 | else if ((InventoryType)item.Type == InventoryType.Notecard) | ||
627 | { | ||
628 | ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); | ||
629 | 633 | ||
630 | if (presence != null) | 634 | if (presence != null) |
631 | { | 635 | { |
632 | presence.ControllingClient.SendAgentAlertMessage( | 636 | presence.ControllingClient.SendAgentAlertMessage( |
633 | "Notecard saved", false); | 637 | "Notecard saved", false); |
634 | } | ||
635 | } | 638 | } |
639 | } | ||
636 | 640 | ||
637 | m_items[item.ItemID] = item; | 641 | m_items[item.ItemID] = item; |
638 | m_inventorySerial++; | 642 | m_inventorySerial++; |
639 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 643 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
640 | |||
641 | HasInventoryChanged = true; | ||
642 | m_part.ParentGroup.HasGroupChanged = true; | ||
643 | 644 | ||
644 | return true; | 645 | HasInventoryChanged = true; |
645 | } | 646 | m_part.ParentGroup.HasGroupChanged = true; |
646 | else | 647 | m_items.LockItemsForWrite(false); |
647 | { | 648 | return true; |
648 | m_log.ErrorFormat( | 649 | } |
649 | "[PRIM INVENTORY]: " + | 650 | else |
650 | "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | 651 | { |
651 | item.ItemID, m_part.Name, m_part.UUID, | 652 | m_log.ErrorFormat( |
652 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 653 | "[PRIM INVENTORY]: " + |
653 | } | 654 | "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", |
655 | item.ItemID, m_part.Name, m_part.UUID, | ||
656 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
654 | } | 657 | } |
658 | m_items.LockItemsForWrite(false); | ||
655 | 659 | ||
656 | return false; | 660 | return false; |
657 | } | 661 | } |
@@ -664,53 +668,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
664 | /// in this prim's inventory.</returns> | 668 | /// in this prim's inventory.</returns> |
665 | public int RemoveInventoryItem(UUID itemID) | 669 | public int RemoveInventoryItem(UUID itemID) |
666 | { | 670 | { |
667 | lock (m_items) | 671 | m_items.LockItemsForRead(true); |
672 | |||
673 | if (m_items.ContainsKey(itemID)) | ||
668 | { | 674 | { |
669 | if (m_items.ContainsKey(itemID)) | 675 | int type = m_items[itemID].InvType; |
676 | m_items.LockItemsForRead(false); | ||
677 | if (type == 10) // Script | ||
670 | { | 678 | { |
671 | int type = m_items[itemID].InvType; | 679 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); |
672 | if (type == 10) // Script | 680 | } |
673 | { | 681 | m_items.LockItemsForWrite(true); |
674 | m_part.RemoveScriptEvents(itemID); | 682 | m_items.Remove(itemID); |
675 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 683 | m_items.LockItemsForWrite(false); |
676 | } | 684 | m_inventorySerial++; |
677 | m_items.Remove(itemID); | 685 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
678 | m_inventorySerial++; | ||
679 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
680 | |||
681 | HasInventoryChanged = true; | ||
682 | m_part.ParentGroup.HasGroupChanged = true; | ||
683 | 686 | ||
684 | int scriptcount = 0; | 687 | HasInventoryChanged = true; |
685 | lock (m_items) | 688 | m_part.ParentGroup.HasGroupChanged = true; |
686 | { | ||
687 | foreach (TaskInventoryItem item in m_items.Values) | ||
688 | { | ||
689 | if (item.Type == 10) | ||
690 | { | ||
691 | scriptcount++; | ||
692 | } | ||
693 | } | ||
694 | } | ||
695 | 689 | ||
696 | if (scriptcount <= 0) | 690 | int scriptcount = 0; |
691 | m_items.LockItemsForRead(true); | ||
692 | foreach (TaskInventoryItem item in m_items.Values) | ||
693 | { | ||
694 | if (item.Type == 10) | ||
697 | { | 695 | { |
698 | m_part.RemFlag(PrimFlags.Scripted); | 696 | scriptcount++; |
699 | } | 697 | } |
700 | |||
701 | m_part.ScheduleFullUpdate(); | ||
702 | |||
703 | return type; | ||
704 | } | 698 | } |
705 | else | 699 | m_items.LockItemsForRead(false); |
700 | |||
701 | |||
702 | if (scriptcount <= 0) | ||
706 | { | 703 | { |
707 | m_log.ErrorFormat( | 704 | m_part.RemFlag(PrimFlags.Scripted); |
708 | "[PRIM INVENTORY]: " + | ||
709 | "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | ||
710 | itemID, m_part.Name, m_part.UUID, | ||
711 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
712 | } | 705 | } |
706 | |||
707 | m_part.ScheduleFullUpdate(); | ||
708 | |||
709 | return type; | ||
710 | } | ||
711 | else | ||
712 | { | ||
713 | m_log.ErrorFormat( | ||
714 | "[PRIM INVENTORY]: " + | ||
715 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | ||
716 | itemID, m_part.Name, m_part.UUID); | ||
713 | } | 717 | } |
718 | m_items.LockItemsForWrite(false); | ||
714 | 719 | ||
715 | return -1; | 720 | return -1; |
716 | } | 721 | } |
@@ -763,52 +768,53 @@ namespace OpenSim.Region.Framework.Scenes | |||
763 | // isn't available (such as drag from prim inventory to agent inventory) | 768 | // isn't available (such as drag from prim inventory to agent inventory) |
764 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | 769 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); |
765 | 770 | ||
766 | lock (m_items) | 771 | m_items.LockItemsForRead(true); |
772 | |||
773 | foreach (TaskInventoryItem item in m_items.Values) | ||
767 | { | 774 | { |
768 | foreach (TaskInventoryItem item in m_items.Values) | 775 | UUID ownerID = item.OwnerID; |
769 | { | 776 | uint everyoneMask = 0; |
770 | UUID ownerID = item.OwnerID; | 777 | uint baseMask = item.BasePermissions; |
771 | uint everyoneMask = 0; | 778 | uint ownerMask = item.CurrentPermissions; |
772 | uint baseMask = item.BasePermissions; | ||
773 | uint ownerMask = item.CurrentPermissions; | ||
774 | 779 | ||
775 | invString.AddItemStart(); | 780 | invString.AddItemStart(); |
776 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | 781 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); |
777 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | 782 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); |
778 | 783 | ||
779 | invString.AddPermissionsStart(); | 784 | invString.AddPermissionsStart(); |
780 | 785 | ||
781 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | 786 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); |
782 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | 787 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); |
783 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); | 788 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); |
784 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | 789 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); |
785 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | 790 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); |
786 | 791 | ||
787 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | 792 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); |
788 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | 793 | invString.AddNameValueLine("owner_id", ownerID.ToString()); |
789 | 794 | ||
790 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | 795 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); |
791 | 796 | ||
792 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | 797 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); |
793 | invString.AddSectionEnd(); | 798 | invString.AddSectionEnd(); |
794 | 799 | ||
795 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | 800 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); |
796 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); | 801 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); |
797 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); | 802 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); |
798 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | 803 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); |
799 | 804 | ||
800 | invString.AddSaleStart(); | 805 | invString.AddSaleStart(); |
801 | invString.AddNameValueLine("sale_type", "not"); | 806 | invString.AddNameValueLine("sale_type", "not"); |
802 | invString.AddNameValueLine("sale_price", "0"); | 807 | invString.AddNameValueLine("sale_price", "0"); |
803 | invString.AddSectionEnd(); | 808 | invString.AddSectionEnd(); |
804 | 809 | ||
805 | invString.AddNameValueLine("name", item.Name + "|"); | 810 | invString.AddNameValueLine("name", item.Name + "|"); |
806 | invString.AddNameValueLine("desc", item.Description + "|"); | 811 | invString.AddNameValueLine("desc", item.Description + "|"); |
807 | 812 | ||
808 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | 813 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); |
809 | invString.AddSectionEnd(); | 814 | invString.AddSectionEnd(); |
810 | } | ||
811 | } | 815 | } |
816 | int count = m_items.Count; | ||
817 | m_items.LockItemsForRead(false); | ||
812 | 818 | ||
813 | fileData = Utils.StringToBytes(invString.BuildString); | 819 | fileData = Utils.StringToBytes(invString.BuildString); |
814 | 820 | ||
@@ -829,10 +835,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
829 | { | 835 | { |
830 | if (HasInventoryChanged) | 836 | if (HasInventoryChanged) |
831 | { | 837 | { |
832 | lock (Items) | 838 | Items.LockItemsForRead(true); |
833 | { | 839 | datastore.StorePrimInventory(m_part.UUID, Items.Values); |
834 | datastore.StorePrimInventory(m_part.UUID, Items.Values); | 840 | Items.LockItemsForRead(false); |
835 | } | ||
836 | 841 | ||
837 | HasInventoryChanged = false; | 842 | HasInventoryChanged = false; |
838 | } | 843 | } |
@@ -901,61 +906,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
901 | { | 906 | { |
902 | uint mask=0x7fffffff; | 907 | uint mask=0x7fffffff; |
903 | 908 | ||
904 | lock (m_items) | 909 | foreach (TaskInventoryItem item in m_items.Values) |
905 | { | 910 | { |
906 | foreach (TaskInventoryItem item in m_items.Values) | 911 | if (item.InvType != (int)InventoryType.Object) |
907 | { | 912 | { |
908 | if (item.InvType != (int)InventoryType.Object) | 913 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) |
909 | { | 914 | mask &= ~((uint)PermissionMask.Copy >> 13); |
910 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | 915 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) |
911 | mask &= ~((uint)PermissionMask.Copy >> 13); | 916 | mask &= ~((uint)PermissionMask.Transfer >> 13); |
912 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | 917 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) |
913 | mask &= ~((uint)PermissionMask.Transfer >> 13); | 918 | mask &= ~((uint)PermissionMask.Modify >> 13); |
914 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | 919 | } |
915 | mask &= ~((uint)PermissionMask.Modify >> 13); | 920 | else |
916 | } | 921 | { |
917 | else | 922 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
918 | { | 923 | mask &= ~((uint)PermissionMask.Copy >> 13); |
919 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | 924 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
920 | mask &= ~((uint)PermissionMask.Copy >> 13); | 925 | mask &= ~((uint)PermissionMask.Transfer >> 13); |
921 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | 926 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
922 | mask &= ~((uint)PermissionMask.Transfer >> 13); | 927 | mask &= ~((uint)PermissionMask.Modify >> 13); |
923 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
924 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
925 | } | ||
926 | |||
927 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
928 | mask &= ~(uint)PermissionMask.Copy; | ||
929 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
930 | mask &= ~(uint)PermissionMask.Transfer; | ||
931 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
932 | mask &= ~(uint)PermissionMask.Modify; | ||
933 | } | 928 | } |
929 | |||
930 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
931 | mask &= ~(uint)PermissionMask.Copy; | ||
932 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
933 | mask &= ~(uint)PermissionMask.Transfer; | ||
934 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
935 | mask &= ~(uint)PermissionMask.Modify; | ||
934 | } | 936 | } |
935 | |||
936 | return mask; | 937 | return mask; |
937 | } | 938 | } |
938 | 939 | ||
939 | public void ApplyNextOwnerPermissions() | 940 | public void ApplyNextOwnerPermissions() |
940 | { | 941 | { |
941 | lock (m_items) | 942 | foreach (TaskInventoryItem item in m_items.Values) |
942 | { | 943 | { |
943 | foreach (TaskInventoryItem item in m_items.Values) | 944 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) |
944 | { | 945 | { |
945 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) | 946 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
946 | { | 947 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; |
947 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | 948 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
948 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; | 949 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; |
949 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | 950 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
950 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | 951 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; |
951 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | 952 | item.CurrentPermissions |= 8; |
952 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; | ||
953 | item.CurrentPermissions |= 8; | ||
954 | } | ||
955 | item.CurrentPermissions &= item.NextPermissions; | ||
956 | item.BasePermissions &= item.NextPermissions; | ||
957 | item.EveryonePermissions &= item.NextPermissions; | ||
958 | } | 953 | } |
954 | item.CurrentPermissions &= item.NextPermissions; | ||
955 | item.BasePermissions &= item.NextPermissions; | ||
956 | item.EveryonePermissions &= item.NextPermissions; | ||
959 | } | 957 | } |
960 | 958 | ||
961 | m_part.TriggerScriptChangedEvent(Changed.OWNER); | 959 | m_part.TriggerScriptChangedEvent(Changed.OWNER); |
@@ -963,29 +961,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
963 | 961 | ||
964 | public void ApplyGodPermissions(uint perms) | 962 | public void ApplyGodPermissions(uint perms) |
965 | { | 963 | { |
966 | lock (m_items) | 964 | foreach (TaskInventoryItem item in m_items.Values) |
967 | { | 965 | { |
968 | foreach (TaskInventoryItem item in m_items.Values) | 966 | item.CurrentPermissions = perms; |
969 | { | 967 | item.BasePermissions = perms; |
970 | item.CurrentPermissions = perms; | ||
971 | item.BasePermissions = perms; | ||
972 | } | ||
973 | } | 968 | } |
974 | } | 969 | } |
975 | 970 | ||
976 | public bool ContainsScripts() | 971 | public bool ContainsScripts() |
977 | { | 972 | { |
978 | lock (m_items) | 973 | foreach (TaskInventoryItem item in m_items.Values) |
979 | { | 974 | { |
980 | foreach (TaskInventoryItem item in m_items.Values) | 975 | if (item.InvType == (int)InventoryType.LSL) |
981 | { | 976 | { |
982 | if (item.InvType == (int)InventoryType.LSL) | 977 | return true; |
983 | { | ||
984 | return true; | ||
985 | } | ||
986 | } | 978 | } |
987 | } | 979 | } |
988 | |||
989 | return false; | 980 | return false; |
990 | } | 981 | } |
991 | 982 | ||
@@ -993,11 +984,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
993 | { | 984 | { |
994 | List<UUID> ret = new List<UUID>(); | 985 | List<UUID> ret = new List<UUID>(); |
995 | 986 | ||
996 | lock (m_items) | 987 | foreach (TaskInventoryItem item in m_items.Values) |
997 | { | 988 | ret.Add(item.ItemID); |
998 | foreach (TaskInventoryItem item in m_items.Values) | ||
999 | ret.Add(item.ItemID); | ||
1000 | } | ||
1001 | 989 | ||
1002 | return ret; | 990 | return ret; |
1003 | } | 991 | } |
@@ -1010,30 +998,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
1010 | if (engines == null) // No engine at all | 998 | if (engines == null) // No engine at all |
1011 | return ret; | 999 | return ret; |
1012 | 1000 | ||
1013 | lock (m_items) | 1001 | foreach (TaskInventoryItem item in m_items.Values) |
1014 | { | 1002 | { |
1015 | foreach (TaskInventoryItem item in m_items.Values) | 1003 | if (item.InvType == (int)InventoryType.LSL) |
1016 | { | 1004 | { |
1017 | if (item.InvType == (int)InventoryType.LSL) | 1005 | foreach (IScriptModule e in engines) |
1018 | { | 1006 | { |
1019 | foreach (IScriptModule e in engines) | 1007 | if (e != null) |
1020 | { | 1008 | { |
1021 | if (e != null) | 1009 | string n = e.GetXMLState(item.ItemID); |
1010 | if (n != String.Empty) | ||
1022 | { | 1011 | { |
1023 | string n = e.GetXMLState(item.ItemID); | 1012 | if (!ret.ContainsKey(item.ItemID)) |
1024 | if (n != String.Empty) | 1013 | ret[item.ItemID] = n; |
1025 | { | 1014 | break; |
1026 | if (!ret.ContainsKey(item.ItemID)) | ||
1027 | ret[item.ItemID] = n; | ||
1028 | break; | ||
1029 | } | ||
1030 | } | 1015 | } |
1031 | } | 1016 | } |
1032 | } | 1017 | } |
1033 | } | 1018 | } |
1034 | } | 1019 | } |
1035 | |||
1036 | return ret; | 1020 | return ret; |
1037 | } | 1021 | } |
1038 | } | 1022 | } |
1039 | } \ No newline at end of file | 1023 | } |