diff options
author | Justin Clark-Casey (justincc) | 2010-07-26 20:36:28 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-07-26 23:34:22 +0100 |
commit | b51b2efdc8059548e1da7ac13ee858673b71592f (patch) | |
tree | 048058e0bd7bf71ddac8cc9b7985a8454f4ddd24 /OpenSim/Region/Framework | |
parent | Add EventManager.OnSceneObjectLoaded() for future use. This is fired immedia... (diff) | |
download | opensim-SC_OLD-b51b2efdc8059548e1da7ac13ee858673b71592f.zip opensim-SC_OLD-b51b2efdc8059548e1da7ac13ee858673b71592f.tar.gz opensim-SC_OLD-b51b2efdc8059548e1da7ac13ee858673b71592f.tar.bz2 opensim-SC_OLD-b51b2efdc8059548e1da7ac13ee858673b71592f.tar.xz |
Add EventManager.OnSceneObjectPreSave() for future use. This is triggered immediately before a copy of the group is persisted to storage
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/EventManager.cs | 39 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 1 |
2 files changed, 37 insertions, 3 deletions
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 | |||
330 | /// If the object is being attached, then the avatarID will be present. If the object is being detached then | 330 | /// If the object is being attached, then the avatarID will be present. If the object is being detached then |
331 | /// the avatarID is UUID.Zero (I know, this doesn't make much sense but now it's historical). | 331 | /// the avatarID is UUID.Zero (I know, this doesn't make much sense but now it's historical). |
332 | public delegate void Attach(uint localID, UUID itemID, UUID avatarID); | 332 | public delegate void Attach(uint localID, UUID itemID, UUID avatarID); |
333 | public event Attach OnAttach; | 333 | public event Attach OnAttach; |
334 | |||
335 | public delegate void SceneObjectDelegate(SceneObjectGroup so); | ||
336 | 334 | ||
337 | /// <summary> | 335 | /// <summary> |
338 | /// Called immediately after an object is loaded from storage. | 336 | /// Called immediately after an object is loaded from storage. |
339 | /// </summary> | 337 | /// </summary> |
340 | public event SceneObjectDelegate OnSceneObjectLoaded; | 338 | public event SceneObjectDelegate OnSceneObjectLoaded; |
339 | public delegate void SceneObjectDelegate(SceneObjectGroup so); | ||
340 | |||
341 | /// <summary> | ||
342 | /// Called immediately before an object is saved to storage. | ||
343 | /// </summary> | ||
344 | /// <param name="persistingSo"> | ||
345 | /// The scene object being persisted. | ||
346 | /// 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. | ||
347 | /// </param> | ||
348 | /// <param name="originalSo"> | ||
349 | /// The original scene object being persisted. Changes here will stay in memory but will not be saved to storage on this save. | ||
350 | /// </param> | ||
351 | public event SceneObjectPreSaveDelegate OnSceneObjectPreSave; | ||
352 | public delegate void SceneObjectPreSaveDelegate(SceneObjectGroup persistingSo, SceneObjectGroup originalSo); | ||
341 | 353 | ||
342 | public delegate void RegionUp(GridRegion region); | 354 | public delegate void RegionUp(GridRegion region); |
343 | public event RegionUp OnRegionUp; | 355 | public event RegionUp OnRegionUp; |
@@ -2040,6 +2052,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2040 | } | 2052 | } |
2041 | } | 2053 | } |
2042 | } | 2054 | } |
2055 | } | ||
2056 | |||
2057 | public void TriggerOnSceneObjectPreSave(SceneObjectGroup persistingSo, SceneObjectGroup originalSo) | ||
2058 | { | ||
2059 | SceneObjectPreSaveDelegate handler = OnSceneObjectPreSave; | ||
2060 | if (handler != null) | ||
2061 | { | ||
2062 | foreach (SceneObjectPreSaveDelegate d in handler.GetInvocationList()) | ||
2063 | { | ||
2064 | try | ||
2065 | { | ||
2066 | d(persistingSo, originalSo); | ||
2067 | } | ||
2068 | catch (Exception e) | ||
2069 | { | ||
2070 | m_log.ErrorFormat( | ||
2071 | "[EVENT MANAGER]: Delegate for TriggerOnSceneObjectPreSave failed - continuing. {0} {1}", | ||
2072 | e.Message, e.StackTrace); | ||
2073 | } | ||
2074 | } | ||
2075 | } | ||
2043 | } | 2076 | } |
2044 | } | 2077 | } |
2045 | } \ No newline at end of file | 2078 | } \ 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 | |||
1479 | backup_group.RootPart.ParticleSystem = RootPart.ParticleSystem; | 1479 | backup_group.RootPart.ParticleSystem = RootPart.ParticleSystem; |
1480 | HasGroupChanged = false; | 1480 | HasGroupChanged = false; |
1481 | 1481 | ||
1482 | m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); | ||
1482 | datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); | 1483 | datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); |
1483 | 1484 | ||
1484 | backup_group.ForEachPart(delegate(SceneObjectPart part) | 1485 | backup_group.ForEachPart(delegate(SceneObjectPart part) |