diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | 101 |
1 files changed, 18 insertions, 83 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 5ff6dec..8557b1c 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -40,23 +40,15 @@ using OpenSim.Region.Environment.Interfaces; | |||
40 | 40 | ||
41 | namespace OpenSim.Region.Environment.Scenes | 41 | namespace OpenSim.Region.Environment.Scenes |
42 | { | 42 | { |
43 | class DeleteToInventoryHolder | ||
44 | { | ||
45 | public DeRezObjectPacket DeRezPacket; | ||
46 | public EntityBase selectedEnt; | ||
47 | public IClientAPI remoteClient; | ||
48 | public SceneObjectGroup objectGroup; | ||
49 | public UUID folderID; | ||
50 | public bool permissionToDelete; | ||
51 | } | ||
52 | |||
53 | public partial class Scene | 43 | public partial class Scene |
54 | { | 44 | { |
55 | private Timer m_inventoryTicker; | ||
56 | private readonly Queue<DeleteToInventoryHolder> m_inventoryDeletes = new Queue<DeleteToInventoryHolder>(); | ||
57 | |||
58 | private static readonly ILog m_log | 45 | private static readonly ILog m_log |
59 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | |||
48 | /// <summary> | ||
49 | /// Allows asynchronous derezzing of objects from the scene into a client's inventory. | ||
50 | /// </summary> | ||
51 | private AsyncSceneObjectGroupDeleter m_asyncSceneObjectDeleter; | ||
60 | 52 | ||
61 | /// <summary> | 53 | /// <summary> |
62 | /// Start all the scripts in the scene which should be started. | 54 | /// Start all the scripts in the scene which should be started. |
@@ -1546,35 +1538,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
1546 | 1538 | ||
1547 | if (permissionToTake) | 1539 | if (permissionToTake) |
1548 | { | 1540 | { |
1549 | if (m_inventoryTicker != null) | 1541 | m_asyncSceneObjectDeleter.DeleteToInventory( |
1550 | { | 1542 | DeRezPacket, folderID, objectGroup, remoteClient, selectedEnt, permissionToDelete); |
1551 | m_inventoryTicker.Stop(); | ||
1552 | } | ||
1553 | else | ||
1554 | { | ||
1555 | m_inventoryTicker = new Timer(2000); | ||
1556 | m_inventoryTicker.AutoReset = false; | ||
1557 | m_inventoryTicker.Elapsed += InventoryRunDeleteTimer; | ||
1558 | } | ||
1559 | |||
1560 | lock (m_inventoryDeletes) | ||
1561 | { | ||
1562 | DeleteToInventoryHolder dtis = new DeleteToInventoryHolder(); | ||
1563 | dtis.DeRezPacket = DeRezPacket; | ||
1564 | dtis.folderID = folderID; | ||
1565 | dtis.objectGroup = objectGroup; | ||
1566 | dtis.remoteClient = remoteClient; | ||
1567 | dtis.selectedEnt = selectedEnt; | ||
1568 | dtis.permissionToDelete = permissionToDelete; | ||
1569 | |||
1570 | m_inventoryDeletes.Enqueue(dtis); | ||
1571 | } | ||
1572 | |||
1573 | m_inventoryTicker.Start(); | ||
1574 | |||
1575 | // Visually remove it, even if it isnt really gone yet. | ||
1576 | if (permissionToDelete) | ||
1577 | objectGroup.FakeDeleteGroup(); | ||
1578 | } | 1543 | } |
1579 | else if (permissionToDelete) | 1544 | else if (permissionToDelete) |
1580 | { | 1545 | { |
@@ -1584,47 +1549,17 @@ namespace OpenSim.Region.Environment.Scenes | |||
1584 | } | 1549 | } |
1585 | } | 1550 | } |
1586 | 1551 | ||
1587 | void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e) | 1552 | /// <summary> |
1588 | { | 1553 | /// Delete a scene object from a scene and place in the given avatar's inventory. |
1589 | m_log.Info("Starting inventory send loop"); | 1554 | /// </summary> |
1590 | while (InventoryDeQueueAndDelete() == true) | 1555 | /// <param name="DeRezPacket"></param> |
1591 | { | 1556 | /// <param name="selectedEnt"></param> |
1592 | m_log.Info("Returned item successfully, continuing..."); | 1557 | /// <param name="remoteClient"> </param> |
1593 | } | 1558 | /// <param name="objectGroup"></param> |
1594 | } | 1559 | /// <param name="folderID"></param> |
1595 | 1560 | /// <param name="permissionToDelete"></param> | |
1596 | private bool InventoryDeQueueAndDelete() | 1561 | public void DeleteToInventory(DeRezObjectPacket DeRezPacket, EntityBase selectedEnt, IClientAPI remoteClient, |
1597 | { | 1562 | SceneObjectGroup objectGroup, UUID folderID, bool permissionToDelete) |
1598 | DeleteToInventoryHolder x = null; | ||
1599 | |||
1600 | try | ||
1601 | { | ||
1602 | lock (m_inventoryDeletes) | ||
1603 | { | ||
1604 | int left = m_inventoryDeletes.Count; | ||
1605 | if (left > 0) | ||
1606 | { | ||
1607 | m_log.InfoFormat("Sending deleted object to user's inventory, {0} item(s) remaining.", left); | ||
1608 | x = m_inventoryDeletes.Dequeue(); | ||
1609 | DeleteToInventory(x.DeRezPacket, x.selectedEnt, x.remoteClient, x.objectGroup, x.folderID, x.permissionToDelete); | ||
1610 | return true; | ||
1611 | } | ||
1612 | } | ||
1613 | } | ||
1614 | catch(Exception e) | ||
1615 | { | ||
1616 | // We can't put the object group details in here since the root part may have disappeared (which is where these sit). | ||
1617 | // FIXME: This needs to be fixed. | ||
1618 | m_log.ErrorFormat( | ||
1619 | "[AGENT INVENTORY]: Queued deletion of scene object to agent {0} {1} failed: {2}", | ||
1620 | (x != null ? x.remoteClient.Name : "unavailable"), (x != null ? x.remoteClient.AgentId.ToString() : "unavailable"), e.ToString()); | ||
1621 | } | ||
1622 | |||
1623 | m_log.Info("No objects left in inventory delete queue."); | ||
1624 | return false; | ||
1625 | } | ||
1626 | |||
1627 | private void DeleteToInventory(DeRezObjectPacket DeRezPacket, EntityBase selectedEnt, IClientAPI remoteClient, SceneObjectGroup objectGroup, UUID folderID, bool permissionToDelete) | ||
1628 | { | 1563 | { |
1629 | string sceneObjectXml = objectGroup.ToXmlString(); | 1564 | string sceneObjectXml = objectGroup.ToXmlString(); |
1630 | 1565 | ||