diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneManager.cs | 64 |
1 files changed, 23 insertions, 41 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index cb5b2ba..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,31 +143,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
141 | 143 | ||
142 | public void Close() | 144 | public void Close() |
143 | { | 145 | { |
144 | // collect known shared modules in sharedModules | ||
145 | Dictionary<string, IRegionModule> sharedModules = new Dictionary<string, IRegionModule>(); | ||
146 | |||
147 | lock (m_localScenes) | 146 | lock (m_localScenes) |
148 | { | 147 | { |
149 | for (int i = 0; i < m_localScenes.Count; i++) | 148 | for (int i = 0; i < m_localScenes.Count; i++) |
150 | { | 149 | { |
151 | // extract known shared modules from scene | ||
152 | foreach (string k in m_localScenes[i].Modules.Keys) | ||
153 | { | ||
154 | if (m_localScenes[i].Modules[k].IsSharedModule && | ||
155 | !sharedModules.ContainsKey(k)) | ||
156 | sharedModules[k] = m_localScenes[i].Modules[k]; | ||
157 | } | ||
158 | // close scene/region | ||
159 | m_localScenes[i].Close(); | 150 | m_localScenes[i].Close(); |
160 | } | 151 | } |
161 | } | 152 | } |
162 | |||
163 | // all regions/scenes are now closed, we can now safely | ||
164 | // close all shared modules | ||
165 | foreach (IRegionModule mod in sharedModules.Values) | ||
166 | { | ||
167 | mod.Close(); | ||
168 | } | ||
169 | } | 153 | } |
170 | 154 | ||
171 | public void Close(Scene cscene) | 155 | public void Close(Scene cscene) |
@@ -196,8 +180,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
196 | 180 | ||
197 | public void HandleRestart(RegionInfo rdata) | 181 | public void HandleRestart(RegionInfo rdata) |
198 | { | 182 | { |
199 | m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main"); | 183 | Scene restartedScene = null; |
200 | int RegionSceneElement = -1; | ||
201 | 184 | ||
202 | lock (m_localScenes) | 185 | lock (m_localScenes) |
203 | { | 186 | { |
@@ -205,19 +188,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
205 | { | 188 | { |
206 | if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) | 189 | if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) |
207 | { | 190 | { |
208 | RegionSceneElement = i; | 191 | restartedScene = m_localScenes[i]; |
192 | m_localScenes.RemoveAt(i); | ||
193 | break; | ||
209 | } | 194 | } |
210 | } | 195 | } |
211 | |||
212 | // Now we make sure the region is no longer known about by the SceneManager | ||
213 | // Prevents duplicates. | ||
214 | |||
215 | if (RegionSceneElement >= 0) | ||
216 | { | ||
217 | m_localScenes.RemoveAt(RegionSceneElement); | ||
218 | } | ||
219 | } | 196 | } |
220 | 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 | |||
221 | // Send signal to main that we're restarting this sim. | 203 | // Send signal to main that we're restarting this sim. |
222 | OnRestartSim(rdata); | 204 | OnRestartSim(rdata); |
223 | } | 205 | } |
@@ -359,14 +341,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
359 | 341 | ||
360 | private void ForEachCurrentScene(Action<Scene> func) | 342 | private void ForEachCurrentScene(Action<Scene> func) |
361 | { | 343 | { |
362 | if (m_currentScene == null) | 344 | if (CurrentScene == null) |
363 | { | 345 | { |
364 | lock (m_localScenes) | 346 | lock (m_localScenes) |
365 | m_localScenes.ForEach(func); | 347 | m_localScenes.ForEach(func); |
366 | } | 348 | } |
367 | else | 349 | else |
368 | { | 350 | { |
369 | func(m_currentScene); | 351 | func(CurrentScene); |
370 | } | 352 | } |
371 | } | 353 | } |
372 | 354 | ||
@@ -386,7 +368,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
386 | || (String.Compare(regionName, "..") == 0) | 368 | || (String.Compare(regionName, "..") == 0) |
387 | || (String.Compare(regionName, "/") == 0)) | 369 | || (String.Compare(regionName, "/") == 0)) |
388 | { | 370 | { |
389 | m_currentScene = null; | 371 | CurrentScene = null; |
390 | return true; | 372 | return true; |
391 | } | 373 | } |
392 | else | 374 | else |
@@ -397,7 +379,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
397 | { | 379 | { |
398 | if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) | 380 | if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) |
399 | { | 381 | { |
400 | m_currentScene = scene; | 382 | CurrentScene = scene; |
401 | return true; | 383 | return true; |
402 | } | 384 | } |
403 | } | 385 | } |
@@ -417,7 +399,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
417 | { | 399 | { |
418 | if (scene.RegionInfo.RegionID == regionID) | 400 | if (scene.RegionInfo.RegionID == regionID) |
419 | { | 401 | { |
420 | m_currentScene = scene; | 402 | CurrentScene = scene; |
421 | return true; | 403 | return true; |
422 | } | 404 | } |
423 | } | 405 | } |