* refactor: Replace derez destiation magic numbers with an enumeration
parent
a199d9b955
commit
df9b0e9e11
|
@ -20,7 +20,7 @@
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
@ -33,7 +33,6 @@ using OpenMetaverse.Packets;
|
||||||
|
|
||||||
namespace OpenSim.Framework
|
namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
|
|
||||||
#region Client API Delegate definitions
|
#region Client API Delegate definitions
|
||||||
|
|
||||||
public delegate void ViewerEffectEventHandler(IClientAPI sender, List<ViewerEffectEventHandlerArg> args);
|
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 GenericCall4(Packet packet, IClientAPI remoteClient);
|
||||||
|
|
||||||
public delegate void DeRezObject(
|
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);
|
public delegate void GenericCall5(IClientAPI remoteClient, bool status);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,19 @@ namespace OpenSim.Framework
|
||||||
Crashed = 2,
|
Crashed = 2,
|
||||||
Starting = 3,
|
Starting = 3,
|
||||||
SlaveScene = 4
|
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
|
public interface IScene
|
||||||
{
|
{
|
||||||
|
|
|
@ -4162,9 +4162,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
foreach (DeRezObjectPacket.ObjectDataBlock data in
|
foreach (DeRezObjectPacket.ObjectDataBlock data in
|
||||||
DeRezPacket.ObjectData)
|
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,
|
handlerDeRezObject(this, data.ObjectLocalID,
|
||||||
DeRezPacket.AgentBlock.GroupID,
|
DeRezPacket.AgentBlock.GroupID,
|
||||||
DeRezPacket.AgentBlock.Destination,
|
(DeRezAction)DeRezPacket.AgentBlock.Destination,
|
||||||
DeRezPacket.AgentBlock.DestinationID);
|
DeRezPacket.AgentBlock.DestinationID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
class DeleteToInventoryHolder
|
class DeleteToInventoryHolder
|
||||||
{
|
{
|
||||||
public int destination;
|
public DeRezAction action;
|
||||||
public IClientAPI remoteClient;
|
public IClientAPI remoteClient;
|
||||||
public SceneObjectGroup objectGroup;
|
public SceneObjectGroup objectGroup;
|
||||||
public UUID folderID;
|
public UUID folderID;
|
||||||
|
@ -74,7 +74,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete the given object from the scene
|
/// Delete the given object from the scene
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void DeleteToInventory(int destination, UUID folderID,
|
public void DeleteToInventory(DeRezAction action, UUID folderID,
|
||||||
SceneObjectGroup objectGroup, IClientAPI remoteClient,
|
SceneObjectGroup objectGroup, IClientAPI remoteClient,
|
||||||
bool permissionToDelete)
|
bool permissionToDelete)
|
||||||
{
|
{
|
||||||
|
@ -84,7 +84,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
lock (m_inventoryDeletes)
|
lock (m_inventoryDeletes)
|
||||||
{
|
{
|
||||||
DeleteToInventoryHolder dtis = new DeleteToInventoryHolder();
|
DeleteToInventoryHolder dtis = new DeleteToInventoryHolder();
|
||||||
dtis.destination = destination;
|
dtis.action = action;
|
||||||
dtis.folderID = folderID;
|
dtis.folderID = folderID;
|
||||||
dtis.objectGroup = objectGroup;
|
dtis.objectGroup = objectGroup;
|
||||||
dtis.remoteClient = remoteClient;
|
dtis.remoteClient = remoteClient;
|
||||||
|
@ -136,7 +136,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
try
|
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)
|
if (x.permissionToDelete)
|
||||||
m_scene.DeleteSceneObject(x.objectGroup, false);
|
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).
|
// 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.
|
// FIXME: This needs to be fixed.
|
||||||
|
|
|
@ -102,9 +102,9 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid
|
||||||
///
|
///
|
||||||
/// DeleteToInventory
|
/// 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))
|
if (!assetID.Equals(UUID.Zero))
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
public partial class Scene
|
public partial class Scene
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log
|
private static readonly ILog m_log
|
||||||
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Allows asynchronous derezzing of objects from the scene into a client's inventory.
|
/// Allows asynchronous derezzing of objects from the scene into a client's inventory.
|
||||||
|
@ -1543,10 +1543,13 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when an object is removed from the environment into inventory.
|
/// Called when an object is removed from the environment into inventory.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packet"></param>
|
|
||||||
/// <param name="remoteClient"></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,
|
public virtual void DeRezObject(IClientAPI remoteClient, uint localID,
|
||||||
UUID groupID, byte destination, UUID destinationID)
|
UUID groupID, DeRezAction action, UUID destinationID)
|
||||||
{
|
{
|
||||||
SceneObjectPart part = GetSceneObjectPart(localID);
|
SceneObjectPart part = GetSceneObjectPart(localID);
|
||||||
if (part == null)
|
if (part == null)
|
||||||
|
@ -1564,20 +1567,20 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
bool permissionToTake = false;
|
bool permissionToTake = false;
|
||||||
bool permissionToDelete = false;
|
bool permissionToDelete = false;
|
||||||
|
|
||||||
if (destination == 1) // Take Copy
|
if (action == DeRezAction.TakeCopy)
|
||||||
{
|
{
|
||||||
permissionToTake =
|
permissionToTake =
|
||||||
Permissions.CanTakeCopyObject(
|
Permissions.CanTakeCopyObject(
|
||||||
grp.UUID,
|
grp.UUID,
|
||||||
remoteClient.AgentId);
|
remoteClient.AgentId);
|
||||||
}
|
}
|
||||||
else if (destination == 5) // God take copy
|
else if (action == DeRezAction.GodTakeCopy)
|
||||||
{
|
{
|
||||||
permissionToTake =
|
permissionToTake =
|
||||||
Permissions.IsGod(
|
Permissions.IsGod(
|
||||||
remoteClient.AgentId);
|
remoteClient.AgentId);
|
||||||
}
|
}
|
||||||
else if (destination == 4) // Take
|
else if (action == DeRezAction.Take)
|
||||||
{
|
{
|
||||||
permissionToTake =
|
permissionToTake =
|
||||||
Permissions.CanTakeObject(
|
Permissions.CanTakeObject(
|
||||||
|
@ -1587,7 +1590,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
//If they can take, they can delete!
|
//If they can take, they can delete!
|
||||||
permissionToDelete = permissionToTake;
|
permissionToDelete = permissionToTake;
|
||||||
}
|
}
|
||||||
else if (destination == 6) //Delete
|
else if (action == DeRezAction.Delete)
|
||||||
{
|
{
|
||||||
permissionToTake =
|
permissionToTake =
|
||||||
Permissions.CanDeleteObject(
|
Permissions.CanDeleteObject(
|
||||||
|
@ -1598,7 +1601,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
grp.UUID,
|
grp.UUID,
|
||||||
remoteClient.AgentId);
|
remoteClient.AgentId);
|
||||||
}
|
}
|
||||||
else if (destination == 9) //Return
|
else if (action == DeRezAction.Return)
|
||||||
{
|
{
|
||||||
if (remoteClient != null)
|
if (remoteClient != null)
|
||||||
{
|
{
|
||||||
|
@ -1625,7 +1628,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
if (permissionToTake)
|
if (permissionToTake)
|
||||||
{
|
{
|
||||||
m_asyncSceneObjectDeleter.DeleteToInventory(
|
m_asyncSceneObjectDeleter.DeleteToInventory(
|
||||||
destination, destinationID, grp, remoteClient,
|
action, destinationID, grp, remoteClient,
|
||||||
permissionToDelete);
|
permissionToDelete);
|
||||||
}
|
}
|
||||||
else if (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.
|
/// Delete a scene object from a scene and place in the given avatar's inventory.
|
||||||
/// Returns the UUID of the newly created asset.
|
/// Returns the UUID of the newly created asset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="DeRezPacket"></param>
|
/// <param name="action"></param>
|
||||||
/// <param name="selectedEnt"></param>
|
|
||||||
/// <param name="remoteClient"> </param>
|
|
||||||
/// <param name="objectGroup"></param>
|
|
||||||
/// <param name="folderID"></param>
|
/// <param name="folderID"></param>
|
||||||
/// <param name="permissionToDelete"></param>
|
/// <param name="objectGroup"></param>
|
||||||
public virtual UUID DeleteToInventory(int destination, UUID folderID,
|
/// <param name="remoteClient"> </param>
|
||||||
|
public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
|
||||||
SceneObjectGroup objectGroup, IClientAPI remoteClient)
|
SceneObjectGroup objectGroup, IClientAPI remoteClient)
|
||||||
{
|
{
|
||||||
UUID assetID = UUID.Zero;
|
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
|
// If we're returning someone's item, it goes back to the
|
||||||
// owner's Lost And Found folder.
|
// owner's Lost And Found folder.
|
||||||
|
|
||||||
if (folderID == UUID.Zero || (destination == 6 &&
|
if (folderID == UUID.Zero || (action == DeRezAction.Delete &&
|
||||||
objectGroup.OwnerID != remoteClient.AgentId))
|
objectGroup.OwnerID != remoteClient.AgentId))
|
||||||
{
|
{
|
||||||
InventoryFolderBase folder =
|
InventoryFolderBase folder =
|
||||||
|
@ -1708,8 +1709,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
InventoryItemBase item = new InventoryItemBase();
|
InventoryItemBase item = new InventoryItemBase();
|
||||||
item.Creator = objectGroup.RootPart.CreatorID;
|
item.Creator = objectGroup.RootPart.CreatorID;
|
||||||
|
|
||||||
if (destination == 1 ||
|
if (action == DeRezAction.TakeCopy || action == DeRezAction.Take)
|
||||||
destination == 4)// Take / Copy
|
|
||||||
item.Owner = remoteClient.AgentId;
|
item.Owner = remoteClient.AgentId;
|
||||||
else // Delete / Return
|
else // Delete / Return
|
||||||
item.Owner = objectGroup.OwnerID;
|
item.Owner = objectGroup.OwnerID;
|
||||||
|
@ -2215,7 +2215,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
|
AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return");
|
||||||
DeRezObject(null, grp.RootPart.LocalId,
|
DeRezObject(null, grp.RootPart.LocalId,
|
||||||
grp.RootPart.GroupID, 9, UUID.Zero);
|
grp.RootPart.GroupID, DeRezAction.Return, UUID.Zero);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1223,10 +1223,10 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
parcel.landData.OtherCleanTime)
|
parcel.landData.OtherCleanTime)
|
||||||
{
|
{
|
||||||
DetachFromBackup();
|
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.AddReturn(OwnerID, Name, AbsolutePosition, "parcel auto return");
|
||||||
m_scene.DeRezObject(null, RootPart.LocalId,
|
m_scene.DeRezObject(null, RootPart.LocalId,
|
||||||
RootPart.GroupID, 9, UUID.Zero);
|
RootPart.GroupID, DeRezAction.Return, UUID.Zero);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ namespace OpenSim.Region.Environment.Scenes.Tests
|
||||||
Is.EqualTo(agentId));
|
Is.EqualTo(agentId));
|
||||||
|
|
||||||
IClientAPI client = SceneTestUtils.AddRootAgent(scene, 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);
|
SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
|
||||||
Assert.That(retrievedPart, Is.Not.Null);
|
Assert.That(retrievedPart, Is.Not.Null);
|
||||||
|
|
Loading…
Reference in New Issue