diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 182 |
1 files changed, 113 insertions, 69 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 959046a..f5b9825 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 | ||
@@ -770,14 +759,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
770 | return item; | 759 | return item; |
771 | } | 760 | } |
772 | 761 | ||
773 | /// <summary> | 762 | public TaskInventoryItem GetInventoryItem(string name) |
774 | /// Get inventory items by name. | 763 | { |
775 | /// </summary> | 764 | m_items.LockItemsForRead(true); |
776 | /// <param name="name"></param> | 765 | foreach (TaskInventoryItem item in m_items.Values) |
777 | /// <returns> | 766 | { |
778 | /// A list of inventory items with that name. | 767 | if (item.Name == name) |
779 | /// If no inventory item has that name then an empty list is returned. | 768 | { |
780 | /// </returns> | 769 | return item; |
770 | m_items.LockItemsForRead(false); | ||
771 | } | ||
772 | } | ||
773 | m_items.LockItemsForRead(false); | ||
774 | |||
775 | return null; | ||
776 | } | ||
777 | |||
781 | public List<TaskInventoryItem> GetInventoryItems(string name) | 778 | public List<TaskInventoryItem> GetInventoryItems(string name) |
782 | { | 779 | { |
783 | List<TaskInventoryItem> items = new List<TaskInventoryItem>(); | 780 | List<TaskInventoryItem> items = new List<TaskInventoryItem>(); |
@@ -1247,10 +1244,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1247 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | 1244 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
1248 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; | 1245 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; |
1249 | } | 1246 | } |
1250 | item.OwnerChanged = true; | ||
1251 | item.CurrentPermissions &= item.NextPermissions; | 1247 | item.CurrentPermissions &= item.NextPermissions; |
1252 | item.BasePermissions &= item.NextPermissions; | 1248 | item.BasePermissions &= item.NextPermissions; |
1253 | item.EveryonePermissions &= item.NextPermissions; | 1249 | item.EveryonePermissions &= item.NextPermissions; |
1250 | item.OwnerChanged = true; | ||
1254 | item.PermsMask = 0; | 1251 | item.PermsMask = 0; |
1255 | item.PermsGranter = UUID.Zero; | 1252 | item.PermsGranter = UUID.Zero; |
1256 | } | 1253 | } |
@@ -1281,9 +1278,57 @@ namespace OpenSim.Region.Framework.Scenes | |||
1281 | return true; | 1278 | return true; |
1282 | } | 1279 | } |
1283 | } | 1280 | } |
1281 | |||
1284 | return false; | 1282 | return false; |
1285 | } | 1283 | } |
1286 | 1284 | ||
1285 | /// <summary> | ||
1286 | /// Returns the count of scripts in this parts inventory. | ||
1287 | /// </summary> | ||
1288 | /// <returns></returns> | ||
1289 | public int ScriptCount() | ||
1290 | { | ||
1291 | int count = 0; | ||
1292 | Items.LockItemsForRead(true); | ||
1293 | foreach (TaskInventoryItem item in m_items.Values) | ||
1294 | { | ||
1295 | if (item.InvType == (int)InventoryType.LSL) | ||
1296 | { | ||
1297 | count++; | ||
1298 | } | ||
1299 | } | ||
1300 | Items.LockItemsForRead(false); | ||
1301 | return count; | ||
1302 | } | ||
1303 | /// <summary> | ||
1304 | /// Returns the count of running scripts in this parts inventory. | ||
1305 | /// </summary> | ||
1306 | /// <returns></returns> | ||
1307 | public int RunningScriptCount() | ||
1308 | { | ||
1309 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
1310 | if (engines.Length == 0) | ||
1311 | return 0; | ||
1312 | |||
1313 | int count = 0; | ||
1314 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); | ||
1315 | |||
1316 | foreach (TaskInventoryItem item in scripts) | ||
1317 | { | ||
1318 | foreach (IScriptModule engine in engines) | ||
1319 | { | ||
1320 | if (engine != null) | ||
1321 | { | ||
1322 | if (engine.GetScriptState(item.ItemID)) | ||
1323 | { | ||
1324 | count++; | ||
1325 | } | ||
1326 | } | ||
1327 | } | ||
1328 | } | ||
1329 | return count; | ||
1330 | } | ||
1331 | |||
1287 | public List<UUID> GetInventoryList() | 1332 | public List<UUID> GetInventoryList() |
1288 | { | 1333 | { |
1289 | List<UUID> ret = new List<UUID>(); | 1334 | List<UUID> ret = new List<UUID>(); |
@@ -1298,22 +1343,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1298 | { | 1343 | { |
1299 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1344 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1300 | 1345 | ||
1301 | lock (m_items) | 1346 | Items.LockItemsForRead(true); |
1302 | ret = new List<TaskInventoryItem>(m_items.Values); | 1347 | ret = new List<TaskInventoryItem>(m_items.Values); |
1348 | Items.LockItemsForRead(false); | ||
1303 | 1349 | ||
1304 | return ret; | 1350 | return ret; |
1305 | } | 1351 | } |
1306 | 1352 | ||
1307 | public List<TaskInventoryItem> GetInventoryScripts() | 1353 | public List<TaskInventoryItem> GetInventoryItems(InventoryType type) |
1308 | { | 1354 | { |
1309 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1355 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1310 | 1356 | ||
1311 | lock (m_items) | 1357 | Items.LockItemsForRead(true); |
1312 | { | 1358 | |
1313 | foreach (TaskInventoryItem item in m_items.Values) | 1359 | foreach (TaskInventoryItem item in m_items.Values) |
1314 | if (item.InvType == (int)InventoryType.LSL) | 1360 | if (item.InvType == (int)type) |
1315 | ret.Add(item); | 1361 | ret.Add(item); |
1316 | } | 1362 | |
1363 | Items.LockItemsForRead(false); | ||
1317 | 1364 | ||
1318 | return ret; | 1365 | return ret; |
1319 | } | 1366 | } |
@@ -1335,35 +1382,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1335 | if (engines.Length == 0) // No engine at all | 1382 | if (engines.Length == 0) // No engine at all |
1336 | return ret; | 1383 | return ret; |
1337 | 1384 | ||
1338 | Items.LockItemsForRead(true); | 1385 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
1339 | foreach (TaskInventoryItem item in m_items.Values) | 1386 | |
1387 | foreach (TaskInventoryItem item in scripts) | ||
1340 | { | 1388 | { |
1341 | if (item.InvType == (int)InventoryType.LSL) | 1389 | foreach (IScriptModule e in engines) |
1342 | { | 1390 | { |
1343 | foreach (IScriptModule e in engines) | 1391 | if (e != null) |
1344 | { | 1392 | { |
1345 | if (e != null) | 1393 | string n = e.GetXMLState(item.ItemID); |
1394 | if (n != String.Empty) | ||
1346 | { | 1395 | { |
1347 | string n = e.GetXMLState(item.ItemID); | 1396 | if (oldIDs) |
1348 | if (n != String.Empty) | 1397 | { |
1398 | if (!ret.ContainsKey(item.OldItemID)) | ||
1399 | ret[item.OldItemID] = n; | ||
1400 | } | ||
1401 | else | ||
1349 | { | 1402 | { |
1350 | if (oldIDs) | 1403 | if (!ret.ContainsKey(item.ItemID)) |
1351 | { | 1404 | 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 | } | 1405 | } |
1406 | break; | ||
1362 | } | 1407 | } |
1363 | } | 1408 | } |
1364 | } | 1409 | } |
1365 | } | 1410 | } |
1366 | Items.LockItemsForRead(false); | ||
1367 | return ret; | 1411 | return ret; |
1368 | } | 1412 | } |
1369 | 1413 | ||
@@ -1373,27 +1417,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
1373 | if (engines.Length == 0) | 1417 | if (engines.Length == 0) |
1374 | return; | 1418 | return; |
1375 | 1419 | ||
1420 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); | ||
1376 | 1421 | ||
1377 | Items.LockItemsForRead(true); | 1422 | foreach (TaskInventoryItem item in scripts) |
1378 | |||
1379 | foreach (TaskInventoryItem item in m_items.Values) | ||
1380 | { | 1423 | { |
1381 | if (item.InvType == (int)InventoryType.LSL) | 1424 | foreach (IScriptModule engine in engines) |
1382 | { | 1425 | { |
1383 | foreach (IScriptModule engine in engines) | 1426 | if (engine != null) |
1384 | { | 1427 | { |
1385 | if (engine != null) | 1428 | // m_log.DebugFormat( |
1386 | { | 1429 | // "[PRIM INVENTORY]: Resuming script {0} {1} for {2}, OwnerChanged {3}", |
1387 | if (item.OwnerChanged) | 1430 | // item.Name, item.ItemID, item.OwnerID, item.OwnerChanged); |
1388 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); | 1431 | |
1389 | item.OwnerChanged = false; | 1432 | engine.ResumeScript(item.ItemID); |
1390 | engine.ResumeScript(item.ItemID); | 1433 | |
1391 | } | 1434 | if (item.OwnerChanged) |
1435 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); | ||
1436 | |||
1437 | item.OwnerChanged = false; | ||
1392 | } | 1438 | } |
1393 | } | 1439 | } |
1394 | } | 1440 | } |
1395 | |||
1396 | Items.LockItemsForRead(false); | ||
1397 | } | 1441 | } |
1398 | } | 1442 | } |
1399 | } | 1443 | } |