* refactor: Replace derez destiation magic numbers with an enumeration

0.6.1-post-fixes
Justin Clarke Casey 2008-11-28 17:18:10 +00:00
parent a199d9b955
commit df9b0e9e11
8 changed files with 47 additions and 34 deletions

View File

@ -20,7 +20,7 @@
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORTOn
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
@ -33,7 +33,6 @@ using OpenMetaverse.Packets;
namespace OpenSim.Framework
{
#region Client API Delegate definitions
public delegate void ViewerEffectEventHandler(IClientAPI sender, List<ViewerEffectEventHandlerArg> args);
@ -98,7 +97,7 @@ namespace OpenSim.Framework
public delegate void GenericCall4(Packet packet, IClientAPI remoteClient);
public delegate void DeRezObject(
IClientAPI remoteClient, uint localID, UUID groupID, byte destination, UUID destinationID);
IClientAPI remoteClient, uint localID, UUID groupID, DeRezAction action, UUID destinationID);
public delegate void GenericCall5(IClientAPI remoteClient, bool status);

View File

@ -40,7 +40,19 @@ namespace OpenSim.Framework
Crashed = 2,
Starting = 3,
SlaveScene = 4
} ;
};
/// <value>
/// Indicate what action to take on an object derez request
/// </value>
public enum DeRezAction : byte
{
TakeCopy = 1,
Take = 4,
GodTakeCopy = 5,
Delete = 6,
Return = 9
};
public interface IScene
{

View File

@ -4162,9 +4162,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
foreach (DeRezObjectPacket.ObjectDataBlock data in
DeRezPacket.ObjectData)
{
// It just so happens that the values on the DeRezAction enumerator match the Destination
// values given by a Second Life client
handlerDeRezObject(this, data.ObjectLocalID,
DeRezPacket.AgentBlock.GroupID,
DeRezPacket.AgentBlock.Destination,
(DeRezAction)DeRezPacket.AgentBlock.Destination,
DeRezPacket.AgentBlock.DestinationID);
}
}

View File

@ -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
/// <summary>
/// Delete the given object from the scene
/// </summary>
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.

View File

@ -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))
{

View File

@ -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);
/// <summary>
/// Allows asynchronous derezzing of objects from the scene into a client's inventory.
@ -1543,10 +1543,13 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary>
/// Called when an object is removed from the environment into inventory.
/// </summary>
/// <param name="packet"></param>
/// <param name="remoteClient"></param>
/// <param name="localID"></param>
/// <param name="groupID"></param>
/// <param name="action"></param>
/// <param name="destinationID"></param>
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.
/// </summary>
/// <param name="DeRezPacket"></param>
/// <param name="selectedEnt"></param>
/// <param name="remoteClient"> </param>
/// <param name="objectGroup"></param>
/// <param name="action"></param>
/// <param name="folderID"></param>
/// <param name="permissionToDelete"></param>
public virtual UUID DeleteToInventory(int destination, UUID folderID,
/// <param name="objectGroup"></param>
/// <param name="remoteClient"> </param>
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;
}

View File

@ -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;
}

View File

@ -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);