diff options
OpenSim no longer uses OpenSim.Config.SimConfigDb4o, it now uses OpenSim.GenericConfig.Xml (or a class implementing IGenericConfig).
Diffstat (limited to '')
-rw-r--r-- | OpenSim.RegionServer/RegionInfo.cs | 229 |
1 files changed, 229 insertions, 0 deletions
diff --git a/OpenSim.RegionServer/RegionInfo.cs b/OpenSim.RegionServer/RegionInfo.cs new file mode 100644 index 0000000..15cc105 --- /dev/null +++ b/OpenSim.RegionServer/RegionInfo.cs | |||
@@ -0,0 +1,229 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenSim.Framework.Interfaces; | ||
5 | using OpenSim.Framework.Utilities; | ||
6 | |||
7 | namespace OpenSim | ||
8 | { | ||
9 | public class RegionInfo // could inherit from SimProfileBase | ||
10 | { | ||
11 | public string RegionName; | ||
12 | |||
13 | public uint RegionLocX; | ||
14 | public uint RegionLocY; | ||
15 | public ulong RegionHandle; | ||
16 | |||
17 | public int IPListenPort; | ||
18 | public string IPListenAddr; | ||
19 | |||
20 | //following should be removed and the GenericConfig object passed around, | ||
21 | //so each class (AssetServer, GridServer etc) can access what config data they want | ||
22 | public string AssetURL = ""; | ||
23 | public string AssetSendKey = ""; | ||
24 | |||
25 | public string GridURL = ""; | ||
26 | public string GridSendKey = ""; | ||
27 | public string GridRecvKey = ""; | ||
28 | public string UserURL = ""; | ||
29 | public string UserSendKey = ""; | ||
30 | public string UserRecvKey = ""; | ||
31 | private bool isSandbox; | ||
32 | |||
33 | public RegionInfo() | ||
34 | { | ||
35 | |||
36 | } | ||
37 | |||
38 | public void InitConfig(bool sandboxMode, IGenericConfig configData) | ||
39 | { | ||
40 | this.isSandbox = sandboxMode; | ||
41 | try | ||
42 | { | ||
43 | // Sim name | ||
44 | string attri =""; | ||
45 | attri = configData.GetAttribute("SimName"); | ||
46 | if (attri == "") | ||
47 | { | ||
48 | this.RegionName = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Name [OpenSim test]: ", "OpenSim test"); | ||
49 | configData.SetAttribute("SimName", this.RegionName); | ||
50 | } | ||
51 | else | ||
52 | { | ||
53 | this.RegionName = attri; | ||
54 | } | ||
55 | // Sim/Grid location X | ||
56 | attri = ""; | ||
57 | attri = configData.GetAttribute("SimLocationX"); | ||
58 | if (attri == "") | ||
59 | { | ||
60 | string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location X [997]: ", "997"); | ||
61 | configData.SetAttribute("SimLocationX", location); | ||
62 | this.RegionLocX = (uint)Convert.ToInt32(location); | ||
63 | } | ||
64 | else | ||
65 | { | ||
66 | this.RegionLocX = (uint)Convert.ToInt32(attri); | ||
67 | } | ||
68 | // Sim/Grid location Y | ||
69 | attri = ""; | ||
70 | attri = configData.GetAttribute("SimLocationY"); | ||
71 | if (attri == "") | ||
72 | { | ||
73 | string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location Y [996]: ", "996"); | ||
74 | configData.SetAttribute("SimLocationY", location); | ||
75 | this.RegionLocY = (uint)Convert.ToInt32(location); | ||
76 | } | ||
77 | else | ||
78 | { | ||
79 | this.RegionLocY = (uint)Convert.ToInt32(attri); | ||
80 | } | ||
81 | //Sim Listen Port | ||
82 | attri = ""; | ||
83 | attri = configData.GetAttribute("SimListenPort"); | ||
84 | if (attri == "") | ||
85 | { | ||
86 | string port = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("UDP port for client connections [9000]: ", "9000"); | ||
87 | configData.SetAttribute("SimListenPort", port); | ||
88 | this.IPListenPort = Convert.ToInt32(port); | ||
89 | } | ||
90 | else | ||
91 | { | ||
92 | this.IPListenPort = Convert.ToInt32(attri); | ||
93 | } | ||
94 | //Sim Listen Address | ||
95 | attri = ""; | ||
96 | attri = configData.GetAttribute("SimListenAddress"); | ||
97 | if (attri == "") | ||
98 | { | ||
99 | this.IPListenAddr = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("IP Address to listen on for client connections [127.0.0.1]: ", "127.0.0.1"); | ||
100 | configData.SetAttribute("SimListenAddress", this.IPListenAddr); | ||
101 | } | ||
102 | else | ||
103 | { | ||
104 | this.IPListenAddr = attri; | ||
105 | } | ||
106 | |||
107 | if (!isSandbox) | ||
108 | { | ||
109 | //shouldn't be reading this data in here, it should be up to the classes implementing the server interfaces to read what they need from the config object | ||
110 | |||
111 | // Asset Server URL | ||
112 | attri = ""; | ||
113 | attri = configData.GetAttribute("AssetServerURL"); | ||
114 | if (attri == "") | ||
115 | { | ||
116 | this.AssetURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Asset server URL: "); | ||
117 | configData.SetAttribute("AssetServerURL", this.AssetURL); | ||
118 | } | ||
119 | else | ||
120 | { | ||
121 | this.AssetURL = attri; | ||
122 | } | ||
123 | //Asset Server key | ||
124 | attri = ""; | ||
125 | attri = configData.GetAttribute("AssetServerKey"); | ||
126 | if (attri == "") | ||
127 | { | ||
128 | this.AssetSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Asset server key: "); | ||
129 | configData.SetAttribute("AssetServerKey", this.AssetSendKey); | ||
130 | } | ||
131 | else | ||
132 | { | ||
133 | this.AssetSendKey = attri; | ||
134 | } | ||
135 | //Grid Sever URL | ||
136 | attri = ""; | ||
137 | attri = configData.GetAttribute("GridServerURL"); | ||
138 | if (attri == "") | ||
139 | { | ||
140 | this.GridURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid server URL: "); | ||
141 | configData.SetAttribute("GridServerURL", this.GridURL); | ||
142 | } | ||
143 | else | ||
144 | { | ||
145 | this.GridURL = attri; | ||
146 | } | ||
147 | //Grid Send Key | ||
148 | attri = ""; | ||
149 | attri = configData.GetAttribute("GridSendKey"); | ||
150 | if (attri == "") | ||
151 | { | ||
152 | this.GridSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to grid server: "); | ||
153 | configData.SetAttribute("GridSendKey", this.GridSendKey); | ||
154 | } | ||
155 | else | ||
156 | { | ||
157 | this.GridSendKey = attri; | ||
158 | } | ||
159 | //Grid Receive Key | ||
160 | attri = ""; | ||
161 | attri = configData.GetAttribute("GridRecvKey"); | ||
162 | if (attri == "") | ||
163 | { | ||
164 | this.GridRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from grid server: "); | ||
165 | configData.SetAttribute("GridRecvKey", this.GridRecvKey); | ||
166 | } | ||
167 | else | ||
168 | { | ||
169 | this.GridRecvKey = attri; | ||
170 | } | ||
171 | //User Server URL | ||
172 | attri = ""; | ||
173 | attri = configData.GetAttribute("UserServerURL"); | ||
174 | if (attri == "") | ||
175 | { | ||
176 | this.UserURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("User server URL: "); | ||
177 | configData.SetAttribute("UserServerURL", this.UserURL); | ||
178 | } | ||
179 | else | ||
180 | { | ||
181 | this.UserURL = attri; | ||
182 | } | ||
183 | //User Send Key | ||
184 | attri = ""; | ||
185 | attri = configData.GetAttribute("UserSendKey"); | ||
186 | if (attri == "") | ||
187 | { | ||
188 | this.UserSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to user server: "); | ||
189 | configData.SetAttribute("UserSendKey", this.UserSendKey); | ||
190 | } | ||
191 | else | ||
192 | { | ||
193 | this.UserSendKey = attri; | ||
194 | } | ||
195 | //User Receive Key | ||
196 | attri = ""; | ||
197 | attri = configData.GetAttribute("UserRecvKey"); | ||
198 | if (attri == "") | ||
199 | { | ||
200 | this.UserRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from user server: "); | ||
201 | configData.SetAttribute("UserRecvKey", this.UserRecvKey); | ||
202 | } | ||
203 | else | ||
204 | { | ||
205 | this.UserRecvKey = attri; | ||
206 | } | ||
207 | } | ||
208 | this.RegionHandle = Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256)); | ||
209 | configData.Commit(); | ||
210 | } | ||
211 | catch (Exception e) | ||
212 | { | ||
213 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Config.cs:InitConfig() - Exception occured"); | ||
214 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); | ||
215 | } | ||
216 | |||
217 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sim settings loaded:"); | ||
218 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Name: " + this.RegionName); | ||
219 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]"); | ||
220 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Region Handle: " + this.RegionHandle.ToString()); | ||
221 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort); | ||
222 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sandbox Mode? " + isSandbox.ToString()); | ||
223 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Asset URL: " + this.AssetURL); | ||
224 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Asset key: " + this.AssetSendKey); | ||
225 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid URL: " + this.GridURL); | ||
226 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Grid key: " + this.GridSendKey); | ||
227 | } | ||
228 | } | ||
229 | } | ||