From c70d57ff983d42b6898d766eb5536e56868b3213 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 26 Jul 2010 20:36:28 +0100 Subject: Add EventManager.OnSceneObjectPreSave() for future use. This is triggered immediately before a copy of the group is persisted to storage --- OpenSim/Region/Framework/Scenes/EventManager.cs | 39 +++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/EventManager.cs') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 46e17c5..a4dd170 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -330,14 +330,26 @@ namespace OpenSim.Region.Framework.Scenes /// If the object is being attached, then the avatarID will be present. If the object is being detached then /// the avatarID is UUID.Zero (I know, this doesn't make much sense but now it's historical). public delegate void Attach(uint localID, UUID itemID, UUID avatarID); - public event Attach OnAttach; - - public delegate void SceneObjectDelegate(SceneObjectGroup so); + public event Attach OnAttach; /// /// Called immediately after an object is loaded from storage. /// public event SceneObjectDelegate OnSceneObjectLoaded; + public delegate void SceneObjectDelegate(SceneObjectGroup so); + + /// + /// Called immediately before an object is saved to storage. + /// + /// + /// The scene object being persisted. + /// This is actually a copy of the original scene object so changes made here will be saved to storage but will not be kept in memory. + /// + /// + /// The original scene object being persisted. Changes here will stay in memory but will not be saved to storage on this save. + /// + public event SceneObjectPreSaveDelegate OnSceneObjectPreSave; + public delegate void SceneObjectPreSaveDelegate(SceneObjectGroup persistingSo, SceneObjectGroup originalSo); public delegate void RegionUp(GridRegion region); public event RegionUp OnRegionUp; @@ -2040,6 +2052,27 @@ namespace OpenSim.Region.Framework.Scenes } } } + } + + public void TriggerOnSceneObjectPreSave(SceneObjectGroup persistingSo, SceneObjectGroup originalSo) + { + SceneObjectPreSaveDelegate handler = OnSceneObjectPreSave; + if (handler != null) + { + foreach (SceneObjectPreSaveDelegate d in handler.GetInvocationList()) + { + try + { + d(persistingSo, originalSo); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerOnSceneObjectPreSave failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } } } } \ No newline at end of file -- cgit v1.1