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