Allow for richer semantics of object derez. Specifically, allow the existence of region modules that do other kinds of garbage collection. Instead of placing deleted objects in the user's Trash folder, or deleting them immediately (UseTrashOnDelete = false), a module may decide to take garbage collection under its control. For example, it may place derezzed objects in a certain area inworld and delete them later.

mb-throttle-test
Diva Canto 2014-12-25 12:17:07 -08:00
parent 789cd4e928
commit bb82076a4d
2 changed files with 54 additions and 13 deletions

View File

@ -786,7 +786,29 @@ namespace OpenSim.Region.Framework.Scenes
/// <see cref="Scene.doObjectDuplicateOnRay"/>
/// </remarks>
public event Action<SceneObjectGroup> OnObjectAddedToScene;
/// <summary>
/// When a client sends a derez request for an object inworld
/// but before the object is deleted
/// </summary>
public event DeRezRequested OnDeRezRequested;
/// <summary>
/// Triggered when a client sends a derez request for an object inworld
/// </summary>
/// <param name="remoteClient">The client question (it can be null)</param>
/// <param name="obj">The object in question</param>
/// <param name="action">The exact derez action</param>
/// <returns>Flag indicating whether the object should be deleted from the scene or not</returns>
public delegate bool DeRezRequested(IClientAPI remoteClient, List<SceneObjectGroup> objs, DeRezAction action);
/// <summary>
/// Triggered when an object is removed from the scene.
/// </summary>
/// <remarks>
/// Triggered by <see cref="TriggerObjectBeingRemovedFromScene"/>
/// in <see cref="Scene.DeleteSceneObject"/>
/// </remarks>
public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene;
/// <summary>
/// Delegate for <see cref="OnObjectBeingRemovedFromScene"/>
/// </summary>
@ -806,15 +828,6 @@ namespace OpenSim.Region.Framework.Scenes
/// </remarks>
public event Action<SceneObjectPart> OnObjectRemovedFromPhysicalScene;
/// <summary>
/// Triggered when an object is removed from the scene.
/// </summary>
/// <remarks>
/// Triggered by <see cref="TriggerObjectBeingRemovedFromScene"/>
/// in <see cref="Scene.DeleteSceneObject"/>
/// </remarks>
public event ObjectBeingRemovedFromScene OnObjectBeingRemovedFromScene;
public delegate void NoticeNoLandDataFromStorage();
public event NoticeNoLandDataFromStorage OnNoticeNoLandDataFromStorage;
@ -1521,8 +1534,33 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
}
}
public bool TriggerDeRezRequested(IClientAPI client, List<SceneObjectGroup> objs, DeRezAction action)
{
bool canDeRez = true;
DeRezRequested handlerDeRezRequested = OnDeRezRequested;
if (handlerDeRezRequested != null)
{
foreach (DeRezRequested d in handlerDeRezRequested.GetInvocationList())
{
try
{
canDeRez &= d(client, objs, action);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[EVENT MANAGER]: Delegate for TriggerDeRezRequested failed - continuing. {0} {1}",
e.Message, e.StackTrace);
}
}
}
return canDeRez;
}
public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj)
{
ObjectBeingRemovedFromScene handlerObjectBeingRemovedFromScene = OnObjectBeingRemovedFromScene;

View File

@ -2182,13 +2182,16 @@ namespace OpenSim.Region.Framework.Scenes
}
}
// OK, we're done with permissions. Let's check if any part of the code prevents the objects from being deleted
bool canDelete = EventManager.TriggerDeRezRequested(remoteClient, deleteGroups, action);
if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete))
{
m_asyncSceneObjectDeleter.DeleteToInventory(
action, destinationID, deleteGroups, remoteClient,
permissionToDelete);
permissionToDelete && canDelete);
}
else if (permissionToDelete)
else if (permissionToDelete && canDelete)
{
foreach (SceneObjectGroup g in deleteGroups)
DeleteSceneObject(g, false);