aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneManager.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs53
1 files changed, 30 insertions, 23 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index 9bd27d3..1e2e973 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -100,23 +100,25 @@ namespace OpenSim.Region.Framework.Scenes
100 } 100 }
101 101
102 private readonly List<Scene> m_localScenes = new List<Scene>(); 102 private readonly List<Scene> m_localScenes = new List<Scene>();
103 private Scene m_currentScene = null;
104 103
105 public List<Scene> Scenes 104 public List<Scene> Scenes
106 { 105 {
107 get { return new List<Scene>(m_localScenes); } 106 get { return new List<Scene>(m_localScenes); }
108 } 107 }
109 108
110 public Scene CurrentScene 109 /// <summary>
111 { 110 /// Scene selected from the console.
112 get { return m_currentScene; } 111 /// </summary>
113 } 112 /// <value>
113 /// If null, then all scenes are considered selected (signalled as "Root" on the console).
114 /// </value>
115 public Scene CurrentScene { get; private set; }
114 116
115 public Scene CurrentOrFirstScene 117 public Scene CurrentOrFirstScene
116 { 118 {
117 get 119 get
118 { 120 {
119 if (m_currentScene == null) 121 if (CurrentScene == null)
120 { 122 {
121 lock (m_localScenes) 123 lock (m_localScenes)
122 { 124 {
@@ -128,7 +130,7 @@ namespace OpenSim.Region.Framework.Scenes
128 } 130 }
129 else 131 else
130 { 132 {
131 return m_currentScene; 133 return CurrentScene;
132 } 134 }
133 } 135 }
134 } 136 }
@@ -141,6 +143,13 @@ namespace OpenSim.Region.Framework.Scenes
141 143
142 public void Close() 144 public void Close()
143 { 145 {
146 lock (m_localScenes)
147 {
148 for (int i = 0; i < m_localScenes.Count; i++)
149 {
150 m_localScenes[i].Close();
151 }
152 }
144 } 153 }
145 154
146 public void Close(Scene cscene) 155 public void Close(Scene cscene)
@@ -171,8 +180,7 @@ namespace OpenSim.Region.Framework.Scenes
171 180
172 public void HandleRestart(RegionInfo rdata) 181 public void HandleRestart(RegionInfo rdata)
173 { 182 {
174 m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main"); 183 Scene restartedScene = null;
175 int RegionSceneElement = -1;
176 184
177 lock (m_localScenes) 185 lock (m_localScenes)
178 { 186 {
@@ -180,19 +188,18 @@ namespace OpenSim.Region.Framework.Scenes
180 { 188 {
181 if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) 189 if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName)
182 { 190 {
183 RegionSceneElement = i; 191 restartedScene = m_localScenes[i];
192 m_localScenes.RemoveAt(i);
193 break;
184 } 194 }
185 } 195 }
186
187 // Now we make sure the region is no longer known about by the SceneManager
188 // Prevents duplicates.
189
190 if (RegionSceneElement >= 0)
191 {
192 m_localScenes.RemoveAt(RegionSceneElement);
193 }
194 } 196 }
195 197
198 // If the currently selected scene has been restarted, then we can't reselect here since we the scene
199 // hasn't yet been recreated. We will have to leave this to the caller.
200 if (CurrentScene == restartedScene)
201 CurrentScene = null;
202
196 // Send signal to main that we're restarting this sim. 203 // Send signal to main that we're restarting this sim.
197 OnRestartSim(rdata); 204 OnRestartSim(rdata);
198 } 205 }
@@ -334,14 +341,14 @@ namespace OpenSim.Region.Framework.Scenes
334 341
335 private void ForEachCurrentScene(Action<Scene> func) 342 private void ForEachCurrentScene(Action<Scene> func)
336 { 343 {
337 if (m_currentScene == null) 344 if (CurrentScene == null)
338 { 345 {
339 lock (m_localScenes) 346 lock (m_localScenes)
340 m_localScenes.ForEach(func); 347 m_localScenes.ForEach(func);
341 } 348 }
342 else 349 else
343 { 350 {
344 func(m_currentScene); 351 func(CurrentScene);
345 } 352 }
346 } 353 }
347 354
@@ -361,7 +368,7 @@ namespace OpenSim.Region.Framework.Scenes
361 || (String.Compare(regionName, "..") == 0) 368 || (String.Compare(regionName, "..") == 0)
362 || (String.Compare(regionName, "/") == 0)) 369 || (String.Compare(regionName, "/") == 0))
363 { 370 {
364 m_currentScene = null; 371 CurrentScene = null;
365 return true; 372 return true;
366 } 373 }
367 else 374 else
@@ -372,7 +379,7 @@ namespace OpenSim.Region.Framework.Scenes
372 { 379 {
373 if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) 380 if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0)
374 { 381 {
375 m_currentScene = scene; 382 CurrentScene = scene;
376 return true; 383 return true;
377 } 384 }
378 } 385 }
@@ -392,7 +399,7 @@ namespace OpenSim.Region.Framework.Scenes
392 { 399 {
393 if (scene.RegionInfo.RegionID == regionID) 400 if (scene.RegionInfo.RegionID == regionID)
394 { 401 {
395 m_currentScene = scene; 402 CurrentScene = scene;
396 return true; 403 return true;
397 } 404 }
398 } 405 }