aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs39
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs116
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs19
3 files changed, 106 insertions, 68 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 5786f48..ced3fb5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -4032,6 +4032,45 @@ namespace OpenSim.Region.Framework.Scenes
4032 } 4032 }
4033 4033
4034 /// <summary> 4034 /// <summary>
4035 /// A float the value is a representative execution time in milliseconds of all scripts in the link set.
4036 /// </summary>
4037 public float ScriptExecutionTime()
4038 {
4039 IScriptModule[] engines = Scene.RequestModuleInterfaces<IScriptModule>();
4040
4041 if (engines.Length == 0) // No engine at all
4042 return 0.0f;
4043
4044 float time = 0.0f;
4045
4046 // get all the scripts in all parts
4047 SceneObjectPart[] parts = m_parts.GetArray();
4048 List<TaskInventoryItem> scripts = new List<TaskInventoryItem>();
4049 for (int i = 0; i < parts.Length; i++)
4050 {
4051 scripts.AddRange(parts[i].Inventory.GetInventoryItems(InventoryType.LSL));
4052 }
4053 // extract the UUIDs
4054 List<UUID> ids = new List<UUID>(scripts.Count);
4055 foreach (TaskInventoryItem script in scripts)
4056 {
4057 if (!ids.Contains(script.ItemID))
4058 {
4059 ids.Add(script.ItemID);
4060 }
4061 }
4062 // Offer the list of script UUIDs to each engine found and accumulate the time
4063 foreach (IScriptModule e in engines)
4064 {
4065 if (e != null)
4066 {
4067 time += e.GetScriptExecutionTime(ids);
4068 }
4069 }
4070 return time;
4071 }
4072
4073 /// <summary>
4035 /// Returns a count of the number of running scripts in this groups parts. 4074 /// Returns a count of the number of running scripts in this groups parts.
4036 /// </summary> 4075 /// </summary>
4037 public int RunningScriptCount() 4076 public int RunningScriptCount()
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}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 0cb1556..fd7f7d8 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3541,6 +3541,25 @@ namespace OpenSim.Region.Framework.Scenes
3541 } 3541 }
3542 3542
3543 /// <summary> 3543 /// <summary>
3544 /// A float the value is a representative execution time in milliseconds of all scripts in all attachments.
3545 /// </summary>
3546 public float ScriptExecutionTime()
3547 {
3548 float time = 0.0f;
3549 lock (m_attachments)
3550 {
3551 foreach (SceneObjectGroup gobj in m_attachments)
3552 {
3553 if (gobj != null)
3554 {
3555 time += gobj.ScriptExecutionTime();
3556 }
3557 }
3558 }
3559 return time;
3560 }
3561
3562 /// <summary>
3544 /// Returns the total count of running scripts in all parts. 3563 /// Returns the total count of running scripts in all parts.
3545 /// </summary> 3564 /// </summary>
3546 public int RunningScriptCount() 3565 public int RunningScriptCount()