diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 158 |
1 files changed, 97 insertions, 61 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 959046a..141cf66 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 | ||
@@ -1281,9 +1270,57 @@ namespace OpenSim.Region.Framework.Scenes | |||
1281 | return true; | 1270 | return true; |
1282 | } | 1271 | } |
1283 | } | 1272 | } |
1273 | |||
1284 | return false; | 1274 | return false; |
1285 | } | 1275 | } |
1286 | 1276 | ||
1277 | /// <summary> | ||
1278 | /// Returns the count of scripts in this parts inventory. | ||
1279 | /// </summary> | ||
1280 | /// <returns></returns> | ||
1281 | public int ScriptCount() | ||
1282 | { | ||
1283 | int count = 0; | ||
1284 | Items.LockItemsForRead(true); | ||
1285 | foreach (TaskInventoryItem item in m_items.Values) | ||
1286 | { | ||
1287 | if (item.InvType == (int)InventoryType.LSL) | ||
1288 | { | ||
1289 | count++; | ||
1290 | } | ||
1291 | } | ||
1292 | Items.LockItemsForRead(false); | ||
1293 | return count; | ||
1294 | } | ||
1295 | /// <summary> | ||
1296 | /// Returns the count of running scripts in this parts inventory. | ||
1297 | /// </summary> | ||
1298 | /// <returns></returns> | ||
1299 | public int RunningScriptCount() | ||
1300 | { | ||
1301 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
1302 | if (engines.Length == 0) | ||
1303 | return 0; | ||
1304 | |||
1305 | int count = 0; | ||
1306 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); | ||
1307 | |||
1308 | foreach (TaskInventoryItem item in scripts) | ||
1309 | { | ||
1310 | foreach (IScriptModule engine in engines) | ||
1311 | { | ||
1312 | if (engine != null) | ||
1313 | { | ||
1314 | if (engine.GetScriptState(item.ItemID)) | ||
1315 | { | ||
1316 | count++; | ||
1317 | } | ||
1318 | } | ||
1319 | } | ||
1320 | } | ||
1321 | return count; | ||
1322 | } | ||
1323 | |||
1287 | public List<UUID> GetInventoryList() | 1324 | public List<UUID> GetInventoryList() |
1288 | { | 1325 | { |
1289 | List<UUID> ret = new List<UUID>(); | 1326 | List<UUID> ret = new List<UUID>(); |
@@ -1298,22 +1335,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1298 | { | 1335 | { |
1299 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1336 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1300 | 1337 | ||
1301 | lock (m_items) | 1338 | Items.LockItemsForRead(true); |
1302 | ret = new List<TaskInventoryItem>(m_items.Values); | 1339 | ret = new List<TaskInventoryItem>(m_items.Values); |
1340 | Items.LockItemsForRead(false); | ||
1303 | 1341 | ||
1304 | return ret; | 1342 | return ret; |
1305 | } | 1343 | } |
1306 | 1344 | ||
1307 | public List<TaskInventoryItem> GetInventoryScripts() | 1345 | public List<TaskInventoryItem> GetInventoryItems(InventoryType type) |
1308 | { | 1346 | { |
1309 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1347 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1310 | 1348 | ||
1311 | lock (m_items) | 1349 | Items.LockItemsForRead(true); |
1312 | { | 1350 | |
1313 | foreach (TaskInventoryItem item in m_items.Values) | 1351 | foreach (TaskInventoryItem item in m_items.Values) |
1314 | if (item.InvType == (int)InventoryType.LSL) | 1352 | if (item.InvType == (int)type) |
1315 | ret.Add(item); | 1353 | ret.Add(item); |
1316 | } | 1354 | |
1355 | Items.LockItemsForRead(false); | ||
1317 | 1356 | ||
1318 | return ret; | 1357 | return ret; |
1319 | } | 1358 | } |
@@ -1335,35 +1374,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1335 | if (engines.Length == 0) // No engine at all | 1374 | if (engines.Length == 0) // No engine at all |
1336 | return ret; | 1375 | return ret; |
1337 | 1376 | ||
1338 | Items.LockItemsForRead(true); | 1377 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
1339 | foreach (TaskInventoryItem item in m_items.Values) | 1378 | |
1379 | foreach (TaskInventoryItem item in scripts) | ||
1340 | { | 1380 | { |
1341 | if (item.InvType == (int)InventoryType.LSL) | 1381 | foreach (IScriptModule e in engines) |
1342 | { | 1382 | { |
1343 | foreach (IScriptModule e in engines) | 1383 | if (e != null) |
1344 | { | 1384 | { |
1345 | if (e != null) | 1385 | string n = e.GetXMLState(item.ItemID); |
1386 | if (n != String.Empty) | ||
1346 | { | 1387 | { |
1347 | string n = e.GetXMLState(item.ItemID); | 1388 | if (oldIDs) |
1348 | if (n != String.Empty) | 1389 | { |
1390 | if (!ret.ContainsKey(item.OldItemID)) | ||
1391 | ret[item.OldItemID] = n; | ||
1392 | } | ||
1393 | else | ||
1349 | { | 1394 | { |
1350 | if (oldIDs) | 1395 | if (!ret.ContainsKey(item.ItemID)) |
1351 | { | 1396 | 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 | } | 1397 | } |
1398 | break; | ||
1362 | } | 1399 | } |
1363 | } | 1400 | } |
1364 | } | 1401 | } |
1365 | } | 1402 | } |
1366 | Items.LockItemsForRead(false); | ||
1367 | return ret; | 1403 | return ret; |
1368 | } | 1404 | } |
1369 | 1405 | ||
@@ -1373,27 +1409,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
1373 | if (engines.Length == 0) | 1409 | if (engines.Length == 0) |
1374 | return; | 1410 | return; |
1375 | 1411 | ||
1412 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); | ||
1376 | 1413 | ||
1377 | Items.LockItemsForRead(true); | 1414 | foreach (TaskInventoryItem item in scripts) |
1378 | |||
1379 | foreach (TaskInventoryItem item in m_items.Values) | ||
1380 | { | 1415 | { |
1381 | if (item.InvType == (int)InventoryType.LSL) | 1416 | foreach (IScriptModule engine in engines) |
1382 | { | 1417 | { |
1383 | foreach (IScriptModule engine in engines) | 1418 | if (engine != null) |
1384 | { | 1419 | { |
1385 | if (engine != null) | 1420 | // m_log.DebugFormat( |
1386 | { | 1421 | // "[PRIM INVENTORY]: Resuming script {0} {1} for {2}, OwnerChanged {3}", |
1387 | if (item.OwnerChanged) | 1422 | // item.Name, item.ItemID, item.OwnerID, item.OwnerChanged); |
1388 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); | 1423 | |
1389 | item.OwnerChanged = false; | 1424 | engine.ResumeScript(item.ItemID); |
1390 | engine.ResumeScript(item.ItemID); | 1425 | |
1391 | } | 1426 | if (item.OwnerChanged) |
1427 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); | ||
1428 | |||
1429 | item.OwnerChanged = false; | ||
1392 | } | 1430 | } |
1393 | } | 1431 | } |
1394 | } | 1432 | } |
1395 | |||
1396 | Items.LockItemsForRead(false); | ||
1397 | } | 1433 | } |
1398 | } | 1434 | } |
1399 | } | 1435 | } \ No newline at end of file |