aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs367
1 files changed, 239 insertions, 128 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 959046a..1c9a17e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -176,16 +176,14 @@ namespace OpenSim.Region.Framework.Scenes
176 /// <param name="ownerId"></param> 176 /// <param name="ownerId"></param>
177 public void ChangeInventoryOwner(UUID ownerId) 177 public void ChangeInventoryOwner(UUID ownerId)
178 { 178 {
179 m_items.LockItemsForWrite(true); 179 List<TaskInventoryItem> items = GetInventoryItems();
180 if (0 == Items.Count) 180
181 { 181 if (items.Count == 0)
182 m_items.LockItemsForWrite(false);
183 return; 182 return;
184 }
185 183
184 m_items.LockItemsForWrite(true);
186 HasInventoryChanged = true; 185 HasInventoryChanged = true;
187 m_part.ParentGroup.HasGroupChanged = true; 186 m_part.ParentGroup.HasGroupChanged = true;
188 List<TaskInventoryItem> items = GetInventoryItems();
189 foreach (TaskInventoryItem item in items) 187 foreach (TaskInventoryItem item in items)
190 { 188 {
191 if (ownerId != item.OwnerID) 189 if (ownerId != item.OwnerID)
@@ -234,7 +232,7 @@ namespace OpenSim.Region.Framework.Scenes
234 232
235 private void QueryScriptStates() 233 private void QueryScriptStates()
236 { 234 {
237 if (m_part == null || m_part.ParentGroup == null) 235 if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null)
238 return; 236 return;
239 237
240 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); 238 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
@@ -262,19 +260,16 @@ namespace OpenSim.Region.Framework.Scenes
262 Items.LockItemsForRead(false); 260 Items.LockItemsForRead(false);
263 } 261 }
264 262
265 /// <summary> 263 public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
266 /// Start all the scripts contained in this prim's inventory
267 /// </summary>
268 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
269 { 264 {
270 Items.LockItemsForRead(true); 265 int scriptsValidForStarting = 0;
271 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 266
272 Items.LockItemsForRead(false); 267 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
273 foreach (TaskInventoryItem item in items) 268 foreach (TaskInventoryItem item in scripts)
274 { 269 if (CreateScriptInstance(item, startParam, postOnRez, engine, stateSource))
275 if ((int)InventoryType.LSL == item.InvType) 270 scriptsValidForStarting++;
276 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); 271
277 } 272 return scriptsValidForStarting;
278 } 273 }
279 274
280 public ArrayList GetScriptErrors(UUID itemID) 275 public ArrayList GetScriptErrors(UUID itemID)
@@ -297,7 +292,7 @@ namespace OpenSim.Region.Framework.Scenes
297 } 292 }
298 293
299 /// <summary> 294 /// <summary>
300 /// Stop all the scripts in this prim. 295 /// Stop and remove all the scripts in this prim.
301 /// </summary> 296 /// </summary>
302 /// <param name="sceneObjectBeingDeleted"> 297 /// <param name="sceneObjectBeingDeleted">
303 /// Should be true if these scripts are being removed because the scene 298 /// Should be true if these scripts are being removed because the scene
@@ -305,26 +300,28 @@ namespace OpenSim.Region.Framework.Scenes
305 /// </param> 300 /// </param>
306 public void RemoveScriptInstances(bool sceneObjectBeingDeleted) 301 public void RemoveScriptInstances(bool sceneObjectBeingDeleted)
307 { 302 {
308 Items.LockItemsForRead(true); 303 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
309 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 304 foreach (TaskInventoryItem item in scripts)
310 Items.LockItemsForRead(false);
311
312 foreach (TaskInventoryItem item in items)
313 { 305 {
314 if ((int)InventoryType.LSL == item.InvType) 306 RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
315 { 307 m_part.RemoveScriptEvents(item.ItemID);
316 RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
317 m_part.RemoveScriptEvents(item.ItemID);
318 }
319 } 308 }
320 } 309 }
321 310
322 /// <summary> 311 /// <summary>
312 /// Stop all the scripts in this prim.
313 /// </summary>
314 public void StopScriptInstances()
315 {
316 GetInventoryItems(InventoryType.LSL).ForEach(i => StopScriptInstance(i));
317 }
318
319 /// <summary>
323 /// Start a script which is in this prim's inventory. 320 /// Start a script which is in this prim's inventory.
324 /// </summary> 321 /// </summary>
325 /// <param name="item"></param> 322 /// <param name="item"></param>
326 /// <returns></returns> 323 /// <returns>true if the script instance was created, false otherwise</returns>
327 public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource) 324 public bool CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource)
328 { 325 {
329// m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}", 326// m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}",
330// item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); 327// item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName);
@@ -332,61 +329,70 @@ namespace OpenSim.Region.Framework.Scenes
332 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) 329 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
333 { 330 {
334 StoreScriptError(item.ItemID, "no permission"); 331 StoreScriptError(item.ItemID, "no permission");
335 return; 332 return false;
336 } 333 }
337 334
338 m_part.AddFlag(PrimFlags.Scripted); 335 m_part.AddFlag(PrimFlags.Scripted);
339 336
340 if (!m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts) 337 if (m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts)
338 return false;
339
340 if (stateSource == 2 && // Prim crossing
341 m_part.ParentGroup.Scene.m_trustBinaries)
341 { 342 {
342 if (stateSource == 2 && // Prim crossing 343 m_items.LockItemsForWrite(true);
343 m_part.ParentGroup.Scene.m_trustBinaries) 344 m_items[item.ItemID].PermsMask = 0;
344 { 345 m_items[item.ItemID].PermsGranter = UUID.Zero;
345 m_items.LockItemsForWrite(true); 346 m_items.LockItemsForWrite(false);
346 m_items[item.ItemID].PermsMask = 0; 347 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
347 m_items[item.ItemID].PermsGranter = UUID.Zero; 348 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
348 m_items.LockItemsForWrite(false); 349 StoreScriptErrors(item.ItemID, null);
349 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 350 m_part.ParentGroup.AddActiveScriptCount(1);
350 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); 351 m_part.ScheduleFullUpdate();
351 StoreScriptErrors(item.ItemID, null); 352 return true;
352 m_part.ParentGroup.AddActiveScriptCount(1); 353 }
353 m_part.ScheduleFullUpdate();
354 return;
355 }
356 354
357 AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); 355 AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());
358 if (null == asset) 356 if (null == asset)
359 { 357 {
360 string msg = String.Format("asset ID {0} could not be found", item.AssetID); 358 m_log.ErrorFormat(
361 StoreScriptError(item.ItemID, msg); 359 "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
362 m_log.ErrorFormat( 360 item.Name, item.ItemID, m_part.AbsolutePosition,
361 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
362
363 return false;
364 }
365 else
366 {
367 if (m_part.ParentGroup.m_savedScriptState != null)
368 item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID);
369
370 string msg = String.Format("asset ID {0} could not be found", item.AssetID);
371 StoreScriptError(item.ItemID, msg);
372 m_log.ErrorFormat(
363 "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", 373 "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
364 item.Name, item.ItemID, m_part.AbsolutePosition, 374 item.Name, item.ItemID, m_part.AbsolutePosition,
365 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); 375 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
366 }
367 else
368 {
369 if (m_part.ParentGroup.m_savedScriptState != null)
370 item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID);
371 376
372 m_items.LockItemsForWrite(true); 377 m_items.LockItemsForWrite(true);
373 378
374 m_items[item.ItemID].OldItemID = item.OldItemID; 379 m_items[item.ItemID].OldItemID = item.OldItemID;
375 m_items[item.ItemID].PermsMask = 0; 380 m_items[item.ItemID].PermsMask = 0;
376 m_items[item.ItemID].PermsGranter = UUID.Zero; 381 m_items[item.ItemID].PermsGranter = UUID.Zero;
377 382
378 m_items.LockItemsForWrite(false); 383 m_items.LockItemsForWrite(false);
379 384
380 string script = Utils.BytesToString(asset.Data); 385 string script = Utils.BytesToString(asset.Data);
381 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 386 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
382 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); 387 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
383 StoreScriptErrors(item.ItemID, null); 388 StoreScriptErrors(item.ItemID, null);
384 if (!item.ScriptRunning) 389 if (!item.ScriptRunning)
385 m_part.ParentGroup.Scene.EventManager.TriggerStopScript( 390 m_part.ParentGroup.Scene.EventManager.TriggerStopScript(
386 m_part.LocalId, item.ItemID); 391 m_part.LocalId, item.ItemID);
387 m_part.ParentGroup.AddActiveScriptCount(1); 392 m_part.ParentGroup.AddActiveScriptCount(1);
388 m_part.ScheduleFullUpdate(); 393 m_part.ScheduleFullUpdate();
389 } 394
395 return true;
390 } 396 }
391 } 397 }
392 398
@@ -459,7 +465,7 @@ namespace OpenSim.Region.Framework.Scenes
459 /// <param name="itemId"> 465 /// <param name="itemId">
460 /// A <see cref="UUID"/> 466 /// A <see cref="UUID"/>
461 /// </param> 467 /// </param>
462 public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) 468 public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
463 { 469 {
464 lock (m_scriptErrors) 470 lock (m_scriptErrors)
465 { 471 {
@@ -467,6 +473,7 @@ namespace OpenSim.Region.Framework.Scenes
467 m_scriptErrors.Remove(itemId); 473 m_scriptErrors.Remove(itemId);
468 } 474 }
469 CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); 475 CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource);
476 return true;
470 } 477 }
471 478
472 private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) 479 private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
@@ -597,7 +604,7 @@ namespace OpenSim.Region.Framework.Scenes
597 } 604 }
598 605
599 /// <summary> 606 /// <summary>
600 /// Stop a script which is in this prim's inventory. 607 /// Stop and remove a script which is in this prim's inventory.
601 /// </summary> 608 /// </summary>
602 /// <param name="itemId"></param> 609 /// <param name="itemId"></param>
603 /// <param name="sceneObjectBeingDeleted"> 610 /// <param name="sceneObjectBeingDeleted">
@@ -616,7 +623,7 @@ namespace OpenSim.Region.Framework.Scenes
616 } 623 }
617 else 624 else
618 { 625 {
619 m_log.ErrorFormat( 626 m_log.WarnFormat(
620 "[PRIM INVENTORY]: " + 627 "[PRIM INVENTORY]: " +
621 "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", 628 "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
622 itemId, m_part.Name, m_part.UUID, 629 itemId, m_part.Name, m_part.UUID,
@@ -625,6 +632,51 @@ namespace OpenSim.Region.Framework.Scenes
625 } 632 }
626 633
627 /// <summary> 634 /// <summary>
635 /// Stop a script which is in this prim's inventory.
636 /// </summary>
637 /// <param name="itemId"></param>
638 /// <param name="sceneObjectBeingDeleted">
639 /// Should be true if this script is being removed because the scene
640 /// object is being deleted. This will prevent spurious updates to the client.
641 /// </param>
642 public void StopScriptInstance(UUID itemId)
643 {
644 TaskInventoryItem scriptItem;
645
646 lock (m_items)
647 m_items.TryGetValue(itemId, out scriptItem);
648
649 if (scriptItem != null)
650 {
651 StopScriptInstance(scriptItem);
652 }
653 else
654 {
655 m_log.WarnFormat(
656 "[PRIM INVENTORY]: " +
657 "Couldn't stop script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
658 itemId, m_part.Name, m_part.UUID,
659 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
660 }
661 }
662
663 /// <summary>
664 /// Stop a script which is in this prim's inventory.
665 /// </summary>
666 /// <param name="itemId"></param>
667 /// <param name="sceneObjectBeingDeleted">
668 /// Should be true if this script is being removed because the scene
669 /// object is being deleted. This will prevent spurious updates to the client.
670 /// </param>
671 public void StopScriptInstance(TaskInventoryItem item)
672 {
673 m_part.ParentGroup.Scene.EventManager.TriggerStopScript(m_part.LocalId, item.ItemID);
674
675 // At the moment, even stopped scripts are counted as active, which is probably wrong.
676// m_part.ParentGroup.AddActiveScriptCount(-1);
677 }
678
679 /// <summary>
628 /// Check if the inventory holds an item with a given name. 680 /// Check if the inventory holds an item with a given name.
629 /// </summary> 681 /// </summary>
630 /// <param name="name"></param> 682 /// <param name="name"></param>
@@ -770,14 +822,22 @@ namespace OpenSim.Region.Framework.Scenes
770 return item; 822 return item;
771 } 823 }
772 824
773 /// <summary> 825 public TaskInventoryItem GetInventoryItem(string name)
774 /// Get inventory items by name. 826 {
775 /// </summary> 827 m_items.LockItemsForRead(true);
776 /// <param name="name"></param> 828 foreach (TaskInventoryItem item in m_items.Values)
777 /// <returns> 829 {
778 /// A list of inventory items with that name. 830 if (item.Name == name)
779 /// If no inventory item has that name then an empty list is returned. 831 {
780 /// </returns> 832 m_items.LockItemsForRead(false);
833 return item;
834 }
835 }
836 m_items.LockItemsForRead(false);
837
838 return null;
839 }
840
781 public List<TaskInventoryItem> GetInventoryItems(string name) 841 public List<TaskInventoryItem> GetInventoryItems(string name)
782 { 842 {
783 List<TaskInventoryItem> items = new List<TaskInventoryItem>(); 843 List<TaskInventoryItem> items = new List<TaskInventoryItem>();
@@ -1247,10 +1307,10 @@ namespace OpenSim.Region.Framework.Scenes
1247 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) 1307 if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
1248 item.CurrentPermissions &= ~(uint)PermissionMask.Modify; 1308 item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
1249 } 1309 }
1250 item.OwnerChanged = true;
1251 item.CurrentPermissions &= item.NextPermissions; 1310 item.CurrentPermissions &= item.NextPermissions;
1252 item.BasePermissions &= item.NextPermissions; 1311 item.BasePermissions &= item.NextPermissions;
1253 item.EveryonePermissions &= item.NextPermissions; 1312 item.EveryonePermissions &= item.NextPermissions;
1313 item.OwnerChanged = true;
1254 item.PermsMask = 0; 1314 item.PermsMask = 0;
1255 item.PermsGranter = UUID.Zero; 1315 item.PermsGranter = UUID.Zero;
1256 } 1316 }
@@ -1281,9 +1341,57 @@ namespace OpenSim.Region.Framework.Scenes
1281 return true; 1341 return true;
1282 } 1342 }
1283 } 1343 }
1344
1284 return false; 1345 return false;
1285 } 1346 }
1286 1347
1348 /// <summary>
1349 /// Returns the count of scripts in this parts inventory.
1350 /// </summary>
1351 /// <returns></returns>
1352 public int ScriptCount()
1353 {
1354 int count = 0;
1355 Items.LockItemsForRead(true);
1356 foreach (TaskInventoryItem item in m_items.Values)
1357 {
1358 if (item.InvType == (int)InventoryType.LSL)
1359 {
1360 count++;
1361 }
1362 }
1363 Items.LockItemsForRead(false);
1364 return count;
1365 }
1366 /// <summary>
1367 /// Returns the count of running scripts in this parts inventory.
1368 /// </summary>
1369 /// <returns></returns>
1370 public int RunningScriptCount()
1371 {
1372 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
1373 if (engines.Length == 0)
1374 return 0;
1375
1376 int count = 0;
1377 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1378
1379 foreach (TaskInventoryItem item in scripts)
1380 {
1381 foreach (IScriptModule engine in engines)
1382 {
1383 if (engine != null)
1384 {
1385 if (engine.GetScriptState(item.ItemID))
1386 {
1387 count++;
1388 }
1389 }
1390 }
1391 }
1392 return count;
1393 }
1394
1287 public List<UUID> GetInventoryList() 1395 public List<UUID> GetInventoryList()
1288 { 1396 {
1289 List<UUID> ret = new List<UUID>(); 1397 List<UUID> ret = new List<UUID>();
@@ -1298,22 +1406,24 @@ namespace OpenSim.Region.Framework.Scenes
1298 { 1406 {
1299 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1407 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1300 1408
1301 lock (m_items) 1409 Items.LockItemsForRead(true);
1302 ret = new List<TaskInventoryItem>(m_items.Values); 1410 ret = new List<TaskInventoryItem>(m_items.Values);
1411 Items.LockItemsForRead(false);
1303 1412
1304 return ret; 1413 return ret;
1305 } 1414 }
1306 1415
1307 public List<TaskInventoryItem> GetInventoryScripts() 1416 public List<TaskInventoryItem> GetInventoryItems(InventoryType type)
1308 { 1417 {
1309 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1418 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1310 1419
1311 lock (m_items) 1420 Items.LockItemsForRead(true);
1312 { 1421
1313 foreach (TaskInventoryItem item in m_items.Values) 1422 foreach (TaskInventoryItem item in m_items.Values)
1314 if (item.InvType == (int)InventoryType.LSL) 1423 if (item.InvType == (int)type)
1315 ret.Add(item); 1424 ret.Add(item);
1316 } 1425
1426 Items.LockItemsForRead(false);
1317 1427
1318 return ret; 1428 return ret;
1319 } 1429 }
@@ -1335,35 +1445,36 @@ namespace OpenSim.Region.Framework.Scenes
1335 if (engines.Length == 0) // No engine at all 1445 if (engines.Length == 0) // No engine at all
1336 return ret; 1446 return ret;
1337 1447
1338 Items.LockItemsForRead(true); 1448 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1339 foreach (TaskInventoryItem item in m_items.Values) 1449
1450 foreach (TaskInventoryItem item in scripts)
1340 { 1451 {
1341 if (item.InvType == (int)InventoryType.LSL) 1452 foreach (IScriptModule e in engines)
1342 { 1453 {
1343 foreach (IScriptModule e in engines) 1454 if (e != null)
1344 { 1455 {
1345 if (e != null) 1456// m_log.DebugFormat(
1457// "[PRIM INVENTORY]: Getting script state from engine {0} for {1} in part {2} in group {3} in {4}",
1458// e.Name, item.Name, m_part.Name, m_part.ParentGroup.Name, m_part.ParentGroup.Scene.Name);
1459
1460 string n = e.GetXMLState(item.ItemID);
1461 if (n != String.Empty)
1346 { 1462 {
1347 string n = e.GetXMLState(item.ItemID); 1463 if (oldIDs)
1348 if (n != String.Empty) 1464 {
1465 if (!ret.ContainsKey(item.OldItemID))
1466 ret[item.OldItemID] = n;
1467 }
1468 else
1349 { 1469 {
1350 if (oldIDs) 1470 if (!ret.ContainsKey(item.ItemID))
1351 { 1471 ret[item.ItemID] = n;
1352 if (!ret.ContainsKey(item.OldItemID))
1353 ret[item.OldItemID] = n;
1354 }
1355 else
1356 {
1357 if (!ret.ContainsKey(item.ItemID))
1358 ret[item.ItemID] = n;
1359 }
1360 break;
1361 } 1472 }
1473 break;
1362 } 1474 }
1363 } 1475 }
1364 } 1476 }
1365 } 1477 }
1366 Items.LockItemsForRead(false);
1367 return ret; 1478 return ret;
1368 } 1479 }
1369 1480
@@ -1373,27 +1484,27 @@ namespace OpenSim.Region.Framework.Scenes
1373 if (engines.Length == 0) 1484 if (engines.Length == 0)
1374 return; 1485 return;
1375 1486
1487 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1376 1488
1377 Items.LockItemsForRead(true); 1489 foreach (TaskInventoryItem item in scripts)
1378
1379 foreach (TaskInventoryItem item in m_items.Values)
1380 { 1490 {
1381 if (item.InvType == (int)InventoryType.LSL) 1491 foreach (IScriptModule engine in engines)
1382 { 1492 {
1383 foreach (IScriptModule engine in engines) 1493 if (engine != null)
1384 { 1494 {
1385 if (engine != null) 1495// m_log.DebugFormat(
1386 { 1496// "[PRIM INVENTORY]: Resuming script {0} {1} for {2}, OwnerChanged {3}",
1387 if (item.OwnerChanged) 1497// item.Name, item.ItemID, item.OwnerID, item.OwnerChanged);
1388 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); 1498
1389 item.OwnerChanged = false; 1499 engine.ResumeScript(item.ItemID);
1390 engine.ResumeScript(item.ItemID); 1500
1391 } 1501 if (item.OwnerChanged)
1502 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER });
1503
1504 item.OwnerChanged = false;
1392 } 1505 }
1393 } 1506 }
1394 } 1507 }
1395
1396 Items.LockItemsForRead(false);
1397 } 1508 }
1398 } 1509 }
1399} 1510}