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.cs62
1 files changed, 31 insertions, 31 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index f1b09ca..0e0b6c3 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -92,7 +92,11 @@ namespace OpenSim.Region.Framework.Scenes
92 private static SceneManager m_instance = null; 92 private static SceneManager m_instance = null;
93 public static SceneManager Instance 93 public static SceneManager Instance
94 { 94 {
95 get { return m_instance; } 95 get {
96 if (m_instance == null)
97 m_instance = new SceneManager();
98 return m_instance;
99 }
96 } 100 }
97 101
98 private readonly DoubleDictionary<UUID, string, Scene> m_localScenes = new DoubleDictionary<UUID, string, Scene>(); 102 private readonly DoubleDictionary<UUID, string, Scene> m_localScenes = new DoubleDictionary<UUID, string, Scene>();
@@ -103,16 +107,19 @@ namespace OpenSim.Region.Framework.Scenes
103 get { return new List<Scene>(m_localScenes.FindAll(delegate(Scene s) { return true; })); } 107 get { return new List<Scene>(m_localScenes.FindAll(delegate(Scene s) { return true; })); }
104 } 108 }
105 109
106 public Scene CurrentScene 110 /// <summary>
107 { 111 /// Scene selected from the console.
108 get { return m_currentScene; } 112 /// </summary>
109 } 113 /// <value>
114 /// If null, then all scenes are considered selected (signalled as "Root" on the console).
115 /// </value>
116 public Scene CurrentScene { get; private set; }
110 117
111 public Scene CurrentOrFirstScene 118 public Scene CurrentOrFirstScene
112 { 119 {
113 get 120 get
114 { 121 {
115 if (m_currentScene == null) 122 if (CurrentScene == null)
116 { 123 {
117 List<Scene> sceneList = Scenes; 124 List<Scene> sceneList = Scenes;
118 if (sceneList.Count == 0) 125 if (sceneList.Count == 0)
@@ -121,7 +128,7 @@ namespace OpenSim.Region.Framework.Scenes
121 } 128 }
122 else 129 else
123 { 130 {
124 return m_currentScene; 131 return CurrentScene;
125 } 132 }
126 } 133 }
127 } 134 }
@@ -134,31 +141,17 @@ namespace OpenSim.Region.Framework.Scenes
134 141
135 public void Close() 142 public void Close()
136 { 143 {
137 // collect known shared modules in sharedModules 144 List<Scene> localScenes = null;
138 Dictionary<string, IRegionModule> sharedModules = new Dictionary<string, IRegionModule>();
139 145
140 List<Scene> sceneList = Scenes; 146 lock (m_localScenes)
141 for (int i = 0; i < sceneList.Count; i++)
142 { 147 {
143 // extract known shared modules from scene 148 localScenes = Scenes;
144 foreach (string k in sceneList[i].Modules.Keys)
145 {
146 if (sceneList[i].Modules[k].IsSharedModule &&
147 !sharedModules.ContainsKey(k))
148 sharedModules[k] = sceneList[i].Modules[k];
149 }
150 // close scene/region
151 sceneList[i].Close();
152 } 149 }
153 150
154 // all regions/scenes are now closed, we can now safely 151 for (int i = 0; i < localScenes.Count; i++)
155 // close all shared modules
156 foreach (IRegionModule mod in sharedModules.Values)
157 { 152 {
158 mod.Close(); 153 localScenes[i].Close();
159 } 154 }
160
161 m_localScenes.Clear();
162 } 155 }
163 156
164 public void Close(Scene cscene) 157 public void Close(Scene cscene)
@@ -179,11 +172,18 @@ namespace OpenSim.Region.Framework.Scenes
179 172
180 public void HandleRestart(RegionInfo rdata) 173 public void HandleRestart(RegionInfo rdata)
181 { 174 {
182 m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main"); 175 Scene restartedScene = null;
183 int RegionSceneElement = -1;
184 176
185 lock (m_localScenes) 177 lock (m_localScenes)
178 {
179 m_localScenes.TryGetValue(rdata.RegionID, out restartedScene);
186 m_localScenes.Remove(rdata.RegionID); 180 m_localScenes.Remove(rdata.RegionID);
181 }
182
183 // If the currently selected scene has been restarted, then we can't reselect here since we the scene
184 // hasn't yet been recreated. We will have to leave this to the caller.
185 if (CurrentScene == restartedScene)
186 CurrentScene = null;
187 187
188 // Send signal to main that we're restarting this sim. 188 // Send signal to main that we're restarting this sim.
189 OnRestartSim(rdata); 189 OnRestartSim(rdata);
@@ -323,14 +323,14 @@ namespace OpenSim.Region.Framework.Scenes
323 323
324 private void ForEachCurrentScene(Action<Scene> func) 324 private void ForEachCurrentScene(Action<Scene> func)
325 { 325 {
326 if (m_currentScene == null) 326 if (CurrentScene == null)
327 { 327 {
328 List<Scene> sceneList = Scenes; 328 List<Scene> sceneList = Scenes;
329 sceneList.ForEach(func); 329 sceneList.ForEach(func);
330 } 330 }
331 else 331 else
332 { 332 {
333 func(m_currentScene); 333 func(CurrentScene);
334 } 334 }
335 } 335 }
336 336
@@ -350,7 +350,7 @@ namespace OpenSim.Region.Framework.Scenes
350 || (String.Compare(regionName, "..") == 0) 350 || (String.Compare(regionName, "..") == 0)
351 || (String.Compare(regionName, "/") == 0)) 351 || (String.Compare(regionName, "/") == 0))
352 { 352 {
353 m_currentScene = null; 353 CurrentScene = null;
354 return true; 354 return true;
355 } 355 }
356 else 356 else