aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Application/HGCommands.cs
diff options
context:
space:
mode:
authorJohn Hurliman2009-09-30 15:28:23 -0700
committerJohn Hurliman2009-09-30 15:28:23 -0700
commitacfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009 (patch)
tree305349e1bd0a5849fd7f96483e24d5e07b24b8f4 /OpenSim/Region/Application/HGCommands.cs
parent* Adding Scale to EntityBase * Fixing the incorrect initialization of EntityB... (diff)
parentFormatting cleanup. (diff)
downloadopensim-SC_OLD-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.zip
opensim-SC_OLD-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.tar.gz
opensim-SC_OLD-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.tar.bz2
opensim-SC_OLD-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region/Application/HGCommands.cs')
-rw-r--r--OpenSim/Region/Application/HGCommands.cs215
1 files changed, 1 insertions, 214 deletions
diff --git a/OpenSim/Region/Application/HGCommands.cs b/OpenSim/Region/Application/HGCommands.cs
index 1786e54..f503db7 100644
--- a/OpenSim/Region/Application/HGCommands.cs
+++ b/OpenSim/Region/Application/HGCommands.cs
@@ -43,16 +43,11 @@ namespace OpenSim
43 public class HGCommands 43 public class HGCommands
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 public static IHyperlink HGServices = null;
47
48 private static uint m_autoMappingX = 0;
49 private static uint m_autoMappingY = 0;
50 private static bool m_enableAutoMapping = false;
51 46
52 public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager, 47 public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager,
53 StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) 48 StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version)
54 { 49 {
55 HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices); 50 HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager);
56 51
57 return 52 return
58 new HGScene( 53 new HGScene(
@@ -61,213 +56,5 @@ namespace OpenSim
61 m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); 56 m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
62 } 57 }
63 58
64 public static void RunHGCommand(string command, string[] cmdparams, Scene scene)
65 {
66 if (command.Equals("link-mapping"))
67 {
68 if (cmdparams.Length == 2)
69 {
70 try
71 {
72 m_autoMappingX = Convert.ToUInt32(cmdparams[0]);
73 m_autoMappingY = Convert.ToUInt32(cmdparams[1]);
74 m_enableAutoMapping = true;
75 }
76 catch (Exception)
77 {
78 m_autoMappingX = 0;
79 m_autoMappingY = 0;
80 m_enableAutoMapping = false;
81 }
82 }
83 }
84 else if (command.Equals("link-region"))
85 {
86 if (cmdparams.Length < 3)
87 {
88 if ((cmdparams.Length == 1) || (cmdparams.Length == 2))
89 {
90 LoadXmlLinkFile(cmdparams, scene);
91 }
92 else
93 {
94 LinkRegionCmdUsage();
95 }
96 return;
97 }
98
99 if (cmdparams[2].Contains(":"))
100 {
101 // New format
102 uint xloc, yloc;
103 string mapName;
104 try
105 {
106 xloc = Convert.ToUInt32(cmdparams[0]);
107 yloc = Convert.ToUInt32(cmdparams[1]);
108 mapName = cmdparams[2];
109 if (cmdparams.Length > 3)
110 for (int i = 3; i < cmdparams.Length; i++)
111 mapName += " " + cmdparams[i];
112
113 m_log.Info(">> MapName: " + mapName);
114 //internalPort = Convert.ToUInt32(cmdparams[4]);
115 //remotingPort = Convert.ToUInt32(cmdparams[5]);
116 }
117 catch (Exception e)
118 {
119 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
120 LinkRegionCmdUsage();
121 return;
122 }
123
124 HGHyperlink.TryLinkRegionToCoords(scene, null, mapName, xloc, yloc);
125 }
126 else
127 {
128 // old format
129 RegionInfo regInfo;
130 uint xloc, yloc;
131 uint externalPort;
132 string externalHostName;
133 try
134 {
135 xloc = Convert.ToUInt32(cmdparams[0]);
136 yloc = Convert.ToUInt32(cmdparams[1]);
137 externalPort = Convert.ToUInt32(cmdparams[3]);
138 externalHostName = cmdparams[2];
139 //internalPort = Convert.ToUInt32(cmdparams[4]);
140 //remotingPort = Convert.ToUInt32(cmdparams[5]);
141 }
142 catch (Exception e)
143 {
144 m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
145 LinkRegionCmdUsage();
146 return;
147 }
148
149 //if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
150 if (HGHyperlink.TryCreateLink(scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo))
151 {
152 if (cmdparams.Length >= 5)
153 {
154 regInfo.RegionName = "";
155 for (int i = 4; i < cmdparams.Length; i++)
156 regInfo.RegionName += cmdparams[i] + " ";
157 }
158 }
159 }
160 return;
161 }
162 else if (command.Equals("unlink-region"))
163 {
164 if (cmdparams.Length < 1)
165 {
166 UnlinkRegionCmdUsage();
167 return;
168 }
169 if (HGHyperlink.TryUnlinkRegion(scene, cmdparams[0]))
170 m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]);
171 else
172 m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]);
173 }
174 }
175
176 private static void LoadXmlLinkFile(string[] cmdparams, Scene scene)
177 {
178 //use http://www.hgurl.com/hypergrid.xml for test
179 try
180 {
181 XmlReader r = XmlReader.Create(cmdparams[0]);
182 XmlConfigSource cs = new XmlConfigSource(r);
183 string[] excludeSections = null;
184
185 if (cmdparams.Length == 2)
186 {
187 if (cmdparams[1].ToLower().StartsWith("excludelist:"))
188 {
189 string excludeString = cmdparams[1].ToLower();
190 excludeString = excludeString.Remove(0, 12);
191 char[] splitter = {';'};
192
193 excludeSections = excludeString.Split(splitter);
194 }
195 }
196
197 for (int i = 0; i < cs.Configs.Count; i++)
198 {
199 bool skip = false;
200 if ((excludeSections != null) && (excludeSections.Length > 0))
201 {
202 for (int n = 0; n < excludeSections.Length; n++)
203 {
204 if (excludeSections[n] == cs.Configs[i].Name.ToLower())
205 {
206 skip = true;
207 break;
208 }
209 }
210 }
211 if (!skip)
212 {
213 ReadLinkFromConfig(cs.Configs[i], scene);
214 }
215 }
216 }
217 catch (Exception e)
218 {
219 m_log.Error(e.ToString());
220 }
221 }
222
223
224 private static void ReadLinkFromConfig(IConfig config, Scene scene)
225 {
226 RegionInfo regInfo;
227 uint xloc, yloc;
228 uint externalPort;
229 string externalHostName;
230 uint realXLoc, realYLoc;
231
232 xloc = Convert.ToUInt32(config.GetString("xloc", "0"));
233 yloc = Convert.ToUInt32(config.GetString("yloc", "0"));
234 externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
235 externalHostName = config.GetString("externalHostName", "");
236 realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
237 realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0"));
238
239 if (m_enableAutoMapping)
240 {
241 xloc = (uint) ((xloc%100) + m_autoMappingX);
242 yloc = (uint) ((yloc%100) + m_autoMappingY);
243 }
244
245 if (((realXLoc == 0) && (realYLoc == 0)) ||
246 (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) &&
247 ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
248 {
249 if (
250 HGHyperlink.TryCreateLink(scene, null, xloc, yloc, "", externalPort,
251 externalHostName, out regInfo))
252 {
253 regInfo.RegionName = config.GetString("localName", "");
254 }
255 }
256 }
257
258
259 private static void LinkRegionCmdUsage()
260 {
261 m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName>:<HttpPort>[:<RemoteRegionName>]");
262 m_log.Info("Usage: link-region <Xloc> <Yloc> <HostName> <HttpPort> [<LocalName>]");
263 m_log.Info("Usage: link-region <URI_of_xml> [<exclude>]");
264 }
265
266 private static void UnlinkRegionCmdUsage()
267 {
268 m_log.Info("Usage: unlink-region <HostName>:<HttpPort>");
269 m_log.Info("Usage: unlink-region <LocalName>");
270 }
271
272 } 59 }
273} 60}