diff options
author | Melanie | 2010-01-10 01:02:03 +0000 |
---|---|---|
committer | Melanie | 2010-01-10 01:02:03 +0000 |
commit | 7a352edd5a8fac579b2267d26e1c2a1cae524df6 (patch) | |
tree | b986ca0400ec727351cc6685efac76d758d24642 /OpenSim/Services | |
parent | Temp fix: initialize flags value to prevent exception (diff) | |
download | opensim-SC_OLD-7a352edd5a8fac579b2267d26e1c2a1cae524df6.zip opensim-SC_OLD-7a352edd5a8fac579b2267d26e1c2a1cae524df6.tar.gz opensim-SC_OLD-7a352edd5a8fac579b2267d26e1c2a1cae524df6.tar.bz2 opensim-SC_OLD-7a352edd5a8fac579b2267d26e1c2a1cae524df6.tar.xz |
Add some commands to the grid server
Diffstat (limited to 'OpenSim/Services')
-rw-r--r-- | OpenSim/Services/GridService/GridService.cs | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 31163a5..d6232ac 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -47,12 +47,16 @@ namespace OpenSim.Services.GridService | |||
47 | MethodBase.GetCurrentMethod().DeclaringType); | 47 | MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | private bool m_DeleteOnUnregister = true; | 49 | private bool m_DeleteOnUnregister = true; |
50 | private static GridService m_RootInstance = null; | ||
50 | 51 | ||
51 | public GridService(IConfigSource config) | 52 | public GridService(IConfigSource config) |
52 | : base(config) | 53 | : base(config) |
53 | { | 54 | { |
54 | m_log.DebugFormat("[GRID SERVICE]: Starting..."); | 55 | m_log.DebugFormat("[GRID SERVICE]: Starting..."); |
55 | 56 | ||
57 | if (m_RootInstance == null) | ||
58 | m_RootInstance = this; | ||
59 | |||
56 | IConfig gridConfig = config.Configs["GridService"]; | 60 | IConfig gridConfig = config.Configs["GridService"]; |
57 | if (gridConfig != null) | 61 | if (gridConfig != null) |
58 | { | 62 | { |
@@ -298,13 +302,84 @@ namespace OpenSim.Services.GridService | |||
298 | 302 | ||
299 | private void HandleShowRegion(string module, string[] cmd) | 303 | private void HandleShowRegion(string module, string[] cmd) |
300 | { | 304 | { |
305 | if (m_RootInstance != this) | ||
306 | return; | ||
307 | |||
301 | if (cmd.Length != 3) | 308 | if (cmd.Length != 3) |
302 | { | 309 | { |
303 | MainConsole.Instance.Output("Syntax: show region <region name>"); | 310 | MainConsole.Instance.Output("Syntax: show region <region name>"); |
304 | return; | 311 | return; |
305 | } | 312 | } |
313 | List<RegionData> regions = m_Database.Get(cmd[2], UUID.Zero); | ||
314 | if (regions == null || regions.Count < 1) | ||
315 | { | ||
316 | MainConsole.Instance.Output("Region not found"); | ||
317 | return; | ||
318 | } | ||
319 | |||
320 | MainConsole.Instance.Output("Region Name Region UUID"); | ||
321 | MainConsole.Instance.Output("Location URI"); | ||
322 | MainConsole.Instance.Output("Owner ID Flags"); | ||
323 | MainConsole.Instance.Output("-------------------------------------------------------------------------------"); | ||
324 | foreach (RegionData r in regions) | ||
325 | { | ||
326 | OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); | ||
327 | MainConsole.Instance.Output(String.Format("{0,-20} {1}\n{2,-20} {3}\n{4,-39} {5}\n\n", | ||
328 | r.RegionName, r.RegionID, | ||
329 | String.Format("{0},{1}", r.posX, r.posY), "http://" + r.Data["serverIP"].ToString() + ":" + r.Data["serverPort"].ToString(), | ||
330 | r.Data["owner_uuid"].ToString(), flags.ToString())); | ||
331 | } | ||
332 | return; | ||
333 | } | ||
334 | |||
335 | private int ParseFlags(int prev, string flags) | ||
336 | { | ||
337 | OpenSim.Data.RegionFlags f = (OpenSim.Data.RegionFlags)prev; | ||
338 | |||
339 | string[] parts = flags.Split(new char[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries); | ||
340 | |||
341 | foreach (string p in parts) | ||
342 | { | ||
343 | int val; | ||
344 | |||
345 | try | ||
346 | { | ||
347 | if (p.StartsWith("+")) | ||
348 | { | ||
349 | val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p.Substring(1)); | ||
350 | f |= (OpenSim.Data.RegionFlags)val; | ||
351 | } | ||
352 | else if (p.StartsWith("-")) | ||
353 | { | ||
354 | val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p.Substring(1)); | ||
355 | f &= ~(OpenSim.Data.RegionFlags)val; | ||
356 | } | ||
357 | else | ||
358 | { | ||
359 | val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p); | ||
360 | f |= (OpenSim.Data.RegionFlags)val; | ||
361 | } | ||
362 | } | ||
363 | catch (Exception e) | ||
364 | { | ||
365 | } | ||
366 | } | ||
306 | 367 | ||
368 | return (int)f; | ||
369 | } | ||
370 | |||
371 | private void HandleSetFlags(string module, string[] cmd) | ||
372 | { | ||
373 | if (m_RootInstance != this) | ||
374 | return; | ||
375 | |||
376 | if (cmd.Length < 4) | ||
377 | { | ||
378 | MainConsole.Instance.Output("Syntax: set region flags <region name> <flags>"); | ||
379 | return; | ||
380 | } | ||
307 | 381 | ||
382 | MainConsole.Instance.Output(ParseFlags(0, cmd[3]).ToString()); | ||
308 | } | 383 | } |
309 | } | 384 | } |
310 | } | 385 | } |