diff options
Switched in NameSpaceChanges
Diffstat (limited to 'OpenSim/Framework/General/Types/RegionInfo.cs')
-rw-r--r-- | OpenSim/Framework/General/Types/RegionInfo.cs | 304 |
1 files changed, 304 insertions, 0 deletions
diff --git a/OpenSim/Framework/General/Types/RegionInfo.cs b/OpenSim/Framework/General/Types/RegionInfo.cs new file mode 100644 index 0000000..0fba6ca --- /dev/null +++ b/OpenSim/Framework/General/Types/RegionInfo.cs | |||
@@ -0,0 +1,304 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using System.Globalization; | ||
32 | using OpenSim.Framework.Interfaces; | ||
33 | using OpenSim.Framework.Utilities; | ||
34 | using OpenSim.Framework.Console; | ||
35 | using libsecondlife; | ||
36 | |||
37 | namespace OpenSim.Framework.Types | ||
38 | { | ||
39 | public class RegionInfo | ||
40 | { | ||
41 | public LLUUID SimUUID = new LLUUID(); | ||
42 | public string RegionName = ""; | ||
43 | public uint RegionLocX = 0; | ||
44 | public uint RegionLocY = 0; | ||
45 | public ulong RegionHandle = 0; | ||
46 | |||
47 | public string DataStore = ""; | ||
48 | public bool isSandbox = false; | ||
49 | |||
50 | public LLUUID MasterAvatarAssignedUUID = new LLUUID(); | ||
51 | public string MasterAvatarFirstName = ""; | ||
52 | public string MasterAvatarLastName = ""; | ||
53 | public string MasterAvatarSandboxPassword = ""; | ||
54 | |||
55 | /// <summary> | ||
56 | /// Port used for listening (TCP and UDP) | ||
57 | /// </summary> | ||
58 | /// <remarks>Seperate TCP and UDP</remarks> | ||
59 | public int CommsIPListenPort = 0; | ||
60 | /// <summary> | ||
61 | /// Address used for internal listening (default: 0.0.0.0?) | ||
62 | /// </summary> | ||
63 | public string CommsIPListenAddr = ""; | ||
64 | /// <summary> | ||
65 | /// Address used for external addressing (DNS or IP) | ||
66 | /// </summary> | ||
67 | public string CommsExternalAddress = ""; | ||
68 | |||
69 | |||
70 | public EstateSettings estateSettings; | ||
71 | |||
72 | public RegionInfo() | ||
73 | { | ||
74 | estateSettings = new EstateSettings(); | ||
75 | } | ||
76 | |||
77 | |||
78 | public void InitConfig(bool sandboxMode, IGenericConfig configData) | ||
79 | { | ||
80 | this.isSandbox = sandboxMode; | ||
81 | try | ||
82 | { | ||
83 | // Sim UUID | ||
84 | string attri = ""; | ||
85 | attri = configData.GetAttribute("SimUUID"); | ||
86 | if (attri == "") | ||
87 | { | ||
88 | this.SimUUID = LLUUID.Random(); | ||
89 | configData.SetAttribute("SimUUID", this.SimUUID.ToString()); | ||
90 | } | ||
91 | else | ||
92 | { | ||
93 | this.SimUUID = new LLUUID(attri); | ||
94 | } | ||
95 | |||
96 | // Sim name | ||
97 | attri = ""; | ||
98 | attri = configData.GetAttribute("SimName"); | ||
99 | if (attri == "") | ||
100 | { | ||
101 | this.RegionName = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("Name", "OpenSim test"); | ||
102 | configData.SetAttribute("SimName", this.RegionName); | ||
103 | } | ||
104 | else | ||
105 | { | ||
106 | this.RegionName = attri; | ||
107 | } | ||
108 | // Sim/Grid location X | ||
109 | attri = ""; | ||
110 | attri = configData.GetAttribute("SimLocationX"); | ||
111 | if (attri == "") | ||
112 | { | ||
113 | string location = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("Grid Location X", "1000"); | ||
114 | configData.SetAttribute("SimLocationX", location); | ||
115 | this.RegionLocX = (uint)Convert.ToUInt32(location); | ||
116 | } | ||
117 | else | ||
118 | { | ||
119 | this.RegionLocX = (uint)Convert.ToUInt32(attri); | ||
120 | } | ||
121 | // Sim/Grid location Y | ||
122 | attri = ""; | ||
123 | attri = configData.GetAttribute("SimLocationY"); | ||
124 | if (attri == "") | ||
125 | { | ||
126 | string location = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("Grid Location Y", "1000"); | ||
127 | configData.SetAttribute("SimLocationY", location); | ||
128 | this.RegionLocY = (uint)Convert.ToUInt32(location); | ||
129 | } | ||
130 | else | ||
131 | { | ||
132 | this.RegionLocY = (uint)Convert.ToUInt32(attri); | ||
133 | } | ||
134 | |||
135 | // Local storage datastore | ||
136 | attri = ""; | ||
137 | attri = configData.GetAttribute("Datastore"); | ||
138 | if (attri == "") | ||
139 | { | ||
140 | string datastore = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("Filename for local storage", "localworld.yap"); | ||
141 | configData.SetAttribute("Datastore", datastore); | ||
142 | this.DataStore = datastore; | ||
143 | } | ||
144 | else | ||
145 | { | ||
146 | this.DataStore = attri; | ||
147 | } | ||
148 | |||
149 | //Sim Listen Port | ||
150 | attri = ""; | ||
151 | attri = configData.GetAttribute("SimListenPort"); | ||
152 | if (attri == "") | ||
153 | { | ||
154 | string port = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("UDP port for client connections", "9000"); | ||
155 | configData.SetAttribute("SimListenPort", port); | ||
156 | this.CommsIPListenPort = Convert.ToInt32(port); | ||
157 | } | ||
158 | else | ||
159 | { | ||
160 | this.CommsIPListenPort = Convert.ToInt32(attri); | ||
161 | } | ||
162 | |||
163 | //Sim Listen Address | ||
164 | attri = ""; | ||
165 | attri = configData.GetAttribute("SimListenAddress"); | ||
166 | if (attri == "") | ||
167 | { | ||
168 | this.CommsIPListenAddr = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("IP Address to listen on for client connections", "0.0.0.0"); | ||
169 | configData.SetAttribute("SimListenAddress", this.CommsIPListenAddr); | ||
170 | } | ||
171 | else | ||
172 | { | ||
173 | // Probably belongs elsewhere, but oh well. | ||
174 | if (attri.Trim().StartsWith("SYSTEMIP")) | ||
175 | { | ||
176 | string localhostname = System.Net.Dns.GetHostName(); | ||
177 | System.Net.IPAddress[] ips = System.Net.Dns.GetHostAddresses(localhostname); | ||
178 | try | ||
179 | { | ||
180 | this.CommsIPListenAddr = "0.0.0.0"; // Incase a IPv4 address isnt found | ||
181 | |||
182 | foreach (System.Net.IPAddress ip in ips) | ||
183 | { | ||
184 | if (ip.AddressFamily.ToString() == System.Net.Sockets.ProtocolFamily.InterNetwork.ToString()) | ||
185 | { | ||
186 | this.CommsIPListenAddr = ip.ToString(); | ||
187 | break; | ||
188 | } | ||
189 | } | ||
190 | } | ||
191 | catch (Exception e) | ||
192 | { | ||
193 | e.ToString(); | ||
194 | this.CommsIPListenAddr = "0.0.0.0"; // Use the default if we fail | ||
195 | } | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | this.CommsIPListenAddr = attri; | ||
200 | } | ||
201 | } | ||
202 | |||
203 | // Sim External Address | ||
204 | attri = ""; | ||
205 | attri = configData.GetAttribute("SimExternalAddress"); | ||
206 | if (attri == "") | ||
207 | { | ||
208 | this.CommsExternalAddress = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("IP or DNS address to send external clients to", "localhost"); | ||
209 | configData.SetAttribute("SimExternalAddress", this.CommsExternalAddress); | ||
210 | } | ||
211 | else | ||
212 | { | ||
213 | this.CommsExternalAddress = attri; | ||
214 | } | ||
215 | |||
216 | attri = ""; | ||
217 | attri = configData.GetAttribute("TerrainFile"); | ||
218 | if (attri == "") | ||
219 | { | ||
220 | this.estateSettings.terrainFile = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("GENERAL SETTING: Default Terrain File", "default.r32"); | ||
221 | configData.SetAttribute("TerrainFile", this.estateSettings.terrainFile); | ||
222 | } | ||
223 | else | ||
224 | { | ||
225 | this.estateSettings.terrainFile = attri; | ||
226 | } | ||
227 | |||
228 | attri = ""; | ||
229 | attri = configData.GetAttribute("TerrainMultiplier"); | ||
230 | if (attri == "") | ||
231 | { | ||
232 | string re = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("GENERAL SETTING: Terrain Height Multiplier", "60.0"); | ||
233 | this.estateSettings.terrainMultiplier = Convert.ToDouble(re, CultureInfo.InvariantCulture); | ||
234 | configData.SetAttribute("TerrainMultiplier", this.estateSettings.terrainMultiplier.ToString()); | ||
235 | } | ||
236 | else | ||
237 | { | ||
238 | this.estateSettings.terrainMultiplier = Convert.ToDouble(attri); | ||
239 | } | ||
240 | |||
241 | attri = ""; | ||
242 | attri = configData.GetAttribute("MasterAvatarFirstName"); | ||
243 | if (attri == "") | ||
244 | { | ||
245 | this.MasterAvatarFirstName = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("First name of Master Avatar (Land and Region Owner)", "Test"); | ||
246 | |||
247 | configData.SetAttribute("MasterAvatarFirstName", this.MasterAvatarFirstName); | ||
248 | } | ||
249 | else | ||
250 | { | ||
251 | this.MasterAvatarFirstName = attri; | ||
252 | } | ||
253 | |||
254 | attri = ""; | ||
255 | attri = configData.GetAttribute("MasterAvatarLastName"); | ||
256 | if (attri == "") | ||
257 | { | ||
258 | this.MasterAvatarLastName = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("Last name of Master Avatar (Land and Region Owner)", "User"); | ||
259 | |||
260 | configData.SetAttribute("MasterAvatarLastName", this.MasterAvatarLastName); | ||
261 | } | ||
262 | else | ||
263 | { | ||
264 | this.MasterAvatarLastName = attri; | ||
265 | } | ||
266 | |||
267 | if (isSandbox) //Sandbox Mode Specific Settings | ||
268 | { | ||
269 | attri = ""; | ||
270 | attri = configData.GetAttribute("MasterAvatarSandboxPassword"); | ||
271 | if (attri == "") | ||
272 | { | ||
273 | this.MasterAvatarSandboxPassword = OpenSim.Framework.Console.MainLog.Instance.CmdPrompt("Password of Master Avatar (Needed for sandbox mode account creation only)", "test"); | ||
274 | |||
275 | //Should I store this? | ||
276 | configData.SetAttribute("MasterAvatarSandboxPassword", this.MasterAvatarSandboxPassword); | ||
277 | } | ||
278 | else | ||
279 | { | ||
280 | this.MasterAvatarSandboxPassword = attri; | ||
281 | } | ||
282 | } | ||
283 | |||
284 | this.RegionHandle = Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256)); | ||
285 | |||
286 | configData.Commit(); | ||
287 | } | ||
288 | catch (Exception e) | ||
289 | { | ||
290 | OpenSim.Framework.Console.MainLog.Instance.Warn("Config.cs:InitConfig() - Exception occured"); | ||
291 | OpenSim.Framework.Console.MainLog.Instance.Warn(e.ToString()); | ||
292 | } | ||
293 | |||
294 | OpenSim.Framework.Console.MainLog.Instance.Verbose("Sim settings loaded:"); | ||
295 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "UUID: " + this.SimUUID.ToStringHyphenated()); | ||
296 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "Name: " + this.RegionName); | ||
297 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); | ||
298 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "Region Handle: " + this.RegionHandle.ToString()); | ||
299 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "Listening on IP: " + this.CommsIPListenAddr + ":" + this.CommsIPListenPort); | ||
300 | OpenSim.Framework.Console.MainLog.Instance.Verbose( "Sandbox Mode? " + isSandbox.ToString()); | ||
301 | |||
302 | } | ||
303 | } | ||
304 | } | ||