From d889d4e1fa9f921a4f8f4f128218bf1d4454071e Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 10 Jan 2010 01:46:34 +0000 Subject: Finally the region service config stuff is in. --- OpenSim/Services/GridService/GridService.cs | 68 +++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 17 deletions(-) (limited to 'OpenSim/Services') 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 private bool m_DeleteOnUnregister = true; private static GridService m_RootInstance = null; + protected IConfigSource m_config; public GridService(IConfigSource config) : base(config) { m_log.DebugFormat("[GRID SERVICE]: Starting..."); - if (m_RootInstance == null) - m_RootInstance = this; - + m_config = config; IConfig gridConfig = config.Configs["GridService"]; if (gridConfig != null) { m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true); } - MainConsole.Instance.Commands.AddCommand("grid", true, - "show region", - "show region ", - "Show details on a region", - "Display all details about a registered grid region", - HandleShowRegion); + if (m_RootInstance == null) + { + m_RootInstance = this; + + MainConsole.Instance.Commands.AddCommand("grid", true, + "show region", + "show region ", + "Show details on a region", + String.Empty, + HandleShowRegion); + + MainConsole.Instance.Commands.AddCommand("grid", true, + "set region flags", + "set region flags ", + "Set database flags for region", + String.Empty, + HandleSetFlags); + } } #region IGridService public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) { + IConfig gridConfig = m_config.Configs["GridService"]; // This needs better sanity testing. What if regionInfo is registering in // overlapping coords? RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); @@ -104,12 +116,23 @@ namespace OpenSim.Services.GridService // Everything is ok, let's register RegionData rdata = RegionInfo2RegionData(regionInfos); rdata.ScopeID = scopeID; - rdata.Data["flags"] = "0"; if (region != null) { rdata.Data["flags"] = region.Data["flags"]; // Preserve fields } + else + { + rdata.Data["flags"] = "0"; + if (gridConfig != null) + { + int newFlags = 0; + newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + rdata.RegionName, String.Empty)); + newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + rdata.RegionID.ToString(), String.Empty)); + rdata.Data["flags"] = newFlags.ToString(); + } + } + int flags = Convert.ToInt32(rdata.Data["flags"]); flags |= (int)OpenSim.Data.RegionFlags.RegionOnline; rdata.Data["flags"] = flags.ToString(); @@ -302,9 +325,6 @@ namespace OpenSim.Services.GridService private void HandleShowRegion(string module, string[] cmd) { - if (m_RootInstance != this) - return; - if (cmd.Length != 3) { MainConsole.Instance.Output("Syntax: show region "); @@ -362,6 +382,7 @@ namespace OpenSim.Services.GridService } catch (Exception e) { + MainConsole.Instance.Output("Error in flag specification: " + p); } } @@ -370,16 +391,29 @@ namespace OpenSim.Services.GridService private void HandleSetFlags(string module, string[] cmd) { - if (m_RootInstance != this) + if (cmd.Length < 5) + { + MainConsole.Instance.Output("Syntax: set region flags "); return; + } - if (cmd.Length < 4) + List regions = m_Database.Get(cmd[3], UUID.Zero); + if (regions == null || regions.Count < 1) { - MainConsole.Instance.Output("Syntax: set region flags "); + MainConsole.Instance.Output("Region not found"); return; } - MainConsole.Instance.Output(ParseFlags(0, cmd[3]).ToString()); + foreach (RegionData r in regions) + { + int flags = Convert.ToInt32(r.Data["flags"]); + flags = ParseFlags(flags, cmd[4]); + r.Data["flags"] = flags.ToString(); + OpenSim.Data.RegionFlags f = (OpenSim.Data.RegionFlags)flags; + + MainConsole.Instance.Output(String.Format("Set region {0} to {1}", r.RegionName, f)); + m_Database.Store(r); + } } } } -- cgit v1.1