aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application/HGOpenSimNode.cs
diff options
context:
space:
mode:
authordiva2009-04-27 00:16:59 +0000
committerdiva2009-04-27 00:16:59 +0000
commitd8313e314feddc492ec9d8e657aa7d0a15a7004b (patch)
tree4024a8bebbc83745b1df22981b001559346bc247 /OpenSim/Region/Application/HGOpenSimNode.cs
parentHGWorldMap got a bit out of sync during the introduction of the new module sy... (diff)
downloadopensim-SC_OLD-d8313e314feddc492ec9d8e657aa7d0a15a7004b.zip
opensim-SC_OLD-d8313e314feddc492ec9d8e657aa7d0a15a7004b.tar.gz
opensim-SC_OLD-d8313e314feddc492ec9d8e657aa7d0a15a7004b.tar.bz2
opensim-SC_OLD-d8313e314feddc492ec9d8e657aa7d0a15a7004b.tar.xz
Getting rid of -hypergrid=true on the command line. This config now goes inside OpenSim.ini in the Startup section. This makes the HG compatible with -background, and prepares the way for further work on HG-related config vars. Might help with mantis #3527.
Diffstat (limited to 'OpenSim/Region/Application/HGOpenSimNode.cs')
-rw-r--r--OpenSim/Region/Application/HGOpenSimNode.cs305
1 files changed, 0 insertions, 305 deletions
diff --git a/OpenSim/Region/Application/HGOpenSimNode.cs b/OpenSim/Region/Application/HGOpenSimNode.cs
deleted file mode 100644
index f4f3062..0000000
--- a/OpenSim/Region/Application/HGOpenSimNode.cs
+++ /dev/null
@@ -1,305 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Xml;
32using log4net;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Console;
37using OpenSim.Region.Framework;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Framework.Scenes.Hypergrid;
40
41namespace OpenSim
42{
43 public class HGOpenSimNode : OpenSim
44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 public IHyperlink HGServices = null;
47
48 private uint m_autoMappingX = 0;
49 private uint m_autoMappingY = 0;
50 private bool m_enableAutoMapping = false;
51
52 public HGOpenSimNode(IConfigSource configSource) : base(configSource)
53 {
54 }
55
56 /// <summary>
57 /// Performs initialisation of the scene, such as loading configuration from disk.
58 /// </summary>
59 protected override void StartupSpecific()
60 {
61 m_log.Info("====================================================================");
62 m_log.Info("=================== STARTING HYPERGRID NODE ========================");
63 m_log.Info("====================================================================");
64
65 base.StartupSpecific();
66
67 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-mapping", "link-mapping [<x> <y>] <cr>",
68 "Set local coordinate to map HG regions to", RunCommand);
69 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "link-region",
70 "link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>] <cr>",
71 "Link a hypergrid region", RunCommand);
72 MainConsole.Instance.Commands.AddCommand("hypergrid", false, "unlink-region",
73 "unlink-region <local name> or <HostName>:<HttpPort> <cr>",
74 "Unlink a hypergrid region", RunCommand);
75 }
76
77 protected override Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager,
78 AgentCircuitManager circuitManager)
79 {
80 HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices);
81
82 return
83 new HGScene(
84 regionInfo, circuitManager, m_commsManager, sceneGridService, storageManager,
85 m_moduleLoader, m_configSettings.DumpAssetsToFile, m_configSettings.PhysicalPrim,
86 m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
87 }
88
89 private new void RunCommand(string module, string[] cp)
90 {
91 List<string> cmdparams = new List<string>(cp);
92 if (cmdparams.Count < 1)
93 return;
94
95 string command = cmdparams[0];
96 cmdparams.RemoveAt(0);
97
98 if (command.Equals("link-mapping"))
99 {
100 if (cmdparams.Count == 2)
101 {
102 try
103 {
104 m_autoMappingX = Convert.ToUInt32(cmdparams[0]);
105 m_autoMappingY = Convert.ToUInt32(cmdparams[1]);
106 m_enableAutoMapping = true;
107 }
108 catch (Exception)
109 {
110 m_autoMappingX = 0;
111 m_autoMappingY = 0;
112 m_enableAutoMapping = false;
113 }
114 }
115 }
116 else if (command.Equals("link-region"))
117 {
118 if (cmdparams.Count < 3)
119 {
120 if ((cmdparams.Count == 1) || (cmdparams.Count == 2))
121 {
122 LoadXmlLinkFile(cmdparams);
123 }
124 else
125 {
126 LinkRegionCmdUsage();
127 }
128 return;
129 }
130
131 if (cmdparams[2].Contains(":"))
132 {
133 // New format
134 uint xloc, yloc;
135 string mapName;
136 try
137 {
138 xloc = Convert.ToUInt32(cmdparams[0]);
139 yloc = Convert.ToUInt32(cmdparams[1]);
140 mapName = cmdparams[2];
141 if (cmdparams.Count > 3)
142 for (int i = 3; i < cmdparams.Count; i++)
143 mapName += " " + cmdparams[i];
144
145 m_log.Info(">> MapName: " + mapName);
146 //internalPort = Convert.ToUInt32(cmdparams[4]);
147 //remotingPort = Convert.ToUInt32(cmdparams[5]);
148 }
149 catch (Exception e)
150 {
151 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
152 LinkRegionCmdUsage();
153 return;
154 }
155
156 HGHyperlink.TryLinkRegionToCoords(m_sceneManager.CurrentOrFirstScene, null, mapName, xloc, yloc);
157 }
158 else
159 {
160 // old format
161 RegionInfo regInfo;
162 uint xloc, yloc;
163 uint externalPort;
164 string externalHostName;
165 try
166 {
167 xloc = Convert.ToUInt32(cmdparams[0]);
168 yloc = Convert.ToUInt32(cmdparams[1]);
169 externalPort = Convert.ToUInt32(cmdparams[3]);
170 externalHostName = cmdparams[2];
171 //internalPort = Convert.ToUInt32(cmdparams[4]);
172 //remotingPort = Convert.ToUInt32(cmdparams[5]);
173 }
174 catch (Exception e)
175 {
176 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
177 LinkRegionCmdUsage();
178 return;
179 }
180
181 //if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
182 if (HGHyperlink.TryCreateLink(m_sceneManager.CurrentOrFirstScene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
183 {
184 if (cmdparams.Count >= 5)
185 {
186 regInfo.RegionName = "";
187 for (int i = 4; i < cmdparams.Count; i++)
188 regInfo.RegionName += cmdparams[i] + " ";
189 }
190 }
191 }
192 return;
193 }
194 else if (command.Equals("unlink-region"))
195 {
196 if (cmdparams.Count < 1)
197 {
198 UnlinkRegionCmdUsage();
199 return;
200 }
201 if (HGHyperlink.TryUnlinkRegion(m_sceneManager.CurrentOrFirstScene, cmdparams[0]))
202 m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]);
203 else
204 m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]);
205 }
206 }
207
208 private void LoadXmlLinkFile(List<string> cmdparams)
209 {
210 //use http://www.hgurl.com/hypergrid.xml for test
211 try
212 {
213 XmlReader r = XmlReader.Create(cmdparams[0]);
214 XmlConfigSource cs = new XmlConfigSource(r);
215 string[] excludeSections = null;
216
217 if (cmdparams.Count == 2)
218 {
219 if (cmdparams[1].ToLower().StartsWith("excludelist:"))
220 {
221 string excludeString = cmdparams[1].ToLower();
222 excludeString = excludeString.Remove(0, 12);
223 char[] splitter = {';'};
224
225 excludeSections = excludeString.Split(splitter);
226 }
227 }
228
229 for (int i = 0; i < cs.Configs.Count; i++)
230 {
231 bool skip = false;
232 if ((excludeSections != null) && (excludeSections.Length > 0))
233 {
234 for (int n = 0; n < excludeSections.Length; n++)
235 {
236 if (excludeSections[n] == cs.Configs[i].Name.ToLower())
237 {
238 skip = true;
239 break;
240 }
241 }
242 }
243 if (!skip)
244 {
245 ReadLinkFromConfig(cs.Configs[i]);
246 }
247 }
248 }
249 catch (Exception e)
250 {
251 m_log.Error(e.ToString());
252 }
253 }
254
255
256 private void ReadLinkFromConfig(IConfig config)
257 {
258 RegionInfo regInfo;
259 uint xloc, yloc;
260 uint externalPort;
261 string externalHostName;
262 uint realXLoc, realYLoc;
263
264 xloc = Convert.ToUInt32(config.GetString("xloc", "0"));
265 yloc = Convert.ToUInt32(config.GetString("yloc", "0"));
266 externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
267 externalHostName = config.GetString("externalHostName", "");
268 realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
269 realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0"));
270
271 if (m_enableAutoMapping)
272 {
273 xloc = (uint) ((xloc%100) + m_autoMappingX);
274 yloc = (uint) ((yloc%100) + m_autoMappingY);
275 }
276
277 if (((realXLoc == 0) && (realYLoc == 0)) ||
278 (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) &&
279 ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
280 {
281 if (
282 HGHyperlink.TryCreateLink(m_sceneManager.CurrentOrFirstScene, null, xloc, yloc, "", externalPort,
283 externalHostName, out regInfo))
284 {
285 regInfo.RegionName = config.GetString("localName", "");
286 }
287 }
288 }
289
290
291 private void LinkRegionCmdUsage()
292 {
293 m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]");
294 m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");
295 m_log.Info("Usage: link-region <URI_of_xml> [<exclude>]");
296 }
297
298 private void UnlinkRegionCmdUsage()
299 {
300 m_log.Info("Usage: unlink-region <HostName>:<HttpPort>");
301 m_log.Info("Usage: unlink-region <LocalName>");
302 }
303
304 }
305} \ No newline at end of file