aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-07-25 21:00:59 +0100
committerJustin Clark-Casey (justincc)2012-07-25 21:00:59 +0100
commit31304c222df1e5a832afd0ebcf7d3ed403543e54 (patch)
treed139e3f34534caa4f31c58503b88bd02a3385d45 /OpenSim/Region
parentRename "image queues clear" console command to "clear image queues" (diff)
downloadopensim-SC_OLD-31304c222df1e5a832afd0ebcf7d3ed403543e54.zip
opensim-SC_OLD-31304c222df1e5a832afd0ebcf7d3ed403543e54.tar.gz
opensim-SC_OLD-31304c222df1e5a832afd0ebcf7d3ed403543e54.tar.bz2
opensim-SC_OLD-31304c222df1e5a832afd0ebcf7d3ed403543e54.tar.xz
Make SceneManager.OnRegionsReadyStatusChange event available.
This is fired when all regions are ready or when at least one region becomes not ready. Recently added EventManager.OnRegionReady becomes OnRegionReadyStatusChange to match OnLoginsEnabledStatusChange
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs11
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs18
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs53
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs2
7 files changed, 79 insertions, 18 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
index 5641804..9d282b8 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
@@ -131,11 +131,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
131 ///<summary> 131 ///<summary>
132 /// 132 ///
133 ///</summary> 133 ///</summary>
134
135
136 ///<summary>
137 ///
138 ///</summary>
139 public void AddRegion(Scene scene) 134 public void AddRegion(Scene scene)
140 { 135 {
141 if (! m_enabled) 136 if (! m_enabled)
@@ -146,7 +141,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
146 lock (m_scenes) 141 lock (m_scenes)
147 m_scenes[scene.RegionInfo.RegionID] = scene; 142 m_scenes[scene.RegionInfo.RegionID] = scene;
148 143
149 scene.EventManager.OnRegionReady += s => UploadMapTile(s); 144 scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) UploadMapTile(s); };
150 } 145 }
151 146
152 ///<summary> 147 ///<summary>
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 620b605..6dea2f0 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -513,8 +513,7 @@ namespace OpenSim.Region.Framework.Scenes
513 /// A region is considered ready when startup operations such as loading of scripts already on the region 513 /// A region is considered ready when startup operations such as loading of scripts already on the region
514 /// have been completed. 514 /// have been completed.
515 /// </remarks> 515 /// </remarks>
516 public event RegionReady OnRegionReady; 516 public event Action<IScene> OnRegionReadyStatusChange;
517 public delegate void RegionReady(IScene scene);
518 517
519 public delegate void PrimsLoaded(Scene s); 518 public delegate void PrimsLoaded(Scene s);
520 public event PrimsLoaded OnPrimsLoaded; 519 public event PrimsLoaded OnPrimsLoaded;
@@ -2508,13 +2507,13 @@ namespace OpenSim.Region.Framework.Scenes
2508 } 2507 }
2509 } 2508 }
2510 2509
2511 public void TriggerRegionReady(IScene scene) 2510 public void TriggerRegionReadyStatusChange(IScene scene)
2512 { 2511 {
2513 RegionReady handler = OnRegionReady; 2512 Action<IScene> handler = OnRegionReadyStatusChange;
2514 2513
2515 if (handler != null) 2514 if (handler != null)
2516 { 2515 {
2517 foreach (RegionReady d in handler.GetInvocationList()) 2516 foreach (Action<IScene> d in handler.GetInvocationList())
2518 { 2517 {
2519 try 2518 try
2520 { 2519 {
@@ -2522,7 +2521,7 @@ namespace OpenSim.Region.Framework.Scenes
2522 } 2521 }
2523 catch (Exception e) 2522 catch (Exception e)
2524 { 2523 {
2525 m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionReady failed - continuing {0} - {1}", 2524 m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionReadyStatusChange failed - continuing {0} - {1}",
2526 e.Message, e.StackTrace); 2525 e.Message, e.StackTrace);
2527 } 2526 }
2528 } 2527 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index ee34338..20918bd 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1499,8 +1499,8 @@ namespace OpenSim.Region.Framework.Scenes
1499 m_sceneGridService.InformNeighborsThatRegionisUp( 1499 m_sceneGridService.InformNeighborsThatRegionisUp(
1500 RequestModuleInterface<INeighbourService>(), RegionInfo); 1500 RequestModuleInterface<INeighbourService>(), RegionInfo);
1501 1501
1502 // Region ready should always be triggered whether logins are immediately enabled or not. 1502 // Region ready should always be set
1503 EventManager.TriggerRegionReady(this); 1503 Ready = true;
1504 } 1504 }
1505 else 1505 else
1506 { 1506 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 282fc5e..b87a38a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -124,6 +124,24 @@ namespace OpenSim.Region.Framework.Scenes
124 } 124 }
125 private bool m_loginsEnabled; 125 private bool m_loginsEnabled;
126 126
127 public bool Ready
128 {
129 get
130 {
131 return m_ready;
132 }
133
134 set
135 {
136 if (m_ready != value)
137 {
138 m_ready = value;
139 EventManager.TriggerRegionReadyStatusChange(this);
140 }
141 }
142 }
143 private bool m_ready;
144
127 public float TimeDilation 145 public float TimeDilation
128 { 146 {
129 get { return 1.0f; } 147 get { return 1.0f; }
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index d73a959..c81b55d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -47,6 +47,48 @@ namespace OpenSim.Region.Framework.Scenes
47 47
48 public event RestartSim OnRestartSim; 48 public event RestartSim OnRestartSim;
49 49
50 /// <summary>
51 /// Fired when either all regions are ready for use or at least one region has become unready for use where
52 /// previously all regions were ready.
53 /// </summary>
54 public event Action<SceneManager> OnRegionsReadyStatusChange;
55
56 /// <summary>
57 /// Are all regions ready for use?
58 /// </summary>
59 public bool AllRegionsReady
60 {
61 get
62 {
63 return m_allRegionsReady;
64 }
65
66 private set
67 {
68 if (m_allRegionsReady != value)
69 {
70 m_allRegionsReady = value;
71 Action<SceneManager> handler = OnRegionsReadyStatusChange;
72 if (handler != null)
73 {
74 foreach (Action<SceneManager> d in handler.GetInvocationList())
75 {
76 try
77 {
78 d(this);
79 }
80 catch (Exception e)
81 {
82 m_log.ErrorFormat("[SCENE MANAGER]: Delegate for OnRegionsReadyStatusChange failed - continuing {0} - {1}",
83 e.Message, e.StackTrace);
84 }
85 }
86 }
87 }
88 }
89 }
90 private bool m_allRegionsReady;
91
50 private static SceneManager m_instance = null; 92 private static SceneManager m_instance = null;
51 public static SceneManager Instance 93 public static SceneManager Instance
52 { 94 {
@@ -141,10 +183,11 @@ namespace OpenSim.Region.Framework.Scenes
141 183
142 public void Add(Scene scene) 184 public void Add(Scene scene)
143 { 185 {
144 scene.OnRestart += HandleRestart;
145
146 lock (m_localScenes) 186 lock (m_localScenes)
147 m_localScenes.Add(scene); 187 m_localScenes.Add(scene);
188
189 scene.OnRestart += HandleRestart;
190 scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange;
148 } 191 }
149 192
150 public void HandleRestart(RegionInfo rdata) 193 public void HandleRestart(RegionInfo rdata)
@@ -175,6 +218,12 @@ namespace OpenSim.Region.Framework.Scenes
175 OnRestartSim(rdata); 218 OnRestartSim(rdata);
176 } 219 }
177 220
221 private void HandleRegionReadyStatusChange(IScene scene)
222 {
223 lock (m_localScenes)
224 AllRegionsReady = m_localScenes.TrueForAll(s => s.Ready);
225 }
226
178 public void SendSimOnlineNotification(ulong regionHandle) 227 public void SendSimOnlineNotification(ulong regionHandle)
179 { 228 {
180 RegionInfo Result = null; 229 RegionInfo Result = null;
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
index f459b8c..fff3a32 100644
--- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
@@ -225,7 +225,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
225 RRAlert("enabled"); 225 RRAlert("enabled");
226 } 226 }
227 227
228 m_scene.EventManager.TriggerRegionReady(m_scene); 228 m_scene.Ready = true;
229 } 229 }
230 230
231 public void OarLoadingAlert(string msg) 231 public void OarLoadingAlert(string msg)
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index da344d6..2dba029 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -646,7 +646,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
646 646
647 // If region ready has been triggered, then the region had no scripts to compile and completed its other 647 // If region ready has been triggered, then the region had no scripts to compile and completed its other
648 // work. 648 // work.
649 m_Scene.EventManager.OnRegionReady += s => m_InitialStartup = false; 649 m_Scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) m_InitialStartup = false; };
650 650
651 if (m_SleepTime > 0) 651 if (m_SleepTime > 0)
652 { 652 {