From b51b2efdc8059548e1da7ac13ee858673b71592f 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 ++++++++++++++++++++--
.../Region/Framework/Scenes/SceneObjectGroup.cs | 1 +
2 files changed, 37 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 0b1f593..3b8d727 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
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 17275d0..c2f9117 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1479,6 +1479,7 @@ namespace OpenSim.Region.Framework.Scenes
backup_group.RootPart.ParticleSystem = RootPart.ParticleSystem;
HasGroupChanged = false;
+ m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this);
datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID);
backup_group.ForEachPart(delegate(SceneObjectPart part)
--
cgit v1.1