From 0237d9113d3cc510fcd9f94d53631c254b8a0351 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Mon, 25 Nov 2013 19:22:09 +0200 Subject: [PATCH] Don't start KeyframeMotion timers until all the regions are ready. This prevents problems in megaregions (prims that think they've crossed over to other regions). --- .../Region/Framework/Scenes/KeyframeMotion.cs | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 29652aaa66..ab1e7faf33 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -47,7 +47,7 @@ namespace OpenSim.Region.Framework.Scenes { public class KeyframeTimer { - private static Dictionarym_timers = + private static Dictionary m_timers = new Dictionary(); private Timer m_timer; @@ -67,8 +67,15 @@ namespace OpenSim.Region.Framework.Scenes m_timer.Interval = TickDuration; m_timer.AutoReset = true; m_timer.Elapsed += OnTimer; + } - m_timer.Start(); + public void Start() + { + lock (m_timer) + { + if (!m_timer.Enabled) + m_timer.Start(); + } } private void OnTimer(object sender, ElapsedEventArgs ea) @@ -120,6 +127,25 @@ namespace OpenSim.Region.Framework.Scenes { timer = new KeyframeTimer(motion.Scene); m_timers[motion.Scene] = timer; + + if (!SceneManager.Instance.AllRegionsReady) + { + // Start the timers only once all the regions are ready. This is required + // when using megaregions, because the megaregion is correctly configured + // only after all the regions have been loaded. (If we don't do this then + // when the prim moves it might think that it crossed into a region.) + SceneManager.Instance.OnRegionsReadyStatusChange += delegate(SceneManager sm) + { + if (sm.AllRegionsReady) + timer.Start(); + }; + } + + // Check again, in case the regions were started while we were adding the event handler + if (SceneManager.Instance.AllRegionsReady) + { + timer.Start(); + } } }