aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs138
1 files changed, 76 insertions, 62 deletions
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