aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2010-01-10 01:46:34 +0000
committerMelanie2010-01-10 01:46:34 +0000
commitd889d4e1fa9f921a4f8f4f128218bf1d4454071e (patch)
tree8349fb7a96ae487f21e2dd7a42cfa1ec51d8bb25 /OpenSim
parentMerge branch 'presence-refactor' of melanie@opensimulator.org:/var/git/opensi... (diff)
downloadopensim-SC-d889d4e1fa9f921a4f8f4f128218bf1d4454071e.zip
opensim-SC-d889d4e1fa9f921a4f8f4f128218bf1d4454071e.tar.gz
opensim-SC-d889d4e1fa9f921a4f8f4f128218bf1d4454071e.tar.bz2
opensim-SC-d889d4e1fa9f921a4f8f4f128218bf1d4454071e.tar.xz
Finally the region service config stuff is in.
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/GridService/GridService.cs68
1 files changed, 51 insertions, 17 deletions
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index d6232ac..0fd2934 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -48,33 +48,45 @@ namespace OpenSim.Services.GridService
48 48
49 private bool m_DeleteOnUnregister = true; 49 private bool m_DeleteOnUnregister = true;
50 private static GridService m_RootInstance = null; 50 private static GridService m_RootInstance = null;
51 protected IConfigSource m_config;
51 52
52 public GridService(IConfigSource config) 53 public GridService(IConfigSource config)
53 : base(config) 54 : base(config)
54 { 55 {
55 m_log.DebugFormat("[GRID SERVICE]: Starting..."); 56 m_log.DebugFormat("[GRID SERVICE]: Starting...");
56 57
57 if (m_RootInstance == null) 58 m_config = config;
58 m_RootInstance = this;
59
60 IConfig gridConfig = config.Configs["GridService"]; 59 IConfig gridConfig = config.Configs["GridService"];
61 if (gridConfig != null) 60 if (gridConfig != null)
62 { 61 {
63 m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true); 62 m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true);
64 } 63 }
65 64
66 MainConsole.Instance.Commands.AddCommand("grid", true, 65 if (m_RootInstance == null)
67 "show region", 66 {
68 "show region <Region name>", 67 m_RootInstance = this;
69 "Show details on a region", 68
70 "Display all details about a registered grid region", 69 MainConsole.Instance.Commands.AddCommand("grid", true,
71 HandleShowRegion); 70 "show region",
71 "show region <Region name>",
72 "Show details on a region",
73 String.Empty,
74 HandleShowRegion);
75
76 MainConsole.Instance.Commands.AddCommand("grid", true,
77 "set region flags",
78 "set region flags <Region name> <flags>",
79 "Set database flags for region",
80 String.Empty,
81 HandleSetFlags);
82 }
72 } 83 }
73 84
74 #region IGridService 85 #region IGridService
75 86
76 public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) 87 public bool RegisterRegion(UUID scopeID, GridRegion regionInfos)
77 { 88 {
89 IConfig gridConfig = m_config.Configs["GridService"];
78 // This needs better sanity testing. What if regionInfo is registering in 90 // This needs better sanity testing. What if regionInfo is registering in
79 // overlapping coords? 91 // overlapping coords?
80 RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); 92 RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
@@ -104,12 +116,23 @@ namespace OpenSim.Services.GridService
104 // Everything is ok, let's register 116 // Everything is ok, let's register
105 RegionData rdata = RegionInfo2RegionData(regionInfos); 117 RegionData rdata = RegionInfo2RegionData(regionInfos);
106 rdata.ScopeID = scopeID; 118 rdata.ScopeID = scopeID;
107 rdata.Data["flags"] = "0";
108 119
109 if (region != null) 120 if (region != null)
110 { 121 {
111 rdata.Data["flags"] = region.Data["flags"]; // Preserve fields 122 rdata.Data["flags"] = region.Data["flags"]; // Preserve fields
112 } 123 }
124 else
125 {
126 rdata.Data["flags"] = "0";
127 if (gridConfig != null)
128 {
129 int newFlags = 0;
130 newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + rdata.RegionName, String.Empty));
131 newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + rdata.RegionID.ToString(), String.Empty));
132 rdata.Data["flags"] = newFlags.ToString();
133 }
134 }
135
113 int flags = Convert.ToInt32(rdata.Data["flags"]); 136 int flags = Convert.ToInt32(rdata.Data["flags"]);
114 flags |= (int)OpenSim.Data.RegionFlags.RegionOnline; 137 flags |= (int)OpenSim.Data.RegionFlags.RegionOnline;
115 rdata.Data["flags"] = flags.ToString(); 138 rdata.Data["flags"] = flags.ToString();
@@ -302,9 +325,6 @@ namespace OpenSim.Services.GridService
302 325
303 private void HandleShowRegion(string module, string[] cmd) 326 private void HandleShowRegion(string module, string[] cmd)
304 { 327 {
305 if (m_RootInstance != this)
306 return;
307
308 if (cmd.Length != 3) 328 if (cmd.Length != 3)
309 { 329 {
310 MainConsole.Instance.Output("Syntax: show region <region name>"); 330 MainConsole.Instance.Output("Syntax: show region <region name>");
@@ -362,6 +382,7 @@ namespace OpenSim.Services.GridService
362 } 382 }
363 catch (Exception e) 383 catch (Exception e)
364 { 384 {
385 MainConsole.Instance.Output("Error in flag specification: " + p);
365 } 386 }
366 } 387 }
367 388
@@ -370,16 +391,29 @@ namespace OpenSim.Services.GridService
370 391
371 private void HandleSetFlags(string module, string[] cmd) 392 private void HandleSetFlags(string module, string[] cmd)
372 { 393 {
373 if (m_RootInstance != this) 394 if (cmd.Length < 5)
395 {
396 MainConsole.Instance.Output("Syntax: set region flags <region name> <flags>");
374 return; 397 return;
398 }
375 399
376 if (cmd.Length < 4) 400 List<RegionData> regions = m_Database.Get(cmd[3], UUID.Zero);
401 if (regions == null || regions.Count < 1)
377 { 402 {
378 MainConsole.Instance.Output("Syntax: set region flags <region name> <flags>"); 403 MainConsole.Instance.Output("Region not found");
379 return; 404 return;
380 } 405 }
381 406
382 MainConsole.Instance.Output(ParseFlags(0, cmd[3]).ToString()); 407 foreach (RegionData r in regions)
408 {
409 int flags = Convert.ToInt32(r.Data["flags"]);
410 flags = ParseFlags(flags, cmd[4]);
411 r.Data["flags"] = flags.ToString();
412 OpenSim.Data.RegionFlags f = (OpenSim.Data.RegionFlags)flags;
413
414 MainConsole.Instance.Output(String.Format("Set region {0} to {1}", r.RegionName, f));
415 m_Database.Store(r);
416 }
383 } 417 }
384 } 418 }
385} 419}