diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 722 |
1 files changed, 426 insertions, 296 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 8b83b06..c4cff12 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -45,6 +45,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
45 | 45 | ||
46 | private string m_inventoryFileName = String.Empty; | 46 | private string m_inventoryFileName = String.Empty; |
47 | private int m_inventoryFileNameSerial = 0; | 47 | private int m_inventoryFileNameSerial = 0; |
48 | |||
49 | private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>(); | ||
48 | 50 | ||
49 | /// <value> | 51 | /// <value> |
50 | /// The part to which the inventory belongs. | 52 | /// The part to which the inventory belongs. |
@@ -81,7 +83,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
81 | /// </value> | 83 | /// </value> |
82 | protected internal TaskInventoryDictionary Items | 84 | protected internal TaskInventoryDictionary Items |
83 | { | 85 | { |
84 | get { return m_items; } | 86 | get { |
87 | return m_items; | ||
88 | } | ||
85 | set | 89 | set |
86 | { | 90 | { |
87 | m_items = value; | 91 | m_items = value; |
@@ -117,22 +121,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
117 | /// <param name="linkNum">Link number for the part</param> | 121 | /// <param name="linkNum">Link number for the part</param> |
118 | public void ResetInventoryIDs() | 122 | public void ResetInventoryIDs() |
119 | { | 123 | { |
120 | lock (Items) | 124 | m_items.LockItemsForWrite(true); |
125 | |||
126 | if (0 == Items.Count) | ||
121 | { | 127 | { |
122 | if (0 == Items.Count) | 128 | m_items.LockItemsForWrite(false); |
123 | return; | 129 | return; |
130 | } | ||
124 | 131 | ||
125 | HasInventoryChanged = true; | 132 | HasInventoryChanged = true; |
126 | m_part.ParentGroup.HasGroupChanged = true; | 133 | m_part.ParentGroup.HasGroupChanged = true; |
127 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 134 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
128 | Items.Clear(); | 135 | Items.Clear(); |
129 | 136 | ||
130 | foreach (TaskInventoryItem item in items) | 137 | foreach (TaskInventoryItem item in items) |
131 | { | 138 | { |
132 | item.ResetIDs(m_part.UUID); | 139 | item.ResetIDs(m_part.UUID); |
133 | Items.Add(item.ItemID, item); | 140 | Items.Add(item.ItemID, item); |
134 | } | ||
135 | } | 141 | } |
142 | m_items.LockItemsForWrite(false); | ||
136 | } | 143 | } |
137 | 144 | ||
138 | /// <summary> | 145 | /// <summary> |
@@ -141,25 +148,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
141 | /// <param name="ownerId"></param> | 148 | /// <param name="ownerId"></param> |
142 | public void ChangeInventoryOwner(UUID ownerId) | 149 | public void ChangeInventoryOwner(UUID ownerId) |
143 | { | 150 | { |
144 | lock (Items) | 151 | m_items.LockItemsForWrite(true); |
152 | if (0 == Items.Count) | ||
145 | { | 153 | { |
146 | if (0 == Items.Count) | 154 | m_items.LockItemsForWrite(false); |
147 | { | 155 | return; |
148 | return; | 156 | } |
149 | } | ||
150 | 157 | ||
151 | HasInventoryChanged = true; | 158 | HasInventoryChanged = true; |
152 | m_part.ParentGroup.HasGroupChanged = true; | 159 | m_part.ParentGroup.HasGroupChanged = true; |
153 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 160 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
154 | foreach (TaskInventoryItem item in items) | 161 | foreach (TaskInventoryItem item in items) |
162 | { | ||
163 | if (ownerId != item.OwnerID) | ||
155 | { | 164 | { |
156 | if (ownerId != item.OwnerID) | 165 | item.LastOwnerID = item.OwnerID; |
157 | { | 166 | item.OwnerID = ownerId; |
158 | item.LastOwnerID = item.OwnerID; | ||
159 | item.OwnerID = ownerId; | ||
160 | } | ||
161 | } | 167 | } |
162 | } | 168 | } |
169 | m_items.LockItemsForWrite(false); | ||
163 | } | 170 | } |
164 | 171 | ||
165 | /// <summary> | 172 | /// <summary> |
@@ -168,24 +175,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
168 | /// <param name="groupID"></param> | 175 | /// <param name="groupID"></param> |
169 | public void ChangeInventoryGroup(UUID groupID) | 176 | public void ChangeInventoryGroup(UUID groupID) |
170 | { | 177 | { |
171 | lock (Items) | 178 | m_items.LockItemsForWrite(true); |
179 | if (0 == Items.Count) | ||
172 | { | 180 | { |
173 | if (0 == Items.Count) | 181 | m_items.LockItemsForWrite(false); |
174 | { | 182 | return; |
175 | return; | 183 | } |
176 | } | ||
177 | 184 | ||
178 | HasInventoryChanged = true; | 185 | HasInventoryChanged = true; |
179 | m_part.ParentGroup.HasGroupChanged = true; | 186 | m_part.ParentGroup.HasGroupChanged = true; |
180 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 187 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
181 | foreach (TaskInventoryItem item in items) | 188 | foreach (TaskInventoryItem item in items) |
189 | { | ||
190 | if (groupID != item.GroupID) | ||
182 | { | 191 | { |
183 | if (groupID != item.GroupID) | 192 | item.GroupID = groupID; |
184 | { | ||
185 | item.GroupID = groupID; | ||
186 | } | ||
187 | } | 193 | } |
188 | } | 194 | } |
195 | m_items.LockItemsForWrite(false); | ||
189 | } | 196 | } |
190 | 197 | ||
191 | /// <summary> | 198 | /// <summary> |
@@ -193,14 +200,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
193 | /// </summary> | 200 | /// </summary> |
194 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) | 201 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
195 | { | 202 | { |
196 | lock (m_items) | 203 | Items.LockItemsForRead(true); |
204 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
205 | Items.LockItemsForRead(false); | ||
206 | foreach (TaskInventoryItem item in items) | ||
197 | { | 207 | { |
198 | foreach (TaskInventoryItem item in Items.Values) | 208 | if ((int)InventoryType.LSL == item.InvType) |
199 | { | 209 | { |
200 | if ((int)InventoryType.LSL == item.InvType) | 210 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); |
201 | { | ||
202 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | ||
203 | } | ||
204 | } | 211 | } |
205 | } | 212 | } |
206 | } | 213 | } |
@@ -235,16 +242,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
235 | /// </param> | 242 | /// </param> |
236 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | 243 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) |
237 | { | 244 | { |
238 | lock (Items) | 245 | Items.LockItemsForRead(true); |
246 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
247 | Items.LockItemsForRead(false); | ||
248 | |||
249 | foreach (TaskInventoryItem item in items) | ||
239 | { | 250 | { |
240 | foreach (TaskInventoryItem item in Items.Values) | 251 | if ((int)InventoryType.LSL == item.InvType) |
241 | { | 252 | { |
242 | if ((int)InventoryType.LSL == item.InvType) | 253 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); |
243 | { | 254 | m_part.RemoveScriptEvents(item.ItemID); |
244 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); | ||
245 | } | ||
246 | } | 255 | } |
247 | } | 256 | } |
257 | |||
258 | |||
248 | } | 259 | } |
249 | 260 | ||
250 | /// <summary> | 261 | /// <summary> |
@@ -260,7 +271,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
260 | // item.Name, item.ItemID, Name, UUID); | 271 | // item.Name, item.ItemID, Name, UUID); |
261 | 272 | ||
262 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) | 273 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) |
274 | { | ||
275 | StoreScriptError(item.ItemID, "no permission"); | ||
263 | return; | 276 | return; |
277 | } | ||
264 | 278 | ||
265 | m_part.AddFlag(PrimFlags.Scripted); | 279 | m_part.AddFlag(PrimFlags.Scripted); |
266 | 280 | ||
@@ -269,14 +283,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
269 | if (stateSource == 1 && // Prim crossing | 283 | if (stateSource == 1 && // Prim crossing |
270 | m_part.ParentGroup.Scene.m_trustBinaries) | 284 | m_part.ParentGroup.Scene.m_trustBinaries) |
271 | { | 285 | { |
272 | lock (m_items) | 286 | m_items.LockItemsForWrite(true); |
273 | { | 287 | m_items[item.ItemID].PermsMask = 0; |
274 | m_items[item.ItemID].PermsMask = 0; | 288 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
275 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 289 | m_items.LockItemsForWrite(false); |
276 | } | ||
277 | |||
278 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 290 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
279 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 291 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
292 | StoreScriptErrors(item.ItemID, null); | ||
280 | m_part.ParentGroup.AddActiveScriptCount(1); | 293 | m_part.ParentGroup.AddActiveScriptCount(1); |
281 | m_part.ScheduleFullUpdate(); | 294 | m_part.ScheduleFullUpdate(); |
282 | return; | 295 | return; |
@@ -285,6 +298,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
285 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); | 298 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); |
286 | if (null == asset) | 299 | if (null == asset) |
287 | { | 300 | { |
301 | string msg = String.Format("asset ID {0} could not be found", item.AssetID); | ||
302 | StoreScriptError(item.ItemID, msg); | ||
288 | m_log.ErrorFormat( | 303 | m_log.ErrorFormat( |
289 | "[PRIM INVENTORY]: " + | 304 | "[PRIM INVENTORY]: " + |
290 | "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", | 305 | "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", |
@@ -296,15 +311,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
296 | if (m_part.ParentGroup.m_savedScriptState != null) | 311 | if (m_part.ParentGroup.m_savedScriptState != null) |
297 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 312 | RestoreSavedScriptState(item.OldItemID, item.ItemID); |
298 | 313 | ||
299 | lock (m_items) | 314 | m_items.LockItemsForWrite(true); |
300 | { | 315 | |
301 | m_items[item.ItemID].PermsMask = 0; | 316 | m_items[item.ItemID].PermsMask = 0; |
302 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 317 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
303 | } | 318 | |
319 | m_items.LockItemsForWrite(false); | ||
304 | 320 | ||
305 | string script = Utils.BytesToString(asset.Data); | 321 | string script = Utils.BytesToString(asset.Data); |
306 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 322 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
307 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 323 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
324 | StoreScriptErrors(item.ItemID, null); | ||
308 | m_part.ParentGroup.AddActiveScriptCount(1); | 325 | m_part.ParentGroup.AddActiveScriptCount(1); |
309 | m_part.ScheduleFullUpdate(); | 326 | m_part.ScheduleFullUpdate(); |
310 | } | 327 | } |
@@ -368,27 +385,145 @@ namespace OpenSim.Region.Framework.Scenes | |||
368 | 385 | ||
369 | /// <summary> | 386 | /// <summary> |
370 | /// Start a script which is in this prim's inventory. | 387 | /// Start a script which is in this prim's inventory. |
388 | /// Some processing may occur in the background, but this routine returns asap. | ||
371 | /// </summary> | 389 | /// </summary> |
372 | /// <param name="itemId"> | 390 | /// <param name="itemId"> |
373 | /// A <see cref="UUID"/> | 391 | /// A <see cref="UUID"/> |
374 | /// </param> | 392 | /// </param> |
375 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | 393 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
376 | { | 394 | { |
377 | lock (m_items) | 395 | lock (m_scriptErrors) |
396 | { | ||
397 | // Indicate to CreateScriptInstanceInternal() we don't want it to wait for completion | ||
398 | m_scriptErrors.Remove(itemId); | ||
399 | } | ||
400 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
401 | } | ||
402 | |||
403 | private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
404 | { | ||
405 | m_items.LockItemsForRead(true); | ||
406 | if (m_items.ContainsKey(itemId)) | ||
378 | { | 407 | { |
379 | if (m_items.ContainsKey(itemId)) | 408 | if (m_items.ContainsKey(itemId)) |
380 | { | 409 | { |
410 | m_items.LockItemsForRead(false); | ||
381 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); | 411 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); |
382 | } | 412 | } |
383 | else | 413 | else |
384 | { | 414 | { |
415 | m_items.LockItemsForRead(false); | ||
416 | string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID, | ||
417 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
418 | StoreScriptError(itemId, msg); | ||
385 | m_log.ErrorFormat( | 419 | m_log.ErrorFormat( |
386 | "[PRIM INVENTORY]: " + | 420 | "[PRIM INVENTORY]: " + |
387 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", | 421 | "Couldn't start script with ID {0} since it {1}", itemId, msg); |
388 | itemId, m_part.Name, m_part.UUID, | ||
389 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
390 | } | 422 | } |
391 | } | 423 | } |
424 | else | ||
425 | { | ||
426 | m_items.LockItemsForRead(false); | ||
427 | string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID); | ||
428 | StoreScriptError(itemId, msg); | ||
429 | m_log.ErrorFormat( | ||
430 | "[PRIM INVENTORY]: " + | ||
431 | "Couldn't start script with ID {0} since it {1}", itemId, msg); | ||
432 | } | ||
433 | |||
434 | } | ||
435 | |||
436 | /// <summary> | ||
437 | /// Start a script which is in this prim's inventory and return any compilation error messages. | ||
438 | /// </summary> | ||
439 | /// <param name="itemId"> | ||
440 | /// A <see cref="UUID"/> | ||
441 | /// </param> | ||
442 | public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
443 | { | ||
444 | ArrayList errors; | ||
445 | |||
446 | // Indicate to CreateScriptInstanceInternal() we want it to | ||
447 | // post any compilation/loading error messages | ||
448 | lock (m_scriptErrors) | ||
449 | { | ||
450 | m_scriptErrors[itemId] = null; | ||
451 | } | ||
452 | |||
453 | // Perform compilation/loading | ||
454 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
455 | |||
456 | // Wait for and retrieve any errors | ||
457 | lock (m_scriptErrors) | ||
458 | { | ||
459 | while ((errors = m_scriptErrors[itemId]) == null) | ||
460 | { | ||
461 | if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000)) | ||
462 | { | ||
463 | m_log.ErrorFormat( | ||
464 | "[PRIM INVENTORY]: " + | ||
465 | "timedout waiting for script {0} errors", itemId); | ||
466 | errors = m_scriptErrors[itemId]; | ||
467 | if (errors == null) | ||
468 | { | ||
469 | errors = new ArrayList(1); | ||
470 | errors.Add("timedout waiting for errors"); | ||
471 | } | ||
472 | break; | ||
473 | } | ||
474 | } | ||
475 | m_scriptErrors.Remove(itemId); | ||
476 | } | ||
477 | return errors; | ||
478 | } | ||
479 | |||
480 | // Signal to CreateScriptInstanceEr() that compilation/loading is complete | ||
481 | private void StoreScriptErrors(UUID itemId, ArrayList errors) | ||
482 | { | ||
483 | lock (m_scriptErrors) | ||
484 | { | ||
485 | // If compilation/loading initiated via CreateScriptInstance(), | ||
486 | // it does not want the errors, so just get out | ||
487 | if (!m_scriptErrors.ContainsKey(itemId)) | ||
488 | { | ||
489 | return; | ||
490 | } | ||
491 | |||
492 | // Initiated via CreateScriptInstanceEr(), if we know what the | ||
493 | // errors are, save them and wake CreateScriptInstanceEr(). | ||
494 | if (errors != null) | ||
495 | { | ||
496 | m_scriptErrors[itemId] = errors; | ||
497 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
498 | return; | ||
499 | } | ||
500 | } | ||
501 | |||
502 | // Initiated via CreateScriptInstanceEr() but we don't know what | ||
503 | // the errors are yet, so retrieve them from the script engine. | ||
504 | // This may involve some waiting internal to GetScriptErrors(). | ||
505 | errors = GetScriptErrors(itemId); | ||
506 | |||
507 | // Get a default non-null value to indicate success. | ||
508 | if (errors == null) | ||
509 | { | ||
510 | errors = new ArrayList(); | ||
511 | } | ||
512 | |||
513 | // Post to CreateScriptInstanceEr() and wake it up | ||
514 | lock (m_scriptErrors) | ||
515 | { | ||
516 | m_scriptErrors[itemId] = errors; | ||
517 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
518 | } | ||
519 | } | ||
520 | |||
521 | // Like StoreScriptErrors(), but just posts a single string message | ||
522 | private void StoreScriptError(UUID itemId, string message) | ||
523 | { | ||
524 | ArrayList errors = new ArrayList(1); | ||
525 | errors.Add(message); | ||
526 | StoreScriptErrors(itemId, errors); | ||
392 | } | 527 | } |
393 | 528 | ||
394 | /// <summary> | 529 | /// <summary> |
@@ -401,15 +536,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
401 | /// </param> | 536 | /// </param> |
402 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) | 537 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) |
403 | { | 538 | { |
404 | bool scriptPresent = false; | 539 | if (m_items.ContainsKey(itemId)) |
405 | |||
406 | lock (m_items) | ||
407 | { | ||
408 | if (m_items.ContainsKey(itemId)) | ||
409 | scriptPresent = true; | ||
410 | } | ||
411 | |||
412 | if (scriptPresent) | ||
413 | { | 540 | { |
414 | if (!sceneObjectBeingDeleted) | 541 | if (!sceneObjectBeingDeleted) |
415 | m_part.RemoveScriptEvents(itemId); | 542 | m_part.RemoveScriptEvents(itemId); |
@@ -435,11 +562,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
435 | /// <returns></returns> | 562 | /// <returns></returns> |
436 | private bool InventoryContainsName(string name) | 563 | private bool InventoryContainsName(string name) |
437 | { | 564 | { |
438 | foreach (TaskInventoryItem item in Items.Values) | 565 | m_items.LockItemsForRead(true); |
566 | foreach (TaskInventoryItem item in m_items.Values) | ||
439 | { | 567 | { |
440 | if (item.Name == name) | 568 | if (item.Name == name) |
569 | { | ||
570 | m_items.LockItemsForRead(false); | ||
441 | return true; | 571 | return true; |
572 | } | ||
442 | } | 573 | } |
574 | m_items.LockItemsForRead(false); | ||
443 | return false; | 575 | return false; |
444 | } | 576 | } |
445 | 577 | ||
@@ -481,13 +613,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
481 | /// <param name="item"></param> | 613 | /// <param name="item"></param> |
482 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 614 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
483 | { | 615 | { |
484 | List<TaskInventoryItem> il; | 616 | m_items.LockItemsForRead(true); |
485 | 617 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); | |
486 | lock (m_items) | 618 | m_items.LockItemsForRead(false); |
487 | { | ||
488 | il = new List<TaskInventoryItem>(m_items.Values); | ||
489 | } | ||
490 | |||
491 | foreach (TaskInventoryItem i in il) | 619 | foreach (TaskInventoryItem i in il) |
492 | { | 620 | { |
493 | if (i.Name == item.Name) | 621 | if (i.Name == item.Name) |
@@ -525,15 +653,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
525 | item.Name = name; | 653 | item.Name = name; |
526 | item.GroupID = m_part.GroupID; | 654 | item.GroupID = m_part.GroupID; |
527 | 655 | ||
528 | lock (m_items) | 656 | m_items.LockItemsForWrite(true); |
529 | { | 657 | m_items.Add(item.ItemID, item); |
530 | m_items.Add(item.ItemID, item); | 658 | m_items.LockItemsForWrite(false); |
531 | |||
532 | if (allowedDrop) | 659 | if (allowedDrop) |
533 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); | 660 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); |
534 | else | 661 | else |
535 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 662 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
536 | } | 663 | |
537 | 664 | ||
538 | m_inventorySerial++; | 665 | m_inventorySerial++; |
539 | //m_inventorySerial += 2; | 666 | //m_inventorySerial += 2; |
@@ -550,14 +677,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
550 | /// <param name="items"></param> | 677 | /// <param name="items"></param> |
551 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) | 678 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) |
552 | { | 679 | { |
553 | lock (m_items) | 680 | m_items.LockItemsForWrite(true); |
681 | foreach (TaskInventoryItem item in items) | ||
554 | { | 682 | { |
555 | foreach (TaskInventoryItem item in items) | 683 | m_items.Add(item.ItemID, item); |
556 | { | 684 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
557 | m_items.Add(item.ItemID, item); | ||
558 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
559 | } | ||
560 | } | 685 | } |
686 | m_items.LockItemsForWrite(false); | ||
561 | 687 | ||
562 | m_inventorySerial++; | 688 | m_inventorySerial++; |
563 | } | 689 | } |
@@ -570,10 +696,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
570 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 696 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
571 | { | 697 | { |
572 | TaskInventoryItem item; | 698 | TaskInventoryItem item; |
573 | 699 | m_items.LockItemsForRead(true); | |
574 | lock (m_items) | 700 | m_items.TryGetValue(itemId, out item); |
575 | m_items.TryGetValue(itemId, out item); | 701 | m_items.LockItemsForRead(false); |
576 | |||
577 | return item; | 702 | return item; |
578 | } | 703 | } |
579 | 704 | ||
@@ -589,15 +714,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
589 | { | 714 | { |
590 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); | 715 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); |
591 | 716 | ||
592 | lock (m_items) | 717 | m_items.LockItemsForRead(true); |
718 | |||
719 | foreach (TaskInventoryItem item in m_items.Values) | ||
593 | { | 720 | { |
594 | foreach (TaskInventoryItem item in m_items.Values) | 721 | if (item.Name == name) |
595 | { | 722 | items.Add(item); |
596 | if (item.Name == name) | ||
597 | items.Add(item); | ||
598 | } | ||
599 | } | 723 | } |
600 | 724 | ||
725 | m_items.LockItemsForRead(false); | ||
726 | |||
601 | return items; | 727 | return items; |
602 | } | 728 | } |
603 | 729 | ||
@@ -614,45 +740,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
614 | 740 | ||
615 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents) | 741 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents) |
616 | { | 742 | { |
617 | lock(m_items) | 743 | m_items.LockItemsForWrite(true); |
744 | |||
745 | if (m_items.ContainsKey(item.ItemID)) | ||
618 | { | 746 | { |
619 | if (m_items.ContainsKey(item.ItemID)) | 747 | item.ParentID = m_part.UUID; |
748 | item.ParentPartID = m_part.UUID; | ||
749 | item.Flags = m_items[item.ItemID].Flags; | ||
750 | |||
751 | // If group permissions have been set on, check that the groupID is up to date in case it has | ||
752 | // changed since permissions were last set. | ||
753 | if (item.GroupPermissions != (uint)PermissionMask.None) | ||
754 | item.GroupID = m_part.GroupID; | ||
755 | |||
756 | if (item.AssetID == UUID.Zero) | ||
620 | { | 757 | { |
621 | if (m_items.ContainsKey(item.ItemID)) | 758 | item.AssetID = m_items[item.ItemID].AssetID; |
622 | { | 759 | } |
623 | item.ParentID = m_part.UUID; | 760 | else if ((InventoryType)item.Type == InventoryType.Notecard) |
624 | item.ParentPartID = m_part.UUID; | 761 | { |
625 | item.Flags = m_items[item.ItemID].Flags; | 762 | ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); |
626 | 763 | ||
627 | // If group permissions have been set on, check that the groupID is up to date in case it has | 764 | if (presence != null) |
628 | // changed since permissions were last set. | ||
629 | if (item.GroupPermissions != (uint)PermissionMask.None) | ||
630 | item.GroupID = m_part.GroupID; | ||
631 | |||
632 | if (item.AssetID == UUID.Zero) | ||
633 | { | ||
634 | item.AssetID = m_items[item.ItemID].AssetID; | ||
635 | } | ||
636 | m_items[item.ItemID] = item; | ||
637 | m_inventorySerial++; | ||
638 | if (fireScriptEvents) | ||
639 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
640 | HasInventoryChanged = true; | ||
641 | m_part.ParentGroup.HasGroupChanged = true; | ||
642 | return true; | ||
643 | } | ||
644 | else | ||
645 | { | 765 | { |
646 | m_log.ErrorFormat( | 766 | presence.ControllingClient.SendAgentAlertMessage( |
647 | "[PRIM INVENTORY]: " + | 767 | "Notecard saved", false); |
648 | "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | ||
649 | item.ItemID, m_part.Name, m_part.UUID, | ||
650 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
651 | } | 768 | } |
652 | |||
653 | } | 769 | } |
654 | return false; | 770 | |
771 | m_items[item.ItemID] = item; | ||
772 | m_inventorySerial++; | ||
773 | if (fireScriptEvents) | ||
774 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
775 | HasInventoryChanged = true; | ||
776 | m_part.ParentGroup.HasGroupChanged = true; | ||
777 | m_items.LockItemsForWrite(false); | ||
778 | return true; | ||
655 | } | 779 | } |
780 | else | ||
781 | { | ||
782 | m_log.ErrorFormat( | ||
783 | "[PRIM INVENTORY]: " + | ||
784 | "Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | ||
785 | item.ItemID, m_part.Name, m_part.UUID, | ||
786 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
787 | } | ||
788 | m_items.LockItemsForWrite(false); | ||
789 | |||
790 | return false; | ||
656 | } | 791 | } |
657 | 792 | ||
658 | /// <summary> | 793 | /// <summary> |
@@ -663,52 +798,53 @@ namespace OpenSim.Region.Framework.Scenes | |||
663 | /// in this prim's inventory.</returns> | 798 | /// in this prim's inventory.</returns> |
664 | public int RemoveInventoryItem(UUID itemID) | 799 | public int RemoveInventoryItem(UUID itemID) |
665 | { | 800 | { |
666 | lock (m_items) | 801 | m_items.LockItemsForRead(true); |
802 | |||
803 | if (m_items.ContainsKey(itemID)) | ||
667 | { | 804 | { |
668 | if (m_items.ContainsKey(itemID)) | 805 | int type = m_items[itemID].InvType; |
806 | m_items.LockItemsForRead(false); | ||
807 | if (type == 10) // Script | ||
669 | { | 808 | { |
670 | int type = m_items[itemID].InvType; | 809 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); |
671 | if (type == 10) // Script | 810 | } |
672 | { | 811 | m_items.LockItemsForWrite(true); |
673 | m_part.RemoveScriptEvents(itemID); | 812 | m_items.Remove(itemID); |
674 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 813 | m_items.LockItemsForWrite(false); |
675 | } | 814 | m_inventorySerial++; |
676 | m_items.Remove(itemID); | 815 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
677 | m_inventorySerial++; | ||
678 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
679 | |||
680 | HasInventoryChanged = true; | ||
681 | m_part.ParentGroup.HasGroupChanged = true; | ||
682 | 816 | ||
683 | int scriptcount = 0; | 817 | HasInventoryChanged = true; |
684 | lock (m_items) | 818 | m_part.ParentGroup.HasGroupChanged = true; |
685 | { | ||
686 | foreach (TaskInventoryItem item in m_items.Values) | ||
687 | { | ||
688 | if (item.Type == 10) | ||
689 | { | ||
690 | scriptcount++; | ||
691 | } | ||
692 | } | ||
693 | } | ||
694 | 819 | ||
695 | if (scriptcount <= 0) | 820 | int scriptcount = 0; |
821 | m_items.LockItemsForRead(true); | ||
822 | foreach (TaskInventoryItem item in m_items.Values) | ||
823 | { | ||
824 | if (item.Type == 10) | ||
696 | { | 825 | { |
697 | m_part.RemFlag(PrimFlags.Scripted); | 826 | scriptcount++; |
698 | } | 827 | } |
699 | |||
700 | m_part.ScheduleFullUpdate(); | ||
701 | |||
702 | return type; | ||
703 | } | 828 | } |
704 | else | 829 | m_items.LockItemsForRead(false); |
830 | |||
831 | |||
832 | if (scriptcount <= 0) | ||
705 | { | 833 | { |
706 | m_log.ErrorFormat( | 834 | m_part.RemFlag(PrimFlags.Scripted); |
707 | "[PRIM INVENTORY]: " + | ||
708 | "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | ||
709 | itemID, m_part.Name, m_part.UUID, | ||
710 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
711 | } | 835 | } |
836 | |||
837 | m_part.ScheduleFullUpdate(); | ||
838 | |||
839 | return type; | ||
840 | } | ||
841 | else | ||
842 | { | ||
843 | m_items.LockItemsForRead(false); | ||
844 | m_log.ErrorFormat( | ||
845 | "[PRIM INVENTORY]: " + | ||
846 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | ||
847 | itemID, m_part.Name, m_part.UUID); | ||
712 | } | 848 | } |
713 | 849 | ||
714 | return -1; | 850 | return -1; |
@@ -762,53 +898,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
762 | // isn't available (such as drag from prim inventory to agent inventory) | 898 | // isn't available (such as drag from prim inventory to agent inventory) |
763 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | 899 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); |
764 | 900 | ||
765 | lock (m_items) | 901 | m_items.LockItemsForRead(true); |
902 | |||
903 | foreach (TaskInventoryItem item in m_items.Values) | ||
766 | { | 904 | { |
767 | foreach (TaskInventoryItem item in m_items.Values) | 905 | UUID ownerID = item.OwnerID; |
768 | { | 906 | uint everyoneMask = 0; |
769 | UUID ownerID = item.OwnerID; | 907 | uint baseMask = item.BasePermissions; |
770 | uint everyoneMask = 0; | 908 | uint ownerMask = item.CurrentPermissions; |
771 | uint baseMask = item.BasePermissions; | 909 | uint groupMask = item.GroupPermissions; |
772 | uint ownerMask = item.CurrentPermissions; | ||
773 | uint groupMask = item.GroupPermissions; | ||
774 | 910 | ||
775 | invString.AddItemStart(); | 911 | invString.AddItemStart(); |
776 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | 912 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); |
777 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | 913 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); |
778 | 914 | ||
779 | invString.AddPermissionsStart(); | 915 | invString.AddPermissionsStart(); |
780 | 916 | ||
781 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | 917 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); |
782 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | 918 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); |
783 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); | 919 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); |
784 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | 920 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); |
785 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | 921 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); |
786 | 922 | ||
787 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | 923 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); |
788 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | 924 | invString.AddNameValueLine("owner_id", ownerID.ToString()); |
789 | 925 | ||
790 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | 926 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); |
791 | 927 | ||
792 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | 928 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); |
793 | invString.AddSectionEnd(); | 929 | invString.AddSectionEnd(); |
794 | 930 | ||
795 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | 931 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); |
796 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); | 932 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); |
797 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); | 933 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); |
798 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | 934 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); |
799 | 935 | ||
800 | invString.AddSaleStart(); | 936 | invString.AddSaleStart(); |
801 | invString.AddNameValueLine("sale_type", "not"); | 937 | invString.AddNameValueLine("sale_type", "not"); |
802 | invString.AddNameValueLine("sale_price", "0"); | 938 | invString.AddNameValueLine("sale_price", "0"); |
803 | invString.AddSectionEnd(); | 939 | invString.AddSectionEnd(); |
804 | 940 | ||
805 | invString.AddNameValueLine("name", item.Name + "|"); | 941 | invString.AddNameValueLine("name", item.Name + "|"); |
806 | invString.AddNameValueLine("desc", item.Description + "|"); | 942 | invString.AddNameValueLine("desc", item.Description + "|"); |
807 | 943 | ||
808 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | 944 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); |
809 | invString.AddSectionEnd(); | 945 | invString.AddSectionEnd(); |
810 | } | ||
811 | } | 946 | } |
947 | int count = m_items.Count; | ||
948 | m_items.LockItemsForRead(false); | ||
812 | 949 | ||
813 | fileData = Utils.StringToBytes(invString.BuildString); | 950 | fileData = Utils.StringToBytes(invString.BuildString); |
814 | 951 | ||
@@ -829,10 +966,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
829 | { | 966 | { |
830 | if (HasInventoryChanged) | 967 | if (HasInventoryChanged) |
831 | { | 968 | { |
832 | lock (Items) | 969 | Items.LockItemsForRead(true); |
833 | { | 970 | datastore.StorePrimInventory(m_part.UUID, Items.Values); |
834 | datastore.StorePrimInventory(m_part.UUID, Items.Values); | 971 | Items.LockItemsForRead(false); |
835 | } | ||
836 | 972 | ||
837 | HasInventoryChanged = false; | 973 | HasInventoryChanged = false; |
838 | } | 974 | } |
@@ -901,90 +1037,76 @@ namespace OpenSim.Region.Framework.Scenes | |||
901 | { | 1037 | { |
902 | uint mask=0x7fffffff; | 1038 | uint mask=0x7fffffff; |
903 | 1039 | ||
904 | lock (m_items) | 1040 | foreach (TaskInventoryItem item in m_items.Values) |
905 | { | 1041 | { |
906 | foreach (TaskInventoryItem item in m_items.Values) | 1042 | if (item.InvType != (int)InventoryType.Object) |
907 | { | 1043 | { |
908 | if (item.InvType != (int)InventoryType.Object) | 1044 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) |
909 | { | 1045 | mask &= ~((uint)PermissionMask.Copy >> 13); |
910 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | 1046 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) |
911 | mask &= ~((uint)PermissionMask.Copy >> 13); | 1047 | mask &= ~((uint)PermissionMask.Transfer >> 13); |
912 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | 1048 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) |
913 | mask &= ~((uint)PermissionMask.Transfer >> 13); | 1049 | mask &= ~((uint)PermissionMask.Modify >> 13); |
914 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | 1050 | } |
915 | mask &= ~((uint)PermissionMask.Modify >> 13); | 1051 | else |
916 | } | 1052 | { |
917 | else | 1053 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
918 | { | 1054 | mask &= ~((uint)PermissionMask.Copy >> 13); |
919 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | 1055 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
920 | mask &= ~((uint)PermissionMask.Copy >> 13); | 1056 | mask &= ~((uint)PermissionMask.Transfer >> 13); |
921 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | 1057 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
922 | mask &= ~((uint)PermissionMask.Transfer >> 13); | 1058 | 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 | } | 1059 | } |
1060 | |||
1061 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1062 | mask &= ~(uint)PermissionMask.Copy; | ||
1063 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1064 | mask &= ~(uint)PermissionMask.Transfer; | ||
1065 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1066 | mask &= ~(uint)PermissionMask.Modify; | ||
934 | } | 1067 | } |
935 | |||
936 | return mask; | 1068 | return mask; |
937 | } | 1069 | } |
938 | 1070 | ||
939 | public void ApplyNextOwnerPermissions() | 1071 | public void ApplyNextOwnerPermissions() |
940 | { | 1072 | { |
941 | lock (m_items) | 1073 | foreach (TaskInventoryItem item in m_items.Values) |
942 | { | 1074 | { |
943 | foreach (TaskInventoryItem item in m_items.Values) | 1075 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) |
944 | { | 1076 | { |
945 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) | 1077 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
946 | { | 1078 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; |
947 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | 1079 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
948 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; | 1080 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; |
949 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | 1081 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
950 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | 1082 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; |
951 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | 1083 | 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 | item.OwnerChanged = true; | ||
959 | } | 1084 | } |
1085 | item.OwnerChanged = true; | ||
1086 | item.CurrentPermissions &= item.NextPermissions; | ||
1087 | item.BasePermissions &= item.NextPermissions; | ||
1088 | item.EveryonePermissions &= item.NextPermissions; | ||
960 | } | 1089 | } |
961 | } | 1090 | } |
962 | 1091 | ||
963 | public void ApplyGodPermissions(uint perms) | 1092 | public void ApplyGodPermissions(uint perms) |
964 | { | 1093 | { |
965 | lock (m_items) | 1094 | foreach (TaskInventoryItem item in m_items.Values) |
966 | { | 1095 | { |
967 | foreach (TaskInventoryItem item in m_items.Values) | 1096 | item.CurrentPermissions = perms; |
968 | { | 1097 | item.BasePermissions = perms; |
969 | item.CurrentPermissions = perms; | ||
970 | item.BasePermissions = perms; | ||
971 | } | ||
972 | } | 1098 | } |
973 | } | 1099 | } |
974 | 1100 | ||
975 | public bool ContainsScripts() | 1101 | public bool ContainsScripts() |
976 | { | 1102 | { |
977 | lock (m_items) | 1103 | foreach (TaskInventoryItem item in m_items.Values) |
978 | { | 1104 | { |
979 | foreach (TaskInventoryItem item in m_items.Values) | 1105 | if (item.InvType == (int)InventoryType.LSL) |
980 | { | 1106 | { |
981 | if (item.InvType == (int)InventoryType.LSL) | 1107 | return true; |
982 | { | ||
983 | return true; | ||
984 | } | ||
985 | } | 1108 | } |
986 | } | 1109 | } |
987 | |||
988 | return false; | 1110 | return false; |
989 | } | 1111 | } |
990 | 1112 | ||
@@ -992,46 +1114,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
992 | { | 1114 | { |
993 | List<UUID> ret = new List<UUID>(); | 1115 | List<UUID> ret = new List<UUID>(); |
994 | 1116 | ||
995 | lock (m_items) | 1117 | foreach (TaskInventoryItem item in m_items.Values) |
996 | { | 1118 | ret.Add(item.ItemID); |
997 | foreach (TaskInventoryItem item in m_items.Values) | ||
998 | ret.Add(item.ItemID); | ||
999 | } | ||
1000 | 1119 | ||
1001 | return ret; | 1120 | return ret; |
1002 | } | 1121 | } |
1003 | 1122 | ||
1004 | public Dictionary<UUID, string> GetScriptStates() | 1123 | public Dictionary<UUID, string> GetScriptStates() |
1005 | { | 1124 | { |
1125 | return GetScriptStates(false); | ||
1126 | } | ||
1127 | |||
1128 | public Dictionary<UUID, string> GetScriptStates(bool oldIDs) | ||
1129 | { | ||
1006 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 1130 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
1007 | 1131 | ||
1008 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | 1132 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); |
1009 | if (engines == null) // No engine at all | 1133 | if (engines == null) // No engine at all |
1010 | return ret; | 1134 | return ret; |
1011 | 1135 | ||
1012 | lock (m_items) | 1136 | foreach (TaskInventoryItem item in m_items.Values) |
1013 | { | 1137 | { |
1014 | foreach (TaskInventoryItem item in m_items.Values) | 1138 | if (item.InvType == (int)InventoryType.LSL) |
1015 | { | 1139 | { |
1016 | if (item.InvType == (int)InventoryType.LSL) | 1140 | foreach (IScriptModule e in engines) |
1017 | { | 1141 | { |
1018 | foreach (IScriptModule e in engines) | 1142 | if (e != null) |
1019 | { | 1143 | { |
1020 | if (e != null) | 1144 | string n = e.GetXMLState(item.ItemID); |
1145 | if (n != String.Empty) | ||
1021 | { | 1146 | { |
1022 | string n = e.GetXMLState(item.ItemID); | 1147 | if (oldIDs) |
1023 | if (n != String.Empty) | 1148 | { |
1149 | if (!ret.ContainsKey(item.OldItemID)) | ||
1150 | ret[item.OldItemID] = n; | ||
1151 | } | ||
1152 | else | ||
1024 | { | 1153 | { |
1025 | if (!ret.ContainsKey(item.ItemID)) | 1154 | if (!ret.ContainsKey(item.ItemID)) |
1026 | ret[item.ItemID] = n; | 1155 | ret[item.ItemID] = n; |
1027 | break; | ||
1028 | } | 1156 | } |
1157 | break; | ||
1029 | } | 1158 | } |
1030 | } | 1159 | } |
1031 | } | 1160 | } |
1032 | } | 1161 | } |
1033 | } | 1162 | } |
1034 | |||
1035 | return ret; | 1163 | return ret; |
1036 | } | 1164 | } |
1037 | 1165 | ||
@@ -1041,25 +1169,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
1041 | if (engines == null) | 1169 | if (engines == null) |
1042 | return; | 1170 | return; |
1043 | 1171 | ||
1044 | lock (m_items) | 1172 | |
1173 | Items.LockItemsForRead(true); | ||
1174 | |||
1175 | foreach (TaskInventoryItem item in m_items.Values) | ||
1045 | { | 1176 | { |
1046 | foreach (TaskInventoryItem item in m_items.Values) | 1177 | if (item.InvType == (int)InventoryType.LSL) |
1047 | { | 1178 | { |
1048 | if (item.InvType == (int)InventoryType.LSL) | 1179 | foreach (IScriptModule engine in engines) |
1049 | { | 1180 | { |
1050 | foreach (IScriptModule engine in engines) | 1181 | if (engine != null) |
1051 | { | 1182 | { |
1052 | if (engine != null) | 1183 | if (item.OwnerChanged) |
1053 | { | 1184 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); |
1054 | if (item.OwnerChanged) | 1185 | item.OwnerChanged = false; |
1055 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); | 1186 | engine.ResumeScript(item.ItemID); |
1056 | item.OwnerChanged = false; | ||
1057 | engine.ResumeScript(item.ItemID); | ||
1058 | } | ||
1059 | } | 1187 | } |
1060 | } | 1188 | } |
1061 | } | 1189 | } |
1062 | } | 1190 | } |
1191 | |||
1192 | Items.LockItemsForRead(false); | ||
1063 | } | 1193 | } |
1064 | } | 1194 | } |
1065 | } | 1195 | } |