From df9b0e9e1131cd3fd9b0361d4d75c7242e04d848 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Fri, 28 Nov 2008 17:18:10 +0000
Subject: * refactor: Replace derez destiation magic numbers with an
enumeration
---
.../Scenes/AsyncSceneObjectGroupDeleter.cs | 10 +++---
.../Scenes/Hypergrid/HGScene.Inventory.cs | 4 +--
.../Region/Environment/Scenes/Scene.Inventory.cs | 38 +++++++++++-----------
.../Region/Environment/Scenes/SceneObjectGroup.cs | 4 +--
.../Environment/Scenes/Tests/SceneObjectTests.cs | 2 +-
5 files changed, 29 insertions(+), 29 deletions(-)
(limited to 'OpenSim/Region/Environment/Scenes')
diff --git a/OpenSim/Region/Environment/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Environment/Scenes/AsyncSceneObjectGroupDeleter.cs
index 20cf318..03b3977 100644
--- a/OpenSim/Region/Environment/Scenes/AsyncSceneObjectGroupDeleter.cs
+++ b/OpenSim/Region/Environment/Scenes/AsyncSceneObjectGroupDeleter.cs
@@ -38,7 +38,7 @@ namespace OpenSim.Region.Environment.Scenes
{
class DeleteToInventoryHolder
{
- public int destination;
+ public DeRezAction action;
public IClientAPI remoteClient;
public SceneObjectGroup objectGroup;
public UUID folderID;
@@ -74,7 +74,7 @@ namespace OpenSim.Region.Environment.Scenes
///
/// Delete the given object from the scene
///
- public void DeleteToInventory(int destination, UUID folderID,
+ public void DeleteToInventory(DeRezAction action, UUID folderID,
SceneObjectGroup objectGroup, IClientAPI remoteClient,
bool permissionToDelete)
{
@@ -84,7 +84,7 @@ namespace OpenSim.Region.Environment.Scenes
lock (m_inventoryDeletes)
{
DeleteToInventoryHolder dtis = new DeleteToInventoryHolder();
- dtis.destination = destination;
+ dtis.action = action;
dtis.folderID = folderID;
dtis.objectGroup = objectGroup;
dtis.remoteClient = remoteClient;
@@ -136,7 +136,7 @@ namespace OpenSim.Region.Environment.Scenes
try
{
- m_scene.DeleteToInventory(x.destination, x.folderID, x.objectGroup, x.remoteClient);
+ m_scene.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient);
if (x.permissionToDelete)
m_scene.DeleteSceneObject(x.objectGroup, false);
}
@@ -149,7 +149,7 @@ namespace OpenSim.Region.Environment.Scenes
}
}
}
- catch(Exception e)
+ catch (Exception e)
{
// We can't put the object group details in here since the root part may have disappeared (which is where these sit).
// FIXME: This needs to be fixed.
diff --git a/OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.Inventory.cs
index 92627d1..f44ba30 100644
--- a/OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Hypergrid/HGScene.Inventory.cs
@@ -102,9 +102,9 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid
///
/// DeleteToInventory
///
- public override UUID DeleteToInventory(int destination, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient)
+ public override UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient)
{
- UUID assetID = base.DeleteToInventory(destination, folderID, objectGroup, remoteClient);
+ UUID assetID = base.DeleteToInventory(action, folderID, objectGroup, remoteClient);
if (!assetID.Equals(UUID.Zero))
{
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 77ac121..113b16c 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Region.Environment.Scenes
public partial class Scene
{
private static readonly ILog m_log
- = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
///
/// Allows asynchronous derezzing of objects from the scene into a client's inventory.
@@ -1543,10 +1543,13 @@ namespace OpenSim.Region.Environment.Scenes
///
/// Called when an object is removed from the environment into inventory.
///
- ///
///
+ ///
+ ///
+ ///
+ ///
public virtual void DeRezObject(IClientAPI remoteClient, uint localID,
- UUID groupID, byte destination, UUID destinationID)
+ UUID groupID, DeRezAction action, UUID destinationID)
{
SceneObjectPart part = GetSceneObjectPart(localID);
if (part == null)
@@ -1564,20 +1567,20 @@ namespace OpenSim.Region.Environment.Scenes
bool permissionToTake = false;
bool permissionToDelete = false;
- if (destination == 1) // Take Copy
+ if (action == DeRezAction.TakeCopy)
{
permissionToTake =
Permissions.CanTakeCopyObject(
grp.UUID,
remoteClient.AgentId);
}
- else if (destination == 5) // God take copy
+ else if (action == DeRezAction.GodTakeCopy)
{
permissionToTake =
Permissions.IsGod(
remoteClient.AgentId);
}
- else if (destination == 4) // Take
+ else if (action == DeRezAction.Take)
{
permissionToTake =
Permissions.CanTakeObject(
@@ -1587,7 +1590,7 @@ namespace OpenSim.Region.Environment.Scenes
//If they can take, they can delete!
permissionToDelete = permissionToTake;
}
- else if (destination == 6) //Delete
+ else if (action == DeRezAction.Delete)
{
permissionToTake =
Permissions.CanDeleteObject(
@@ -1598,7 +1601,7 @@ namespace OpenSim.Region.Environment.Scenes
grp.UUID,
remoteClient.AgentId);
}
- else if (destination == 9) //Return
+ else if (action == DeRezAction.Return)
{
if (remoteClient != null)
{
@@ -1625,7 +1628,7 @@ namespace OpenSim.Region.Environment.Scenes
if (permissionToTake)
{
m_asyncSceneObjectDeleter.DeleteToInventory(
- destination, destinationID, grp, remoteClient,
+ action, destinationID, grp, remoteClient,
permissionToDelete);
}
else if (permissionToDelete)
@@ -1638,13 +1641,11 @@ namespace OpenSim.Region.Environment.Scenes
/// Delete a scene object from a scene and place in the given avatar's inventory.
/// Returns the UUID of the newly created asset.
///
- ///
- ///
- ///
- ///
+ ///
///
- ///
- public virtual UUID DeleteToInventory(int destination, UUID folderID,
+ ///
+ ///
+ public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
SceneObjectGroup objectGroup, IClientAPI remoteClient)
{
UUID assetID = UUID.Zero;
@@ -1671,7 +1672,7 @@ namespace OpenSim.Region.Environment.Scenes
// If we're returning someone's item, it goes back to the
// owner's Lost And Found folder.
- if (folderID == UUID.Zero || (destination == 6 &&
+ if (folderID == UUID.Zero || (action == DeRezAction.Delete &&
objectGroup.OwnerID != remoteClient.AgentId))
{
InventoryFolderBase folder =
@@ -1708,8 +1709,7 @@ namespace OpenSim.Region.Environment.Scenes
InventoryItemBase item = new InventoryItemBase();
item.Creator = objectGroup.RootPart.CreatorID;
- if (destination == 1 ||
- destination == 4)// Take / Copy
+ if (action == DeRezAction.TakeCopy || action == DeRezAction.Take)
item.Owner = remoteClient.AgentId;
else // Delete / Return
item.Owner = objectGroup.OwnerID;
@@ -2215,7 +2215,7 @@ namespace OpenSim.Region.Environment.Scenes
{
AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
DeRezObject(null, grp.RootPart.LocalId,
- grp.RootPart.GroupID, 9, UUID.Zero);
+ grp.RootPart.GroupID, DeRezAction.Return, UUID.Zero);
}
return true;
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 7bdcb5c..8a6f06c 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -1223,10 +1223,10 @@ namespace OpenSim.Region.Environment.Scenes
parcel.landData.OtherCleanTime)
{
DetachFromBackup();
- m_log.InfoFormat("[SCENE] Returning object {0} due to parcel auto return", RootPart.UUID.ToString());
+ m_log.InfoFormat("[SCENE]: Returning object {0} due to parcel auto return", RootPart.UUID.ToString());
m_scene.AddReturn(OwnerID, Name, AbsolutePosition, "parcel auto return");
m_scene.DeRezObject(null, RootPart.LocalId,
- RootPart.GroupID, 9, UUID.Zero);
+ RootPart.GroupID, DeRezAction.Return, UUID.Zero);
return;
}
diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs
index 7391696..babdee6 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs
@@ -110,7 +110,7 @@ namespace OpenSim.Region.Environment.Scenes.Tests
Is.EqualTo(agentId));
IClientAPI client = SceneTestUtils.AddRootAgent(scene, agentId);
- scene.DeRezObject(client, part.LocalId, UUID.Zero, 9, UUID.Zero);
+ scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Return, UUID.Zero);
SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
Assert.That(retrievedPart, Is.Not.Null);
--
cgit v1.1