aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs116
1 files changed, 48 insertions, 68 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 7e629c0..36cb09a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -267,14 +267,9 @@ namespace OpenSim.Region.Framework.Scenes
267 /// </summary> 267 /// </summary>
268 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) 268 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
269 { 269 {
270 Items.LockItemsForRead(true); 270 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
271 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); 271 foreach (TaskInventoryItem item in scripts)
272 Items.LockItemsForRead(false); 272 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
273 foreach (TaskInventoryItem item in items)
274 {
275 if ((int)InventoryType.LSL == item.InvType)
276 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
277 }
278 } 273 }
279 274
280 public ArrayList GetScriptErrors(UUID itemID) 275 public ArrayList GetScriptErrors(UUID itemID)
@@ -305,17 +300,11 @@ 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
@@ -1291,17 +1280,15 @@ namespace OpenSim.Region.Framework.Scenes
1291 public int ScriptCount() 1280 public int ScriptCount()
1292 { 1281 {
1293 int count = 0; 1282 int count = 0;
1294 lock (m_items) 1283 Items.LockItemsForRead(true);
1284 foreach (TaskInventoryItem item in m_items.Values)
1295 { 1285 {
1296 foreach (TaskInventoryItem item in m_items.Values) 1286 if (item.InvType == (int)InventoryType.LSL)
1297 { 1287 {
1298 if (item.InvType == (int)InventoryType.LSL) 1288 count++;
1299 {
1300 count++;
1301 }
1302 } 1289 }
1303 } 1290 }
1304 1291 Items.LockItemsForRead(false);
1305 return count; 1292 return count;
1306 } 1293 }
1307 /// <summary> 1294 /// <summary>
@@ -1315,7 +1302,7 @@ namespace OpenSim.Region.Framework.Scenes
1315 return 0; 1302 return 0;
1316 1303
1317 int count = 0; 1304 int count = 0;
1318 List<TaskInventoryItem> scripts = GetInventoryScripts(); 1305 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1319 1306
1320 foreach (TaskInventoryItem item in scripts) 1307 foreach (TaskInventoryItem item in scripts)
1321 { 1308 {
@@ -1347,22 +1334,24 @@ namespace OpenSim.Region.Framework.Scenes
1347 { 1334 {
1348 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1335 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1349 1336
1350 lock (m_items) 1337 Items.LockItemsForRead(true);
1351 ret = new List<TaskInventoryItem>(m_items.Values); 1338 ret = new List<TaskInventoryItem>(m_items.Values);
1339 Items.LockItemsForRead(false);
1352 1340
1353 return ret; 1341 return ret;
1354 } 1342 }
1355 1343
1356 public List<TaskInventoryItem> GetInventoryScripts() 1344 public List<TaskInventoryItem> GetInventoryItems(InventoryType type)
1357 { 1345 {
1358 List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); 1346 List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
1359 1347
1360 lock (m_items) 1348 Items.LockItemsForRead(true);
1361 { 1349
1362 foreach (TaskInventoryItem item in m_items.Values) 1350 foreach (TaskInventoryItem item in m_items.Values)
1363 if (item.InvType == (int)InventoryType.LSL) 1351 if (item.InvType == (int)type)
1364 ret.Add(item); 1352 ret.Add(item);
1365 } 1353
1354 Items.LockItemsForRead(false);
1366 1355
1367 return ret; 1356 return ret;
1368 } 1357 }
@@ -1384,35 +1373,32 @@ namespace OpenSim.Region.Framework.Scenes
1384 if (engines.Length == 0) // No engine at all 1373 if (engines.Length == 0) // No engine at all
1385 return ret; 1374 return ret;
1386 1375
1387 Items.LockItemsForRead(true); 1376 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1388 foreach (TaskInventoryItem item in m_items.Values) 1377
1378 foreach (TaskInventoryItem item in scripts)
1389 { 1379 {
1390 if (item.InvType == (int)InventoryType.LSL) 1380 foreach (IScriptModule e in engines)
1391 { 1381 {
1392 foreach (IScriptModule e in engines) 1382 if (e != null)
1393 { 1383 {
1394 if (e != null) 1384 string n = e.GetXMLState(item.ItemID);
1385 if (n != String.Empty)
1395 { 1386 {
1396 string n = e.GetXMLState(item.ItemID); 1387 if (oldIDs)
1397 if (n != String.Empty) 1388 {
1389 if (!ret.ContainsKey(item.OldItemID))
1390 ret[item.OldItemID] = n;
1391 }
1392 else
1398 { 1393 {
1399 if (oldIDs) 1394 if (!ret.ContainsKey(item.ItemID))
1400 { 1395 ret[item.ItemID] = n;
1401 if (!ret.ContainsKey(item.OldItemID))
1402 ret[item.OldItemID] = n;
1403 }
1404 else
1405 {
1406 if (!ret.ContainsKey(item.ItemID))
1407 ret[item.ItemID] = n;
1408 }
1409 break;
1410 } 1396 }
1397 break;
1411 } 1398 }
1412 } 1399 }
1413 } 1400 }
1414 } 1401 }
1415 Items.LockItemsForRead(false);
1416 return ret; 1402 return ret;
1417 } 1403 }
1418 1404
@@ -1422,27 +1408,21 @@ namespace OpenSim.Region.Framework.Scenes
1422 if (engines.Length == 0) 1408 if (engines.Length == 0)
1423 return; 1409 return;
1424 1410
1411 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
1425 1412
1426 Items.LockItemsForRead(true); 1413 foreach (TaskInventoryItem item in scripts)
1427
1428 foreach (TaskInventoryItem item in m_items.Values)
1429 { 1414 {
1430 if (item.InvType == (int)InventoryType.LSL) 1415 foreach (IScriptModule engine in engines)
1431 { 1416 {
1432 foreach (IScriptModule engine in engines) 1417 if (engine != null)
1433 { 1418 {
1434 if (engine != null) 1419 if (item.OwnerChanged)
1435 { 1420 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER });
1436 if (item.OwnerChanged) 1421 item.OwnerChanged = false;
1437 engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); 1422 engine.ResumeScript(item.ItemID);
1438 item.OwnerChanged = false;
1439 engine.ResumeScript(item.ItemID);
1440 }
1441 } 1423 }
1442 } 1424 }
1443 } 1425 }
1444
1445 Items.LockItemsForRead(false);
1446 } 1426 }
1447 } 1427 }
1448} 1428}