aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/SceneManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneManager.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneManager.cs500
1 files changed, 250 insertions, 250 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs
index 0049282..89f60d1 100644
--- a/OpenSim/Region/Environment/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs
@@ -1,251 +1,251 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using OpenSim.Framework.Console; 3using OpenSim.Framework.Console;
4using OpenSim.Framework.Types; 4using OpenSim.Framework.Types;
5using libsecondlife; 5using libsecondlife;
6 6
7namespace OpenSim.Region.Environment.Scenes 7namespace OpenSim.Region.Environment.Scenes
8{ 8{
9 public class SceneManager 9 public class SceneManager
10 { 10 {
11 private readonly List<Scene> m_localScenes; 11 private readonly List<Scene> m_localScenes;
12 private Scene m_currentScene = null; 12 private Scene m_currentScene = null;
13 13
14 public Scene CurrentScene 14 public Scene CurrentScene
15 { 15 {
16 get { return m_currentScene; } 16 get { return m_currentScene; }
17 } 17 }
18 18
19 public Scene CurrentOrFirstScene 19 public Scene CurrentOrFirstScene
20 { 20 {
21 get 21 get
22 { 22 {
23 if (m_currentScene == null) 23 if (m_currentScene == null)
24 { 24 {
25 return m_localScenes[0]; 25 return m_localScenes[0];
26 } 26 }
27 else 27 else
28 { 28 {
29 return m_currentScene; 29 return m_currentScene;
30 } 30 }
31 } 31 }
32 } 32 }
33 33
34 public SceneManager() 34 public SceneManager()
35 { 35 {
36 m_localScenes = new List<Scene>(); 36 m_localScenes = new List<Scene>();
37 } 37 }
38 38
39 public void Close() 39 public void Close()
40 { 40 {
41 for (int i = 0; i < m_localScenes.Count; i++) 41 for (int i = 0; i < m_localScenes.Count; i++)
42 { 42 {
43 m_localScenes[i].Close(); 43 m_localScenes[i].Close();
44 } 44 }
45 } 45 }
46 46
47 public void Add(Scene scene) 47 public void Add(Scene scene)
48 { 48 {
49 m_localScenes.Add(scene); 49 m_localScenes.Add(scene);
50 } 50 }
51 51
52 public void SaveCurrentSceneToXml(string filename) 52 public void SaveCurrentSceneToXml(string filename)
53 { 53 {
54 CurrentOrFirstScene.SavePrimsToXml(filename); 54 CurrentOrFirstScene.SavePrimsToXml(filename);
55 } 55 }
56 56
57 public void LoadCurrentSceneFromXml(string filename) 57 public void LoadCurrentSceneFromXml(string filename)
58 { 58 {
59 CurrentOrFirstScene.LoadPrimsFromXml(filename); 59 CurrentOrFirstScene.LoadPrimsFromXml(filename);
60 } 60 }
61 61
62 public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result) 62 public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result)
63 { 63 {
64 if (m_currentScene == null) 64 if (m_currentScene == null)
65 { 65 {
66 bool success = true; 66 bool success = true;
67 foreach (Scene scene in m_localScenes) 67 foreach (Scene scene in m_localScenes)
68 { 68 {
69 if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName)) 69 if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName))
70 { 70 {
71 success = false; 71 success = false;
72 } 72 }
73 } 73 }
74 74
75 return success; 75 return success;
76 } 76 }
77 else 77 else
78 { 78 {
79 return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName); 79 return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName);
80 } 80 }
81 } 81 }
82 82
83 public void SendCommandToCurrentSceneScripts(string[] cmdparams) 83 public void SendCommandToCurrentSceneScripts(string[] cmdparams)
84 { 84 {
85 ForEachCurrentScene(delegate(Scene scene) { scene.SendCommandToPlugins(cmdparams); }); 85 ForEachCurrentScene(delegate(Scene scene) { scene.SendCommandToPlugins(cmdparams); });
86 } 86 }
87 87
88 public void SetBypassPermissionsOnCurrentScene(bool bypassPermissions) 88 public void SetBypassPermissionsOnCurrentScene(bool bypassPermissions)
89 { 89 {
90 ForEachCurrentScene(delegate(Scene scene) { scene.PermissionsMngr.BypassPermissions = bypassPermissions; }); 90 ForEachCurrentScene(delegate(Scene scene) { scene.PermissionsMngr.BypassPermissions = bypassPermissions; });
91 } 91 }
92 92
93 private void ForEachCurrentScene(Action<Scene> func) 93 private void ForEachCurrentScene(Action<Scene> func)
94 { 94 {
95 if (m_currentScene == null) 95 if (m_currentScene == null)
96 { 96 {
97 m_localScenes.ForEach(func); 97 m_localScenes.ForEach(func);
98 } 98 }
99 else 99 else
100 { 100 {
101 func(m_currentScene); 101 func(m_currentScene);
102 } 102 }
103 } 103 }
104 104
105 public void BackupCurrentScene() 105 public void BackupCurrentScene()
106 { 106 {
107 ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); }); 107 ForEachCurrentScene(delegate(Scene scene) { scene.Backup(); });
108 } 108 }
109 109
110 public void HandleAlertCommandOnCurrentScene(string[] cmdparams) 110 public void HandleAlertCommandOnCurrentScene(string[] cmdparams)
111 { 111 {
112 ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); }); 112 ForEachCurrentScene(delegate(Scene scene) { scene.HandleAlertCommand(cmdparams); });
113 } 113 }
114 114
115 public bool TrySetCurrentScene(string regionName) 115 public bool TrySetCurrentScene(string regionName)
116 { 116 {
117 if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0)) 117 if ((String.Compare(regionName, "root") == 0) || (String.Compare(regionName, "..") == 0))
118 { 118 {
119 m_currentScene = null; 119 m_currentScene = null;
120 return true; 120 return true;
121 } 121 }
122 else 122 else
123 { 123 {
124 Console.WriteLine("Searching for Region: '" + regionName + "'"); 124 Console.WriteLine("Searching for Region: '" + regionName + "'");
125 125
126 foreach (Scene scene in m_localScenes) 126 foreach (Scene scene in m_localScenes)
127 { 127 {
128 if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) 128 if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0)
129 { 129 {
130 m_currentScene = scene; 130 m_currentScene = scene;
131 return true; 131 return true;
132 } 132 }
133 } 133 }
134 134
135 return false; 135 return false;
136 } 136 }
137 } 137 }
138 138
139 public void SetDebugPacketOnCurrentScene(LogBase log, int newDebug) 139 public void SetDebugPacketOnCurrentScene(LogBase log, int newDebug)
140 { 140 {
141 ForEachCurrentScene(delegate(Scene scene) 141 ForEachCurrentScene(delegate(Scene scene)
142 { 142 {
143 foreach (EntityBase entity in scene.Entities.Values) 143 foreach (EntityBase entity in scene.Entities.Values)
144 { 144 {
145 if (entity is ScenePresence) 145 if (entity is ScenePresence)
146 { 146 {
147 ScenePresence scenePrescence = entity as ScenePresence; 147 ScenePresence scenePrescence = entity as ScenePresence;
148 if (!scenePrescence.IsChildAgent) 148 if (!scenePrescence.IsChildAgent)
149 { 149 {
150 log.Error(String.Format("Packet debug for {0} {1} set to {2}", 150 log.Error(String.Format("Packet debug for {0} {1} set to {2}",
151 scenePrescence.Firstname, scenePrescence.Lastname, 151 scenePrescence.Firstname, scenePrescence.Lastname,
152 newDebug)); 152 newDebug));
153 153
154 scenePrescence.ControllingClient.SetDebug(newDebug); 154 scenePrescence.ControllingClient.SetDebug(newDebug);
155 } 155 }
156 } 156 }
157 } 157 }
158 }); 158 });
159 } 159 }
160 160
161 public List<ScenePresence> GetCurrentSceneAvatars() 161 public List<ScenePresence> GetCurrentSceneAvatars()
162 { 162 {
163 List<ScenePresence> avatars = new List<ScenePresence>(); 163 List<ScenePresence> avatars = new List<ScenePresence>();
164 164
165 ForEachCurrentScene(delegate(Scene scene) 165 ForEachCurrentScene(delegate(Scene scene)
166 { 166 {
167 foreach (EntityBase entity in scene.Entities.Values) 167 foreach (EntityBase entity in scene.Entities.Values)
168 { 168 {
169 if (entity is ScenePresence) 169 if (entity is ScenePresence)
170 { 170 {
171 ScenePresence scenePrescence = entity as ScenePresence; 171 ScenePresence scenePrescence = entity as ScenePresence;
172 if (!scenePrescence.IsChildAgent) 172 if (!scenePrescence.IsChildAgent)
173 { 173 {
174 avatars.Add(scenePrescence); 174 avatars.Add(scenePrescence);
175 } 175 }
176 } 176 }
177 } 177 }
178 }); 178 });
179 179
180 return avatars; 180 return avatars;
181 } 181 }
182 182
183 public RegionInfo GetRegionInfo(ulong regionHandle) 183 public RegionInfo GetRegionInfo(ulong regionHandle)
184 { 184 {
185 foreach (Scene scene in m_localScenes) 185 foreach (Scene scene in m_localScenes)
186 { 186 {
187 if (scene.RegionInfo.RegionHandle == regionHandle) 187 if (scene.RegionInfo.RegionHandle == regionHandle)
188 { 188 {
189 return scene.RegionInfo; 189 return scene.RegionInfo;
190 } 190 }
191 } 191 }
192 192
193 return null; 193 return null;
194 } 194 }
195 195
196 public void SetCurrentSceneTimePhase(int timePhase) 196 public void SetCurrentSceneTimePhase(int timePhase)
197 { 197 {
198 ForEachCurrentScene(delegate(Scene scene) 198 ForEachCurrentScene(delegate(Scene scene)
199 { 199 {
200 scene.SetTimePhase( 200 scene.SetTimePhase(
201 timePhase) 201 timePhase)
202 ; 202 ;
203 }); 203 });
204 } 204 }
205 205
206 206
207 public void ForceCurrentSceneClientUpdate() 207 public void ForceCurrentSceneClientUpdate()
208 { 208 {
209 ForEachCurrentScene(delegate(Scene scene) { scene.ForceClientUpdate(); }); 209 ForEachCurrentScene(delegate(Scene scene) { scene.ForceClientUpdate(); });
210 } 210 }
211 211
212 public void HandleEditCommandOnCurrentScene(string[] cmdparams) 212 public void HandleEditCommandOnCurrentScene(string[] cmdparams)
213 { 213 {
214 ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); }); 214 ForEachCurrentScene(delegate(Scene scene) { scene.HandleEditCommand(cmdparams); });
215 } 215 }
216 216
217 public bool TryGetAvatar( LLUUID avatarId, out ScenePresence avatar ) 217 public bool TryGetAvatar( LLUUID avatarId, out ScenePresence avatar )
218 { 218 {
219 foreach (Scene scene in m_localScenes) 219 foreach (Scene scene in m_localScenes)
220 { 220 {
221 if( scene.TryGetAvatar( avatarId, out avatar )) 221 if( scene.TryGetAvatar( avatarId, out avatar ))
222 { 222 {
223 return true; 223 return true;
224 } 224 }
225 } 225 }
226 226
227 avatar = null; 227 avatar = null;
228 return false; 228 return false;
229 } 229 }
230 230
231 public void CloseScene(Scene scene) 231 public void CloseScene(Scene scene)
232 { 232 {
233 m_localScenes.Remove(scene); 233 m_localScenes.Remove(scene);
234 scene.Close(); 234 scene.Close();
235 } 235 }
236 236
237 public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) 237 public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
238 { 238 {
239 foreach (Scene scene in m_localScenes) 239 foreach (Scene scene in m_localScenes)
240 { 240 {
241 if (scene.TryGetAvatarByName(avatarName, out avatar)) 241 if (scene.TryGetAvatarByName(avatarName, out avatar))
242 { 242 {
243 return true; 243 return true;
244 } 244 }
245 } 245 }
246 246
247 avatar = null; 247 avatar = null;
248 return false; 248 return false;
249 } 249 }
250 } 250 }
251} \ No newline at end of file 251} \ No newline at end of file