aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie Thielker2010-06-01 02:27:30 +0200
committerMelanie2010-06-01 02:10:22 +0100
commitf29cb57bf183c0530ead35890163f39903c8f410 (patch)
tree303f04127a4051be5d27c2007edc359e1e306478
parentAdd a method to get the bounding box and root prim offsets within it for (diff)
downloadopensim-SC_OLD-f29cb57bf183c0530ead35890163f39903c8f410.zip
opensim-SC_OLD-f29cb57bf183c0530ead35890163f39903c8f410.tar.gz
opensim-SC_OLD-f29cb57bf183c0530ead35890163f39903c8f410.tar.bz2
opensim-SC_OLD-f29cb57bf183c0530ead35890163f39903c8f410.tar.xz
Continuing refactor. Refactor DeRezObject to deal with multiple objects
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs17
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs14
-rw-r--r--OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs18
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs138
5 files changed, 118 insertions, 71 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index 93aeb94..2ab46aa 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -119,9 +119,22 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
119 /// 119 ///
120 /// DeleteToInventory 120 /// DeleteToInventory
121 /// 121 ///
122 public override UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient) 122 public override UUID DeleteToInventory(DeRezAction action, UUID folderID, List<SceneObjectGroup> objectGroups, IClientAPI remoteClient)
123 { 123 {
124 UUID assetID = base.DeleteToInventory(action, folderID, objectGroup, remoteClient); 124 UUID ret = UUID.Zero;
125
126 // HACK: Only works for lists of length one.
127 // Intermediate version, just to make things compile
128 foreach (SceneObjectGroup g in objectGroups)
129 ret = DeleteToInventory(action, folderID, g, remoteClient);
130
131 return ret;
132 }
133
134 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
135 SceneObjectGroup objectGroup, IClientAPI remoteClient)
136 {
137 UUID assetID = base.DeleteToInventory(action, folderID, new List<SceneObjectGroup>() {objectGroup}, remoteClient);
125 138
126 if (!assetID.Equals(UUID.Zero)) 139 if (!assetID.Equals(UUID.Zero))
127 { 140 {
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 901dcba..3035d88 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -189,6 +189,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
189 /// <param name="objectGroup"></param> 189 /// <param name="objectGroup"></param>
190 /// <param name="remoteClient"> </param> 190 /// <param name="remoteClient"> </param>
191 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, 191 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
192 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient)
193 {
194 // HACK: This is only working for lists containing a single item!
195 // It's just a hack to make this WIP compile and run. Nothing
196 // currently calls this with multiple items.
197 UUID ret = UUID.Zero;
198
199 foreach (SceneObjectGroup g in objectGroups)
200 ret = DeleteToInventory(action, folderID, g, remoteClient);
201
202 return ret;
203 }
204
205 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
192 SceneObjectGroup objectGroup, IClientAPI remoteClient) 206 SceneObjectGroup objectGroup, IClientAPI remoteClient)
193 { 207 {
194 UUID assetID = UUID.Zero; 208 UUID assetID = UUID.Zero;
diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
index 8185258..97f4188 100644
--- a/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs
@@ -38,7 +38,7 @@ namespace OpenSim.Region.Framework.Interfaces
38 public interface IInventoryAccessModule 38 public interface IInventoryAccessModule
39 { 39 {
40 UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data); 40 UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data);
41 UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient); 41 UUID DeleteToInventory(DeRezAction action, UUID folderID, List<SceneObjectGroup> objectGroups, IClientAPI remoteClient);
42 SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, 42 SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
43 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 43 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
44 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment); 44 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment);
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
index c08b961..241cac0 100644
--- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
+++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Region.Framework.Scenes
40 { 40 {
41 public DeRezAction action; 41 public DeRezAction action;
42 public IClientAPI remoteClient; 42 public IClientAPI remoteClient;
43 public SceneObjectGroup objectGroup; 43 public List<SceneObjectGroup> objectGroups;
44 public UUID folderID; 44 public UUID folderID;
45 public bool permissionToDelete; 45 public bool permissionToDelete;
46 } 46 }
@@ -75,7 +75,7 @@ namespace OpenSim.Region.Framework.Scenes
75 /// Delete the given object from the scene 75 /// Delete the given object from the scene
76 /// </summary> 76 /// </summary>
77 public void DeleteToInventory(DeRezAction action, UUID folderID, 77 public void DeleteToInventory(DeRezAction action, UUID folderID,
78 SceneObjectGroup objectGroup, IClientAPI remoteClient, 78 List<SceneObjectGroup> objectGroups, IClientAPI remoteClient,
79 bool permissionToDelete) 79 bool permissionToDelete)
80 { 80 {
81 if (Enabled) 81 if (Enabled)
@@ -87,7 +87,7 @@ namespace OpenSim.Region.Framework.Scenes
87 DeleteToInventoryHolder dtis = new DeleteToInventoryHolder(); 87 DeleteToInventoryHolder dtis = new DeleteToInventoryHolder();
88 dtis.action = action; 88 dtis.action = action;
89 dtis.folderID = folderID; 89 dtis.folderID = folderID;
90 dtis.objectGroup = objectGroup; 90 dtis.objectGroups = objectGroups;
91 dtis.remoteClient = remoteClient; 91 dtis.remoteClient = remoteClient;
92 dtis.permissionToDelete = permissionToDelete; 92 dtis.permissionToDelete = permissionToDelete;
93 93
@@ -103,7 +103,10 @@ namespace OpenSim.Region.Framework.Scenes
103 // This is not ideal since the object will still be available for manipulation when it should be, but it's 103 // This is not ideal since the object will still be available for manipulation when it should be, but it's
104 // better than losing the object for now. 104 // better than losing the object for now.
105 if (permissionToDelete) 105 if (permissionToDelete)
106 objectGroup.DeleteGroup(false); 106 {
107 foreach (SceneObjectGroup g in objectGroups)
108 g.DeleteGroup(false);
109 }
107 } 110 }
108 111
109 private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e) 112 private void InventoryRunDeleteTimer(object sender, ElapsedEventArgs e)
@@ -140,9 +143,12 @@ namespace OpenSim.Region.Framework.Scenes
140 { 143 {
141 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); 144 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
142 if (invAccess != null) 145 if (invAccess != null)
143 invAccess.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient); 146 invAccess.DeleteToInventory(x.action, x.folderID, x.objectGroups, x.remoteClient);
144 if (x.permissionToDelete) 147 if (x.permissionToDelete)
145 m_scene.DeleteSceneObject(x.objectGroup, false); 148 {
149 foreach (SceneObjectGroup g in x.objectGroups)
150 m_scene.DeleteSceneObject(g, false);
151 }
146 } 152 }
147 catch (Exception e) 153 catch (Exception e)
148 { 154 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 96f22a4..bad92a0 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1531,79 +1531,98 @@ namespace OpenSim.Region.Framework.Scenes
1531 public virtual void DeRezObject(IClientAPI remoteClient, uint localID, 1531 public virtual void DeRezObject(IClientAPI remoteClient, uint localID,
1532 UUID groupID, DeRezAction action, UUID destinationID) 1532 UUID groupID, DeRezAction action, UUID destinationID)
1533 { 1533 {
1534 SceneObjectPart part = GetSceneObjectPart(localID); 1534 DeRezObjects(remoteClient, new List<uint>() { localID} , groupID, action, destinationID);
1535 if (part == null) 1535 }
1536 return;
1537 1536
1538 if (part.ParentGroup == null || part.ParentGroup.IsDeleted) 1537 public virtual void DeRezObjects(IClientAPI remoteClient, List<uint> localIDs,
1539 return; 1538 UUID groupID, DeRezAction action, UUID destinationID)
1539 {
1540 // First, see of we can perform the requested action and
1541 // build a list of eligible objects
1542 List<uint> deleteIDs = new List<uint>();
1543 List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>();
1540 1544
1541 // Can't delete child prims 1545 // Start with true for both, then remove the flags if objects
1542 if (part != part.ParentGroup.RootPart) 1546 // that we can't derez are part of the selection
1543 return; 1547 bool permissionToTake = true;
1548 bool permissionToTakeCopy = true;
1549 bool permissionToDelete = true;
1544 1550
1545 SceneObjectGroup grp = part.ParentGroup; 1551 foreach (uint localID in localIDs)
1552 {
1553 // Invalid id
1554 SceneObjectPart part = GetSceneObjectPart(localID);
1555 if (part == null)
1556 continue;
1546 1557
1547 //force a database backup/update on this SceneObjectGroup 1558 // Already deleted by someone else
1548 //So that we know the database is upto date, for when deleting the object from it 1559 if (part.ParentGroup == null || part.ParentGroup.IsDeleted)
1549 ForceSceneObjectBackup(grp); 1560 continue;
1550 1561
1551 bool permissionToTake = false; 1562 // Can't delete child prims
1552 bool permissionToDelete = false; 1563 if (part != part.ParentGroup.RootPart)
1564 continue;
1553 1565
1554 if (action == DeRezAction.SaveToExistingUserInventoryItem) 1566 SceneObjectGroup grp = part.ParentGroup;
1555 { 1567
1556 if (grp.OwnerID == remoteClient.AgentId && grp.RootPart.FromUserInventoryItemID != UUID.Zero) 1568 deleteIDs.Add(localID);
1557 { 1569 deleteGroups.Add(grp);
1558 permissionToTake = true; 1570
1571 // Force a database backup/update on this SceneObjectGroup
1572 // So that we know the database is upto date,
1573 // for when deleting the object from it
1574 ForceSceneObjectBackup(grp);
1575
1576 if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId))
1577 permissionToTakeCopy = false;
1578 if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId))
1579 permissionToTake = false;
1580
1581 if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId))
1559 permissionToDelete = false; 1582 permissionToDelete = false;
1560 } 1583
1561 } 1584 }
1562 else if (action == DeRezAction.TakeCopy) 1585
1586 // Handle god perms
1587 if (Permissions.IsGod(remoteClient.AgentId))
1563 { 1588 {
1564 permissionToTake = 1589 permissionToTake = true;
1565 Permissions.CanTakeCopyObject( 1590 permissionToTakeCopy = true;
1566 grp.UUID, 1591 permissionToDelete = true;
1567 remoteClient.AgentId);
1568 } 1592 }
1569 else if (action == DeRezAction.GodTakeCopy)
1570 {
1571 permissionToTake =
1572 Permissions.IsGod(
1573 remoteClient.AgentId);
1574 }
1575 else if (action == DeRezAction.Take)
1576 {
1577 permissionToTake =
1578 Permissions.CanTakeObject(
1579 grp.UUID,
1580 remoteClient.AgentId);
1581 1593
1582 //If they can take, they can delete! 1594 // If we're re-saving, we don't even want to delete
1583 permissionToDelete = permissionToTake; 1595 if (action == DeRezAction.SaveToExistingUserInventoryItem)
1584 } 1596 permissionToDelete = false;
1585 else if (action == DeRezAction.Delete) 1597
1598 // if we want to take a copy,, we also don't want to delete
1599 // Note: after this point, the permissionToTakeCopy flag
1600 // becomes irrelevant. It already includes the permissionToTake
1601 // permission and after excluding no copy items here, we can
1602 // just use that.
1603 if (action == DeRezAction.TakeCopy)
1586 { 1604 {
1587 permissionToTake = 1605 // If we don't have permission, stop right here
1588 Permissions.CanDeleteObject( 1606 if (!permissionToTakeCopy)
1589 grp.UUID, 1607 return;
1590 remoteClient.AgentId); 1608
1591 permissionToDelete = permissionToTake; 1609 // Don't delete
1610 permissionToDelete = false;
1592 } 1611 }
1593 else if (action == DeRezAction.Return) 1612
1613 if (action == DeRezAction.Return)
1594 { 1614 {
1595 if (remoteClient != null) 1615 if (remoteClient != null)
1596 { 1616 {
1597 permissionToTake = 1617 if (Permissions.CanReturnObjects(
1598 Permissions.CanReturnObjects(
1599 null, 1618 null,
1600 remoteClient.AgentId, 1619 remoteClient.AgentId,
1601 new List<SceneObjectGroup>() {grp}); 1620 deleteGroups))
1602 permissionToDelete = permissionToTake; 1621 foreach (SceneObjectGroup g in deleteGroups)
1603
1604 if (permissionToDelete)
1605 { 1622 {
1606 AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); 1623 AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return");
1624 DeleteSceneObject(g, false);
1625 return;
1607 } 1626 }
1608 } 1627 }
1609 else // Auto return passes through here with null agent 1628 else // Auto return passes through here with null agent
@@ -1612,22 +1631,17 @@ namespace OpenSim.Region.Framework.Scenes
1612 permissionToDelete = true; 1631 permissionToDelete = true;
1613 } 1632 }
1614 } 1633 }
1615 else
1616 {
1617 m_log.DebugFormat(
1618 "[AGENT INVENTORY]: Ignoring unexpected derez action {0} for {1}", action, remoteClient.Name);
1619 return;
1620 }
1621 1634
1622 if (permissionToTake) 1635 if (permissionToTake)
1623 { 1636 {
1624 m_asyncSceneObjectDeleter.DeleteToInventory( 1637 m_asyncSceneObjectDeleter.DeleteToInventory(
1625 action, destinationID, grp, remoteClient, 1638 action, destinationID, deleteGroups, remoteClient,
1626 permissionToDelete); 1639 permissionToDelete);
1627 } 1640 }
1628 else if (permissionToDelete) 1641 else if (permissionToDelete)
1629 { 1642 {
1630 DeleteSceneObject(grp, false); 1643 foreach (SceneObjectGroup g in deleteGroups)
1644 DeleteSceneObject(g, false);
1631 } 1645 }
1632 } 1646 }
1633 1647