From e7362738155c0a0a5c9ef8b867eb14b18bb31a44 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 18 Sep 2009 19:16:30 -0700 Subject: First pass at the grid service. --- OpenSim/Services/GridService/GridService.cs | 297 ++++++++++++++++++++++++++++ 1 file changed, 297 insertions(+) create mode 100644 OpenSim/Services/GridService/GridService.cs (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs new file mode 100644 index 0000000..6aa1c4f --- /dev/null +++ b/OpenSim/Services/GridService/GridService.cs @@ -0,0 +1,297 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Net; +using System.Reflection; +using Nini.Config; +using log4net; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Data; +using OpenSim.Services.Interfaces; +using OpenMetaverse; + +namespace OpenSim.Services.GridService +{ + public class GridService : GridServiceBase, IGridService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + public GridService(IConfigSource config) + : base(config) + { + MainConsole.Instance.Commands.AddCommand("kfs", false, + "show digest", + "show digest ", + "Show asset digest", HandleShowDigest); + + MainConsole.Instance.Commands.AddCommand("kfs", false, + "delete asset", + "delete asset ", + "Delete asset from database", HandleDeleteAsset); + + } + + #region IGridService + + public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos) + { + if (m_Database.Get(regionInfos.RegionID, scopeID) != null) + { + m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID); + return false; + } + if (m_Database.Get((int)regionInfos.RegionLocX, (int)regionInfos.RegionLocY, scopeID) != null) + { + m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", + regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); + return false; + } + + // Everything is ok, let's register + RegionData rdata = RegionInfo2RegionData(regionInfos); + rdata.ScopeID = scopeID; + m_Database.Store(rdata); + return true; + } + + public bool DeregisterRegion(UUID regionID) + { + return m_Database.Delete(regionID); + } + + public List GetNeighbours(UUID scopeID, int x, int y) + { + List rdatas = m_Database.Get(x - 1, y - 1, x + 1, y + 1, scopeID); + List rinfos = new List(); + foreach (RegionData rdata in rdatas) + rinfos.Add(RegionData2RegionInfo(rdata)); + + return rinfos; + } + + public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + { + RegionData rdata = m_Database.Get(regionID, scopeID); + if (rdata != null) + return RegionData2RegionInfo(rdata); + + return null; + } + + public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + { + RegionData rdata = m_Database.Get(x, y, scopeID); + if (rdata != null) + return RegionData2RegionInfo(rdata); + + return null; + } + + public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + { + List rdatas = m_Database.Get(regionName + "%", scopeID); + if ((rdatas != null) && (rdatas.Count > 0)) + return RegionData2RegionInfo(rdatas[0]); // get the first + + return null; + } + + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + { + List rdatas = m_Database.Get("%" + name + "%", scopeID); + + int count = 0; + List rinfos = new List(); + + if (rdatas != null) + { + foreach (RegionData rdata in rdatas) + { + if (count++ < maxNumber) + rinfos.Add(RegionData2RegionInfo(rdata)); + } + } + + return rinfos; + } + + public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + { + List rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); + List rinfos = new List(); + foreach (RegionData rdata in rdatas) + rinfos.Add(RegionData2RegionInfo(rdata)); + + return rinfos; + } + + #endregion + + #region Data structure conversions + + protected RegionData RegionInfo2RegionData(SimpleRegionInfo rinfo) + { + RegionData rdata = new RegionData(); + rdata.posX = (int)rinfo.RegionLocX; + rdata.posY = (int)rinfo.RegionLocY; + rdata.RegionID = rinfo.RegionID; + //rdata.RegionName = rinfo.RegionName; + rdata.Data["external_ip_address"] = rinfo.ExternalEndPoint.Address.ToString(); + rdata.Data["external_port"] = rinfo.ExternalEndPoint.Port.ToString(); + rdata.Data["external_host_name"] = rinfo.ExternalHostName; + rdata.Data["http_port"] = rinfo.HttpPort.ToString(); + rdata.Data["internal_ip_address"] = rinfo.InternalEndPoint.Address.ToString(); + rdata.Data["internal_port"] = rinfo.InternalEndPoint.Port.ToString(); + rdata.Data["alternate_ports"] = rinfo.m_allow_alternate_ports.ToString(); + rdata.Data["server_uri"] = rinfo.ServerURI; + + return rdata; + } + + protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) + { + SimpleRegionInfo rinfo = new SimpleRegionInfo(); + rinfo.RegionLocX = (uint)rdata.posX; + rinfo.RegionLocY = (uint)rdata.posY; + rinfo.RegionID = rdata.RegionID; + //rinfo.RegionName = rdata.RegionName; + + // Now for the variable data + if ((rdata.Data["external_ip_address"] != null) && (rdata.Data["external_port"] != null)) + { + int port = 0; + Int32.TryParse((string)rdata.Data["external_port"], out port); + IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)rdata.Data["external_ip_address"]), port); + rinfo.ExternalEndPoint = ep; + } + else + rinfo.ExternalEndPoint = new IPEndPoint(new IPAddress(0), 0); + + if (rdata.Data["external_host_name"] != null) + rinfo.ExternalHostName = (string)rdata.Data["external_host_name"] ; + + if (rdata.Data["http_port"] != null) + { + UInt32 port = 0; + UInt32.TryParse((string)rdata.Data["http_port"], out port); + rinfo.HttpPort = port; + } + + if ((rdata.Data["internal_ip_address"] != null) && (rdata.Data["internal_port"] != null)) + { + int port = 0; + Int32.TryParse((string)rdata.Data["internal_port"], out port); + IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)rdata.Data["internal_ip_address"]), port); + rinfo.InternalEndPoint = ep; + } + else + rinfo.InternalEndPoint = new IPEndPoint(new IPAddress(0), 0); + + if (rdata.Data["alternate_ports"] != null) + { + bool alts = false; + Boolean.TryParse((string)rdata.Data["alternate_ports"], out alts); + rinfo.m_allow_alternate_ports = alts; + } + + if (rdata.Data["server_uri"] != null) + rinfo.ServerURI = (string)rdata.Data["server_uri"]; + + return rinfo; + } + + #endregion + + void HandleShowDigest(string module, string[] args) + { + //if (args.Length < 3) + //{ + // MainConsole.Instance.Output("Syntax: show digest "); + // return; + //} + + //AssetBase asset = Get(args[2]); + + //if (asset == null || asset.Data.Length == 0) + //{ + // MainConsole.Instance.Output("Asset not found"); + // return; + //} + + //int i; + + //MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name)); + //MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description)); + //MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type)); + //MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType)); + + //for (i = 0 ; i < 5 ; i++) + //{ + // int off = i * 16; + // if (asset.Data.Length <= off) + // break; + // int len = 16; + // if (asset.Data.Length < off + len) + // len = asset.Data.Length - off; + + // byte[] line = new byte[len]; + // Array.Copy(asset.Data, off, line, 0, len); + + // string text = BitConverter.ToString(line); + // MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); + //} + } + + void HandleDeleteAsset(string module, string[] args) + { + //if (args.Length < 3) + //{ + // MainConsole.Instance.Output("Syntax: delete asset "); + // return; + //} + + //AssetBase asset = Get(args[2]); + + //if (asset == null || asset.Data.Length == 0) + // MainConsole.Instance.Output("Asset not found"); + // return; + //} + + //Delete(args[2]); + + ////MainConsole.Instance.Output("Asset deleted"); + //// TODO: Implement this + + //MainConsole.Instance.Output("Asset deletion not supported by database"); + } + } +} -- cgit v1.1 From 390137d540b9ae39eba3ba9136bd49d5e992bc5f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 21 Sep 2009 11:05:01 -0700 Subject: Added grid handler and grid remote connector. --- OpenSim/Services/GridService/GridService.cs | 65 +++++------------------------ 1 file changed, 11 insertions(+), 54 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 6aa1c4f..2229421 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -88,13 +88,18 @@ namespace OpenSim.Services.GridService return m_Database.Delete(regionID); } - public List GetNeighbours(UUID scopeID, int x, int y) + public List GetNeighbours(UUID scopeID, UUID regionID) { - List rdatas = m_Database.Get(x - 1, y - 1, x + 1, y + 1, scopeID); List rinfos = new List(); - foreach (RegionData rdata in rdatas) - rinfos.Add(RegionData2RegionInfo(rdata)); + RegionData region = m_Database.Get(regionID, scopeID); + if (region != null) + { + // Not really? Maybe? + List rdatas = m_Database.Get(region.posX - 1, region.posY - 1, region.posX + 1, region.posY + 1, scopeID); + foreach (RegionData rdata in rdatas) + rinfos.Add(RegionData2RegionInfo(rdata)); + } return rinfos; } @@ -164,68 +169,20 @@ namespace OpenSim.Services.GridService rdata.posX = (int)rinfo.RegionLocX; rdata.posY = (int)rinfo.RegionLocY; rdata.RegionID = rinfo.RegionID; + rdata.Data = rinfo.ToKeyValuePairs(); //rdata.RegionName = rinfo.RegionName; - rdata.Data["external_ip_address"] = rinfo.ExternalEndPoint.Address.ToString(); - rdata.Data["external_port"] = rinfo.ExternalEndPoint.Port.ToString(); - rdata.Data["external_host_name"] = rinfo.ExternalHostName; - rdata.Data["http_port"] = rinfo.HttpPort.ToString(); - rdata.Data["internal_ip_address"] = rinfo.InternalEndPoint.Address.ToString(); - rdata.Data["internal_port"] = rinfo.InternalEndPoint.Port.ToString(); - rdata.Data["alternate_ports"] = rinfo.m_allow_alternate_ports.ToString(); - rdata.Data["server_uri"] = rinfo.ServerURI; return rdata; } protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) { - SimpleRegionInfo rinfo = new SimpleRegionInfo(); + SimpleRegionInfo rinfo = new SimpleRegionInfo(rdata.Data); rinfo.RegionLocX = (uint)rdata.posX; rinfo.RegionLocY = (uint)rdata.posY; rinfo.RegionID = rdata.RegionID; //rinfo.RegionName = rdata.RegionName; - // Now for the variable data - if ((rdata.Data["external_ip_address"] != null) && (rdata.Data["external_port"] != null)) - { - int port = 0; - Int32.TryParse((string)rdata.Data["external_port"], out port); - IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)rdata.Data["external_ip_address"]), port); - rinfo.ExternalEndPoint = ep; - } - else - rinfo.ExternalEndPoint = new IPEndPoint(new IPAddress(0), 0); - - if (rdata.Data["external_host_name"] != null) - rinfo.ExternalHostName = (string)rdata.Data["external_host_name"] ; - - if (rdata.Data["http_port"] != null) - { - UInt32 port = 0; - UInt32.TryParse((string)rdata.Data["http_port"], out port); - rinfo.HttpPort = port; - } - - if ((rdata.Data["internal_ip_address"] != null) && (rdata.Data["internal_port"] != null)) - { - int port = 0; - Int32.TryParse((string)rdata.Data["internal_port"], out port); - IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)rdata.Data["internal_ip_address"]), port); - rinfo.InternalEndPoint = ep; - } - else - rinfo.InternalEndPoint = new IPEndPoint(new IPAddress(0), 0); - - if (rdata.Data["alternate_ports"] != null) - { - bool alts = false; - Boolean.TryParse((string)rdata.Data["alternate_ports"], out alts); - rinfo.m_allow_alternate_ports = alts; - } - - if (rdata.Data["server_uri"] != null) - rinfo.ServerURI = (string)rdata.Data["server_uri"]; - return rinfo; } -- cgit v1.1 From ae07b220c61cc92453c67e602907f0b3c8fcc707 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 21 Sep 2009 17:16:30 -0700 Subject: Changed position methods so that they assume the input params are in meters. --- OpenSim/Services/GridService/GridService.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 2229421..dd529f5 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -95,7 +95,9 @@ namespace OpenSim.Services.GridService if (region != null) { // Not really? Maybe? - List rdatas = m_Database.Get(region.posX - 1, region.posY - 1, region.posX + 1, region.posY + 1, scopeID); + List rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize, region.posY - (int)Constants.RegionSize, + region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID); + foreach (RegionData rdata in rdatas) rinfos.Add(RegionData2RegionInfo(rdata)); @@ -114,7 +116,9 @@ namespace OpenSim.Services.GridService public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) { - RegionData rdata = m_Database.Get(x, y, scopeID); + int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; + int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; + RegionData rdata = m_Database.Get(snapX, snapY, scopeID); if (rdata != null) return RegionData2RegionInfo(rdata); @@ -151,7 +155,12 @@ namespace OpenSim.Services.GridService public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { - List rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); + int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; + int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; + int yminSnap = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; + int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; + + List rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); List rinfos = new List(); foreach (RegionData rdata in rdatas) rinfos.Add(RegionData2RegionInfo(rdata)); -- cgit v1.1 From ffd30b8ac31bc408316079ba86076bf9e984a8be Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 22 Sep 2009 14:46:05 -0700 Subject: Moved RegionName from RegionInfo to SimpleRegionInfo. --- OpenSim/Services/GridService/GridService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index dd529f5..b37a51b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -179,7 +179,7 @@ namespace OpenSim.Services.GridService rdata.posY = (int)rinfo.RegionLocY; rdata.RegionID = rinfo.RegionID; rdata.Data = rinfo.ToKeyValuePairs(); - //rdata.RegionName = rinfo.RegionName; + rdata.RegionName = rinfo.RegionName; return rdata; } @@ -190,7 +190,7 @@ namespace OpenSim.Services.GridService rinfo.RegionLocX = (uint)rdata.posX; rinfo.RegionLocY = (uint)rdata.posY; rinfo.RegionID = rdata.RegionID; - //rinfo.RegionName = rdata.RegionName; + rinfo.RegionName = rdata.RegionName; return rinfo; } -- cgit v1.1 From 67276589c883fe1a74d8d52057db1431d637dade Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 17:20:07 -0700 Subject: Changed IGridService to use the new GridRegion data structure instead of old SimpleRegionInfo. Added grid configs to standalones. --- OpenSim/Services/GridService/GridService.cs | 32 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index b37a51b..cd462ab 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -35,6 +35,7 @@ using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Data; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenMetaverse; namespace OpenSim.Services.GridService @@ -48,6 +49,7 @@ namespace OpenSim.Services.GridService public GridService(IConfigSource config) : base(config) { + m_log.DebugFormat("[GRID SERVICE]: Starting..."); MainConsole.Instance.Commands.AddCommand("kfs", false, "show digest", "show digest ", @@ -62,7 +64,7 @@ namespace OpenSim.Services.GridService #region IGridService - public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos) + public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) { if (m_Database.Get(regionInfos.RegionID, scopeID) != null) { @@ -88,9 +90,9 @@ namespace OpenSim.Services.GridService return m_Database.Delete(regionID); } - public List GetNeighbours(UUID scopeID, UUID regionID) + public List GetNeighbours(UUID scopeID, UUID regionID) { - List rinfos = new List(); + List rinfos = new List(); RegionData region = m_Database.Get(regionID, scopeID); if (region != null) { @@ -105,7 +107,7 @@ namespace OpenSim.Services.GridService return rinfos; } - public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { RegionData rdata = m_Database.Get(regionID, scopeID); if (rdata != null) @@ -114,7 +116,7 @@ namespace OpenSim.Services.GridService return null; } - public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; @@ -125,7 +127,7 @@ namespace OpenSim.Services.GridService return null; } - public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public GridRegion GetRegionByName(UUID scopeID, string regionName) { List rdatas = m_Database.Get(regionName + "%", scopeID); if ((rdatas != null) && (rdatas.Count > 0)) @@ -134,12 +136,12 @@ namespace OpenSim.Services.GridService return null; } - public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) { List rdatas = m_Database.Get("%" + name + "%", scopeID); int count = 0; - List rinfos = new List(); + List rinfos = new List(); if (rdatas != null) { @@ -153,7 +155,7 @@ namespace OpenSim.Services.GridService return rinfos; } - public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; @@ -161,7 +163,7 @@ namespace OpenSim.Services.GridService int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; List rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); - List rinfos = new List(); + List rinfos = new List(); foreach (RegionData rdata in rdatas) rinfos.Add(RegionData2RegionInfo(rdata)); @@ -172,7 +174,7 @@ namespace OpenSim.Services.GridService #region Data structure conversions - protected RegionData RegionInfo2RegionData(SimpleRegionInfo rinfo) + protected RegionData RegionInfo2RegionData(GridRegion rinfo) { RegionData rdata = new RegionData(); rdata.posX = (int)rinfo.RegionLocX; @@ -184,11 +186,11 @@ namespace OpenSim.Services.GridService return rdata; } - protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) + protected GridRegion RegionData2RegionInfo(RegionData rdata) { - SimpleRegionInfo rinfo = new SimpleRegionInfo(rdata.Data); - rinfo.RegionLocX = (uint)rdata.posX; - rinfo.RegionLocY = (uint)rdata.posY; + GridRegion rinfo = new GridRegion(rdata.Data); + rinfo.RegionLocX = rdata.posX; + rinfo.RegionLocY = rdata.posY; rinfo.RegionID = rdata.RegionID; rinfo.RegionName = rdata.RegionName; -- cgit v1.1 From fd8fb7735b0eb6150679ccad84b2a32fd5315a38 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 20:39:25 -0700 Subject: First test passes -- regions being registered and retrieved correctly in Data.Null. --- OpenSim/Services/GridService/GridService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index cd462ab..1b297dc 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -101,7 +101,8 @@ namespace OpenSim.Services.GridService region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID); foreach (RegionData rdata in rdatas) - rinfos.Add(RegionData2RegionInfo(rdata)); + if (rdata.RegionID != regionID) + rinfos.Add(RegionData2RegionInfo(rdata)); } return rinfos; -- cgit v1.1 From 2824bbc47b30ab6fb9a12bce3201bb5b79b20bd5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 05:48:35 -0700 Subject: Changed name of the hyperlink XMLRPC method to linkk-region, so that it doesn't conflict with the existing one. --- OpenSim/Services/GridService/GridService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 1b297dc..01ffa1d 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -71,7 +71,9 @@ namespace OpenSim.Services.GridService m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID); return false; } - if (m_Database.Get((int)regionInfos.RegionLocX, (int)regionInfos.RegionLocY, scopeID) != null) + // This needs better sanity testing. What if regionInfo is registering in + // overlapping coords? + if (m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID) != null) { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); -- cgit v1.1 From 6a5d7650d02979c74abcbbb3595729a4a6b55411 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 18:23:55 -0700 Subject: All tests pass for MySQL/MySQLRegionData. Added OpenSim.GridServer.ini.example that I have been using for testing the ROBUST grid service with the GridClient. --- OpenSim/Services/GridService/GridService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 01ffa1d..41344ad 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -183,9 +183,9 @@ namespace OpenSim.Services.GridService rdata.posX = (int)rinfo.RegionLocX; rdata.posY = (int)rinfo.RegionLocY; rdata.RegionID = rinfo.RegionID; - rdata.Data = rinfo.ToKeyValuePairs(); rdata.RegionName = rinfo.RegionName; - + rdata.Data = rinfo.ToKeyValuePairs(); + rdata.Data["regionHandle"] = Utils.UIntsToLong((uint)rdata.posX, (uint)rdata.posY); return rdata; } @@ -196,6 +196,7 @@ namespace OpenSim.Services.GridService rinfo.RegionLocY = rdata.posY; rinfo.RegionID = rdata.RegionID; rinfo.RegionName = rdata.RegionName; + rinfo.ScopeID = rdata.ScopeID; return rinfo; } -- cgit v1.1 From b6824c495cb04ca79c681143be2d1b8f9b5b228d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 24 Sep 2009 18:28:38 -0700 Subject: Deleted the meaningless console commands on the GridService. Will need to add meaningful ones. --- OpenSim/Services/GridService/GridService.cs | 72 ----------------------------- 1 file changed, 72 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 41344ad..68b7cdf 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -50,16 +50,6 @@ namespace OpenSim.Services.GridService : base(config) { m_log.DebugFormat("[GRID SERVICE]: Starting..."); - MainConsole.Instance.Commands.AddCommand("kfs", false, - "show digest", - "show digest ", - "Show asset digest", HandleShowDigest); - - MainConsole.Instance.Commands.AddCommand("kfs", false, - "delete asset", - "delete asset ", - "Delete asset from database", HandleDeleteAsset); - } #region IGridService @@ -203,67 +193,5 @@ namespace OpenSim.Services.GridService #endregion - void HandleShowDigest(string module, string[] args) - { - //if (args.Length < 3) - //{ - // MainConsole.Instance.Output("Syntax: show digest "); - // return; - //} - - //AssetBase asset = Get(args[2]); - - //if (asset == null || asset.Data.Length == 0) - //{ - // MainConsole.Instance.Output("Asset not found"); - // return; - //} - - //int i; - - //MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name)); - //MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description)); - //MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type)); - //MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType)); - - //for (i = 0 ; i < 5 ; i++) - //{ - // int off = i * 16; - // if (asset.Data.Length <= off) - // break; - // int len = 16; - // if (asset.Data.Length < off + len) - // len = asset.Data.Length - off; - - // byte[] line = new byte[len]; - // Array.Copy(asset.Data, off, line, 0, len); - - // string text = BitConverter.ToString(line); - // MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text)); - //} - } - - void HandleDeleteAsset(string module, string[] args) - { - //if (args.Length < 3) - //{ - // MainConsole.Instance.Output("Syntax: delete asset "); - // return; - //} - - //AssetBase asset = Get(args[2]); - - //if (asset == null || asset.Data.Length == 0) - // MainConsole.Instance.Output("Asset not found"); - // return; - //} - - //Delete(args[2]); - - ////MainConsole.Instance.Output("Asset deleted"); - //// TODO: Implement this - - //MainConsole.Instance.Output("Asset deletion not supported by database"); - } } } -- cgit v1.1 From 52e477b41f137ff2a0775722dcbaaa64fa5f3bc3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 25 Sep 2009 06:02:41 -0700 Subject: Better guards on RegisterRegion in GridService. Added serverPort to the fields that get stored (I think this is the UDP port). --- OpenSim/Services/GridService/GridService.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 68b7cdf..991acf2 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -56,19 +56,21 @@ namespace OpenSim.Services.GridService public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) { - if (m_Database.Get(regionInfos.RegionID, scopeID) != null) - { - m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID); - return false; - } // This needs better sanity testing. What if regionInfo is registering in // overlapping coords? - if (m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID) != null) + RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); + if ((region != null) && (region.RegionID != regionInfos.RegionID)) { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); return false; } + if ((region != null) && (region.RegionID == regionInfos.RegionID) && + ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) + { + // Region reregistering in other coordinates. Delete the old entry + m_Database.Delete(regionInfos.RegionID); + } // Everything is ok, let's register RegionData rdata = RegionInfo2RegionData(regionInfos); -- cgit v1.1 From a2d5da71292ee271617edf28346e6aeb1e153943 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 5 Oct 2009 10:31:09 -0700 Subject: More debug messages if things go wrong. --- OpenSim/Services/GridService/GridService.cs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 991acf2..a2e4771 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -69,18 +69,40 @@ namespace OpenSim.Services.GridService ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) { // Region reregistering in other coordinates. Delete the old entry - m_Database.Delete(regionInfos.RegionID); + m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", + regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); + + try + { + m_Database.Delete(regionInfos.RegionID); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); + } } // Everything is ok, let's register RegionData rdata = RegionInfo2RegionData(regionInfos); rdata.ScopeID = scopeID; - m_Database.Store(rdata); + try + { + m_Database.Store(rdata); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); + } + + m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}", + regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); + return true; } public bool DeregisterRegion(UUID regionID) { + m_log.DebugFormat("[GRID SERVICE]: Region {0} deregistered", regionID); return m_Database.Delete(regionID); } -- cgit v1.1 From d9f15fbf40f7eca81ff2ca6f3792820c6cabc605 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 7 Oct 2009 19:37:18 +0100 Subject: store owner_uuid in the region table --- OpenSim/Services/GridService/GridService.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index a2e4771..86815e5 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -200,6 +200,7 @@ namespace OpenSim.Services.GridService rdata.RegionName = rinfo.RegionName; rdata.Data = rinfo.ToKeyValuePairs(); rdata.Data["regionHandle"] = Utils.UIntsToLong((uint)rdata.posX, (uint)rdata.posY); + rdata.Data["owner_uuid"] = rinfo.EstateOwner.ToString(); return rdata; } -- cgit v1.1 From 28d6705358c2e383fb46c57f064de4dcff144e33 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 9 Jan 2010 20:46:32 +0000 Subject: Preliminary work on the new default region setting mechanism --- OpenSim/Services/GridService/GridService.cs | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 86815e5..884bc95 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -46,10 +46,18 @@ namespace OpenSim.Services.GridService LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); + private bool m_DeleteOnUnregister = true; + public GridService(IConfigSource config) : base(config) { m_log.DebugFormat("[GRID SERVICE]: Starting..."); + + IConfig gridConfig = config.Configs["GridService"]; + if (gridConfig != null) + { + m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true); + } } #region IGridService @@ -85,6 +93,15 @@ namespace OpenSim.Services.GridService // Everything is ok, let's register RegionData rdata = RegionInfo2RegionData(regionInfos); rdata.ScopeID = scopeID; + + if (region != null) + { + rdata.Data["flags"] = region.Data["flags"]; // Preserve fields + } + int flags = Convert.ToInt32(rdata.Data["flags"]); + flags |= (int)OpenSim.Data.RegionFlags.RegionOnline; + rdata.Data["flags"] = flags.ToString(); + try { m_Database.Store(rdata); @@ -103,6 +120,28 @@ namespace OpenSim.Services.GridService public bool DeregisterRegion(UUID regionID) { m_log.DebugFormat("[GRID SERVICE]: Region {0} deregistered", regionID); + if (!m_DeleteOnUnregister) + { + RegionData region = m_Database.Get(regionID, UUID.Zero); + if (region == null) + return false; + + int flags = Convert.ToInt32(region.Data["flags"]); + flags &= ~(int)OpenSim.Data.RegionFlags.RegionOnline; + region.Data["flags"] = flags.ToString(); + try + { + m_Database.Store(region); + } + catch (Exception e) + { + m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); + } + + return true; + + } + return m_Database.Delete(regionID); } @@ -218,5 +257,35 @@ namespace OpenSim.Services.GridService #endregion + public List GetDefaultRegions(UUID scopeID) + { + List ret = new List(); + + List regions = m_Database.GetDefaultRegions(scopeID); + + foreach (RegionData r in regions) + ret.Add(RegionData2RegionInfo(r)); + + return ret; + } + + public List GetFallbackRegions(UUID scopeID, int x, int y) + { + List ret = new List(); + + List regions = m_Database.GetFallbackRegions(scopeID, x, y); + + foreach (RegionData r in regions) + ret.Add(RegionData2RegionInfo(r)); + + return ret; + } + + public int GetRegionFlags(UUID scopeID, UUID regionID) + { + RegionData region = m_Database.Get(regionID, scopeID); + + return Convert.ToInt32(region.Data["flags"]); + } } } -- cgit v1.1 From 59ecd6d151a990454847358fc4f83fb210913741 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 9 Jan 2010 23:25:34 +0000 Subject: Temp fix: initialize flags value to prevent exception --- OpenSim/Services/GridService/GridService.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 884bc95..31163a5 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -58,6 +58,13 @@ namespace OpenSim.Services.GridService { 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); } #region IGridService @@ -93,6 +100,7 @@ namespace OpenSim.Services.GridService // Everything is ok, let's register RegionData rdata = RegionInfo2RegionData(regionInfos); rdata.ScopeID = scopeID; + rdata.Data["flags"] = "0"; if (region != null) { @@ -287,5 +295,16 @@ namespace OpenSim.Services.GridService return Convert.ToInt32(region.Data["flags"]); } + + private void HandleShowRegion(string module, string[] cmd) + { + if (cmd.Length != 3) + { + MainConsole.Instance.Output("Syntax: show region "); + return; + } + + + } } } -- cgit v1.1 From 7a352edd5a8fac579b2267d26e1c2a1cae524df6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 10 Jan 2010 01:02:03 +0000 Subject: Add some commands to the grid server --- OpenSim/Services/GridService/GridService.cs | 75 +++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'OpenSim/Services/GridService/GridService.cs') 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 MethodBase.GetCurrentMethod().DeclaringType); private bool m_DeleteOnUnregister = true; + private static GridService m_RootInstance = null; public GridService(IConfigSource config) : base(config) { m_log.DebugFormat("[GRID SERVICE]: Starting..."); + if (m_RootInstance == null) + m_RootInstance = this; + IConfig gridConfig = config.Configs["GridService"]; if (gridConfig != null) { @@ -298,13 +302,84 @@ 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 "); return; } + List regions = m_Database.Get(cmd[2], UUID.Zero); + if (regions == null || regions.Count < 1) + { + MainConsole.Instance.Output("Region not found"); + return; + } + + MainConsole.Instance.Output("Region Name Region UUID"); + MainConsole.Instance.Output("Location URI"); + MainConsole.Instance.Output("Owner ID Flags"); + MainConsole.Instance.Output("-------------------------------------------------------------------------------"); + foreach (RegionData r in regions) + { + OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); + MainConsole.Instance.Output(String.Format("{0,-20} {1}\n{2,-20} {3}\n{4,-39} {5}\n\n", + r.RegionName, r.RegionID, + String.Format("{0},{1}", r.posX, r.posY), "http://" + r.Data["serverIP"].ToString() + ":" + r.Data["serverPort"].ToString(), + r.Data["owner_uuid"].ToString(), flags.ToString())); + } + return; + } + + private int ParseFlags(int prev, string flags) + { + OpenSim.Data.RegionFlags f = (OpenSim.Data.RegionFlags)prev; + + string[] parts = flags.Split(new char[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries); + + foreach (string p in parts) + { + int val; + + try + { + if (p.StartsWith("+")) + { + val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p.Substring(1)); + f |= (OpenSim.Data.RegionFlags)val; + } + else if (p.StartsWith("-")) + { + val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p.Substring(1)); + f &= ~(OpenSim.Data.RegionFlags)val; + } + else + { + val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p); + f |= (OpenSim.Data.RegionFlags)val; + } + } + catch (Exception e) + { + } + } + return (int)f; + } + + private void HandleSetFlags(string module, string[] cmd) + { + if (m_RootInstance != this) + return; + + if (cmd.Length < 4) + { + MainConsole.Instance.Output("Syntax: set region flags "); + return; + } + MainConsole.Instance.Output(ParseFlags(0, cmd[3]).ToString()); } } } -- cgit v1.1 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/GridService/GridService.cs') 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 From 21de921b95da3d6fe94284365d836d71f3295a41 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 10 Jan 2010 02:07:10 +0000 Subject: Make the new API return only the regions that are marked online --- OpenSim/Services/GridService/GridService.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 0fd2934..3ae51e4 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -299,7 +299,10 @@ namespace OpenSim.Services.GridService List regions = m_Database.GetDefaultRegions(scopeID); foreach (RegionData r in regions) - ret.Add(RegionData2RegionInfo(r)); + { + if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) + ret.Add(RegionData2RegionInfo(r)); + } return ret; } @@ -311,7 +314,10 @@ namespace OpenSim.Services.GridService List regions = m_Database.GetFallbackRegions(scopeID, x, y); foreach (RegionData r in regions) - ret.Add(RegionData2RegionInfo(r)); + { + if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) + ret.Add(RegionData2RegionInfo(r)); + } return ret; } -- cgit v1.1 From e189b3056fff7223f6474bc26af559ef32891fa6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 10 Jan 2010 02:13:55 +0000 Subject: Add last_seen field to regions table --- OpenSim/Services/GridService/GridService.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 3ae51e4..9bf986e 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -139,6 +139,7 @@ namespace OpenSim.Services.GridService try { + rdata.Data["last_seen"] = Util.UnixTimeSinceEpoch(); m_Database.Store(rdata); } catch (Exception e) @@ -164,6 +165,7 @@ namespace OpenSim.Services.GridService int flags = Convert.ToInt32(region.Data["flags"]); flags &= ~(int)OpenSim.Data.RegionFlags.RegionOnline; region.Data["flags"] = flags.ToString(); + region.Data["last_seen"] = Util.UnixTimeSinceEpoch(); try { m_Database.Store(region); -- cgit v1.1 From 9727e3d66b7324a2fa63e1cd95a77e2a82882723 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 10 Jan 2010 02:44:57 +0000 Subject: Add "Persistent" flag to regions table flags values --- OpenSim/Services/GridService/GridService.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 9bf986e..66bbff0 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -156,13 +156,14 @@ namespace OpenSim.Services.GridService public bool DeregisterRegion(UUID regionID) { m_log.DebugFormat("[GRID SERVICE]: Region {0} deregistered", regionID); - if (!m_DeleteOnUnregister) - { - RegionData region = m_Database.Get(regionID, UUID.Zero); - if (region == null) - return false; + RegionData region = m_Database.Get(regionID, UUID.Zero); + if (region == null) + return false; - int flags = Convert.ToInt32(region.Data["flags"]); + int flags = Convert.ToInt32(region.Data["flags"]); + + if (!m_DeleteOnUnregister || (flags & (int)OpenSim.Data.RegionFlags.Persistent) != 0) + { flags &= ~(int)OpenSim.Data.RegionFlags.RegionOnline; region.Data["flags"] = flags.ToString(); region.Data["last_seen"] = Util.UnixTimeSinceEpoch(); -- cgit v1.1 From 78e9dc7c2c71a2d1cfda7b39dfbc12ddbb64233b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 10 Jan 2010 04:23:23 +0000 Subject: Add a "LockedOut" flag to allow locking a region out via the grid server. This flag prevents registration of a known region --- OpenSim/Services/GridService/GridService.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 66bbff0..c48b10c 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -119,6 +119,9 @@ namespace OpenSim.Services.GridService if (region != null) { + if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) + return false; + rdata.Data["flags"] = region.Data["flags"]; // Preserve fields } else -- cgit v1.1 From 7467a471ca2d3e6066f89d8bca4ba956e07fbb6b Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 11 Jan 2010 22:52:05 +0000 Subject: Add the option to reject duplicate region names --- OpenSim/Services/GridService/GridService.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 86815e5..a500593 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -46,10 +46,18 @@ namespace OpenSim.Services.GridService LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); + protected bool m_AllowDuplicateNames = false; + public GridService(IConfigSource config) : base(config) { m_log.DebugFormat("[GRID SERVICE]: Starting..."); + + IConfig gridConfig = config.Configs["GridService"]; + if (gridConfig != null) + { + m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames); + } } #region IGridService @@ -82,6 +90,23 @@ namespace OpenSim.Services.GridService } } + if (!m_AllowDuplicateNames) + { + List dupe = m_Database.Get(regionInfos.RegionName, scopeID); + if (dupe != null && dupe.Count > 0) + { + foreach (RegionData d in dupe) + { + if (d.RegionID != regionInfos.RegionID) + { + m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.", + regionInfos.RegionName, regionInfos.RegionID); + return false; + } + } + } + } + // Everything is ok, let's register RegionData rdata = RegionInfo2RegionData(regionInfos); rdata.ScopeID = scopeID; -- cgit v1.1 From e3a04fcb7b6510b46bc4e24b9a1bc6e321774ac3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 13 Jan 2010 03:08:34 +0000 Subject: Change the error messages on region region registration. This changes URM and region. The non-error case should be compatible, so no version bump. Untested. --- OpenSim/Services/GridService/GridService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index a500593..7749c37 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -62,7 +62,7 @@ namespace OpenSim.Services.GridService #region IGridService - public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) + public string RegisterRegion(UUID scopeID, GridRegion regionInfos) { // This needs better sanity testing. What if regionInfo is registering in // overlapping coords? @@ -71,7 +71,7 @@ namespace OpenSim.Services.GridService { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); - return false; + return "Region overlaps another region"; } if ((region != null) && (region.RegionID == regionInfos.RegionID) && ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) @@ -101,7 +101,7 @@ namespace OpenSim.Services.GridService { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.", regionInfos.RegionName, regionInfos.RegionID); - return false; + return "Duplicate region name"; } } } @@ -122,7 +122,7 @@ namespace OpenSim.Services.GridService m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}", regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); - return true; + return String.Empty; } public bool DeregisterRegion(UUID regionID) -- cgit v1.1 From ab021aaa25d4ec4874ddc06eee77af9944d75926 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 13 Jan 2010 15:42:43 -0800 Subject: Make region flag specs work for regions whose names contain spaces. Uses underscore in place of spaces. Region_Word1_Word2. --- OpenSim/Services/GridService/GridService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index c48b10c..4f93ce5 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -127,10 +127,11 @@ namespace OpenSim.Services.GridService else { rdata.Data["flags"] = "0"; - if (gridConfig != null) + if ((gridConfig != null) && rdata.RegionName != string.Empty) { int newFlags = 0; - newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + rdata.RegionName, String.Empty)); + string regionName = rdata.RegionName.Trim().Replace(' ', '_'); + newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + regionName, String.Empty)); newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + rdata.RegionID.ToString(), String.Empty)); rdata.Data["flags"] = newFlags.ToString(); } -- cgit v1.1 From 344d27b19d4a1b0ca98a1e7cc4932eb996a9d59c Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 15 Jan 2010 21:23:59 +0000 Subject: Implement the NoMove behavior. Cause Reservation flag to be reset on first connect --- OpenSim/Services/GridService/GridService.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 4f93ce5..6e2c0d7 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -99,6 +99,9 @@ namespace OpenSim.Services.GridService if ((region != null) && (region.RegionID == regionInfos.RegionID) && ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) { + if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.NoMove) != 0) + return false; + // Region reregistering in other coordinates. Delete the old entry m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); @@ -119,10 +122,13 @@ namespace OpenSim.Services.GridService if (region != null) { - if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) + int oldFlags = Convert.ToInt32(region.Data["flags"]); + if ((oldFlags & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) return false; - rdata.Data["flags"] = region.Data["flags"]; // Preserve fields + oldFlags &= ~(int)OpenSim.Data.RegionFlags.Reservation; + + rdata.Data["flags"] = oldFlags.ToString(); // Preserve flags } else { -- cgit v1.1 From d49cc7ca905a54f72707e5fa728c4dfa68a514fb Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 15 Jan 2010 21:35:10 +0000 Subject: Implement "Reservation" flag behavior. --- OpenSim/Services/GridService/GridService.cs | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 6e2c0d7..6826940 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -90,6 +90,40 @@ namespace OpenSim.Services.GridService // This needs better sanity testing. What if regionInfo is registering in // overlapping coords? RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); + if (region != null) + { + // There is a preexisting record + // + // Get it's flags + // + OpenSim.Data.RegionFlags rflags = (OpenSim.Data.RegionFlags)Convert.ToInt32(region.Data["Flags"]); + + // Is this a reservation? + // + if ((rflags & OpenSim.Data.RegionFlags.Reservation) != 0) + { + // Regions reserved for the null key cannot be taken. + // + if (region.Data["PrincipalID"] == UUID.Zero.ToString()) + return false; + + // Treat it as an auth request + // + // NOTE: Fudging the flags value here, so these flags + // should not be used elsewhere. Don't optimize + // this with the later retrieval of the same flags! + // + rflags |= OpenSim.Data.RegionFlags.Authenticate; + } + + if ((rflags & OpenSim.Data.RegionFlags.Authenticate) != 0) + { + // TODO: Authenticate the principal + + return false; + } + } + if ((region != null) && (region.RegionID != regionInfos.RegionID)) { m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", -- cgit v1.1 From 686660650b4f5724fc0b4858d50ff4deeafb8ffe Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 15 Jan 2010 21:57:31 +0000 Subject: Implement region registration with authentication --- OpenSim/Services/GridService/GridService.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 6826940..5c55c0b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -34,6 +34,7 @@ using log4net; using OpenSim.Framework; using OpenSim.Framework.Console; using OpenSim.Data; +using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenMetaverse; @@ -50,6 +51,8 @@ namespace OpenSim.Services.GridService private static GridService m_RootInstance = null; protected IConfigSource m_config; + protected IAuthenticationService m_AuthenticationService = null; + public GridService(IConfigSource config) : base(config) { @@ -60,6 +63,14 @@ namespace OpenSim.Services.GridService if (gridConfig != null) { m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true); + + string authService = gridConfig.GetString("AuthenticationService", String.Empty); + + if (authService != String.Empty) + { + Object[] args = new Object[] { config }; + m_AuthenticationService = ServerUtils.LoadPlugin(authService, args); + } } if (m_RootInstance == null) @@ -118,7 +129,13 @@ namespace OpenSim.Services.GridService if ((rflags & OpenSim.Data.RegionFlags.Authenticate) != 0) { - // TODO: Authenticate the principal + // Can we authenticate at all? + // + if (m_AuthenticationService == null) + return false; + + if (!m_AuthenticationService.Verify(new UUID(region.Data["PrincipalID"].ToString()), regionInfos.Token, 30)) + return false; return false; } -- cgit v1.1 From bbbe9e73cca2a0ed5d35db1b054b8ed4cd23bfea Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 18 Jan 2010 09:14:19 -0800 Subject: * Fixed misspelling of field in GridService * Moved TeleportClientHome to EntityTransferModule --- OpenSim/Services/GridService/GridService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index e912705..9e0790c 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -109,7 +109,7 @@ namespace OpenSim.Services.GridService // // Get it's flags // - OpenSim.Data.RegionFlags rflags = (OpenSim.Data.RegionFlags)Convert.ToInt32(region.Data["Flags"]); + OpenSim.Data.RegionFlags rflags = (OpenSim.Data.RegionFlags)Convert.ToInt32(region.Data["flags"]); // Is this a reservation? // -- cgit v1.1 From 48b03c2c61a422c3ac9843892a2ae93b29a9f7b8 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 24 Jan 2010 14:30:48 -0800 Subject: Integrated the hyperlinking with the GridService. --- OpenSim/Services/GridService/GridService.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 9e0790c..ae29a74 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -50,6 +50,7 @@ namespace OpenSim.Services.GridService private bool m_DeleteOnUnregister = true; private static GridService m_RootInstance = null; protected IConfigSource m_config; + protected HypergridLinker m_HypergridLinker; protected IAuthenticationService m_AuthenticationService = null; protected bool m_AllowDuplicateNames = false; @@ -92,6 +93,8 @@ namespace OpenSim.Services.GridService "Set database flags for region", String.Empty, HandleSetFlags); + + m_HypergridLinker = new HypergridLinker(m_config, this, m_Database); } } @@ -346,7 +349,7 @@ namespace OpenSim.Services.GridService #region Data structure conversions - protected RegionData RegionInfo2RegionData(GridRegion rinfo) + public RegionData RegionInfo2RegionData(GridRegion rinfo) { RegionData rdata = new RegionData(); rdata.posX = (int)rinfo.RegionLocX; @@ -359,7 +362,7 @@ namespace OpenSim.Services.GridService return rdata; } - protected GridRegion RegionData2RegionInfo(RegionData rdata) + public GridRegion RegionData2RegionInfo(RegionData rdata) { GridRegion rinfo = new GridRegion(rdata.Data); rinfo.RegionLocX = rdata.posX; -- cgit v1.1 From ea3d287f70d48eb2d3abf6eb1506bf64674874c5 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 24 Jan 2010 15:04:41 -0800 Subject: Some method implementations were missing from LocalGridServiceConnector. --- OpenSim/Services/GridService/GridService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index ae29a74..b86fd4d 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -410,7 +410,9 @@ namespace OpenSim.Services.GridService { RegionData region = m_Database.Get(regionID, scopeID); - return Convert.ToInt32(region.Data["flags"]); + int flags = Convert.ToInt32(region.Data["flags"]); + //m_log.DebugFormat("[GRID SERVICE]: Request for flags of {0}: {1}", regionID, flags); + return flags; } private void HandleShowRegion(string module, string[] cmd) -- cgit v1.1 From 8ddf787cfd090fc8f2715a6f2a5329348a12e28b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 24 Jan 2010 16:00:28 -0800 Subject: Hypergrid map search back on, this time with a config var in the grid service. --- OpenSim/Services/GridService/GridService.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index b86fd4d..515d620 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -54,6 +54,7 @@ namespace OpenSim.Services.GridService protected IAuthenticationService m_AuthenticationService = null; protected bool m_AllowDuplicateNames = false; + protected bool m_AllowHypergridMapSearch = false; public GridService(IConfigSource config) : base(config) @@ -74,6 +75,7 @@ namespace OpenSim.Services.GridService m_AuthenticationService = ServerUtils.LoadPlugin(authService, args); } m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames); + m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch); } if (m_RootInstance == null) @@ -327,6 +329,13 @@ namespace OpenSim.Services.GridService } } + if (m_AllowHypergridMapSearch && rdatas.Count == 0 && name.Contains(".")) + { + GridRegion r = m_HypergridLinker.LinkRegion(scopeID, name); + if (r != null) + rinfos.Add(r); + } + return rinfos; } @@ -410,9 +419,14 @@ namespace OpenSim.Services.GridService { RegionData region = m_Database.Get(regionID, scopeID); - int flags = Convert.ToInt32(region.Data["flags"]); - //m_log.DebugFormat("[GRID SERVICE]: Request for flags of {0}: {1}", regionID, flags); - return flags; + if (region != null) + { + int flags = Convert.ToInt32(region.Data["flags"]); + //m_log.DebugFormat("[GRID SERVICE]: Request for flags of {0}: {1}", regionID, flags); + return flags; + } + else + return -1; } private void HandleShowRegion(string module, string[] cmd) -- cgit v1.1 From 35a245b67a44eaa62dbf7951646ad9818caa8b02 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 31 Jan 2010 22:35:23 -0800 Subject: Assorted bug fixes related to hyperlinking --- OpenSim/Services/GridService/GridService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 515d620..4dee7a4 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -329,7 +329,7 @@ namespace OpenSim.Services.GridService } } - if (m_AllowHypergridMapSearch && rdatas.Count == 0 && name.Contains(".")) + if (m_AllowHypergridMapSearch && rdatas == null || (rdatas != null && rdatas.Count == 0) && name.Contains(".")) { GridRegion r = m_HypergridLinker.LinkRegion(scopeID, name); if (r != null) @@ -412,6 +412,7 @@ namespace OpenSim.Services.GridService ret.Add(RegionData2RegionInfo(r)); } + m_log.DebugFormat("[GRID SERVICE]: Fallback returned {0} regions", ret.Count); return ret; } -- cgit v1.1 From 70de6956ff6a3d833149156b6293122ef734b73d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Feb 2010 18:56:44 -0800 Subject: Small bug fixes for making tests work. --- OpenSim/Services/GridService/GridService.cs | 30 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 4dee7a4..1368e46 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -82,20 +82,22 @@ namespace OpenSim.Services.GridService { 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); - + if (MainConsole.Instance != null) + { + 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); + } m_HypergridLinker = new HypergridLinker(m_config, this, m_Database); } } -- cgit v1.1 From 4b813932745775ef585a2cbca99233e57d20e13e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 12 Mar 2010 23:21:45 +0000 Subject: minor: remove some mono compiler warnings --- OpenSim/Services/GridService/GridService.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 1368e46..2faf018 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -123,8 +123,7 @@ namespace OpenSim.Services.GridService if ((rflags & OpenSim.Data.RegionFlags.Reservation) != 0) { // Regions reserved for the null key cannot be taken. - // - if (region.Data["PrincipalID"] == UUID.Zero.ToString()) + if ((string)region.Data["PrincipalID"] == UUID.Zero.ToString()) return "Region location us reserved"; // Treat it as an auth request @@ -132,7 +131,6 @@ namespace OpenSim.Services.GridService // NOTE: Fudging the flags value here, so these flags // should not be used elsewhere. Don't optimize // this with the later retrieval of the same flags! - // rflags |= OpenSim.Data.RegionFlags.Authenticate; } @@ -489,7 +487,7 @@ namespace OpenSim.Services.GridService f |= (OpenSim.Data.RegionFlags)val; } } - catch (Exception e) + catch (Exception) { MainConsole.Instance.Output("Error in flag specification: " + p); } -- cgit v1.1 From b10811a13b8fab81ce00d544d8efe081792bdaaa Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 3 May 2010 09:50:55 -0700 Subject: Assorted bug fixes in hypergrid linking. --- OpenSim/Services/GridService/GridService.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 2faf018..4089fce 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -315,6 +315,8 @@ namespace OpenSim.Services.GridService public List GetRegionsByName(UUID scopeID, string name, int maxNumber) { + m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name); + List rdatas = m_Database.Get("%" + name + "%", scopeID); int count = 0; @@ -329,7 +331,7 @@ namespace OpenSim.Services.GridService } } - if (m_AllowHypergridMapSearch && rdatas == null || (rdatas != null && rdatas.Count == 0) && name.Contains(".")) + if (m_AllowHypergridMapSearch && (rdatas == null || (rdatas != null && rdatas.Count == 0) && name.Contains("."))) { GridRegion r = m_HypergridLinker.LinkRegion(scopeID, name); if (r != null) @@ -397,6 +399,7 @@ namespace OpenSim.Services.GridService ret.Add(RegionData2RegionInfo(r)); } + m_log.DebugFormat("[GRID SERVICE]: GetDefaultRegions returning {0} regions", ret.Count); return ret; } -- cgit v1.1 From b233a4b2cab3a39f9edc17130cd7c2f2f807d6bb Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 9 May 2010 13:39:56 -0700 Subject: * Fixed spamming the assets table with map tiles. The tile image ID is now stored in regionsettings. Upon generation of a new tile image, the old one is deleted. Tested for SQLite and MySql standalone. * Fixed small bug with map search where the local sim regions weren't found. --- OpenSim/Services/GridService/GridService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 4089fce..7c98642 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -324,6 +324,7 @@ namespace OpenSim.Services.GridService if (rdatas != null) { + m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count); foreach (RegionData rdata in rdatas) { if (count++ < maxNumber) @@ -331,7 +332,7 @@ namespace OpenSim.Services.GridService } } - if (m_AllowHypergridMapSearch && (rdatas == null || (rdatas != null && rdatas.Count == 0) && name.Contains("."))) + if (m_AllowHypergridMapSearch && (rdatas == null || (rdatas != null && rdatas.Count == 0)) && name.Contains(".")) { GridRegion r = m_HypergridLinker.LinkRegion(scopeID, name); if (r != null) -- cgit v1.1 From 19558f380a1e9cbaff849eb15262266ea79b60d2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 13 Jun 2010 19:06:22 -0700 Subject: Fixes the long-standing RegionUp bug! Plus lots of other cleanups related to neighbours. --- OpenSim/Services/GridService/GridService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 7c98642..225530f 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -273,14 +273,15 @@ namespace OpenSim.Services.GridService if (region != null) { // Not really? Maybe? - List rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize, region.posY - (int)Constants.RegionSize, - region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID); + List rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize - 1, region.posY - (int)Constants.RegionSize - 1, + region.posX + (int)Constants.RegionSize + 1, region.posY + (int)Constants.RegionSize + 1, scopeID); foreach (RegionData rdata in rdatas) if (rdata.RegionID != regionID) rinfos.Add(RegionData2RegionInfo(rdata)); } + m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighours", region.RegionName, rinfos.Count); return rinfos; } -- cgit v1.1 From 7525f3a556116e47f629e09b42dd4753185166e2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 5 Jul 2010 04:19:53 -0700 Subject: Don't include hyperlinks as neighbors, even if grid operators have done the mistake of placing them as neighbors. This will not prevent further mess ups coming from that unsupported action. --- OpenSim/Services/GridService/GridService.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 225530f..46d72dc 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -278,7 +278,11 @@ namespace OpenSim.Services.GridService foreach (RegionData rdata in rdatas) if (rdata.RegionID != regionID) - rinfos.Add(RegionData2RegionInfo(rdata)); + { + int flags = Convert.ToInt32(rdata.Data["flags"]); + if ((flags & (int)Data.RegionFlags.Hyperlink) == 0) // no hyperlinks as neighbours + rinfos.Add(RegionData2RegionInfo(rdata)); + } } m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighours", region.RegionName, rinfos.Count); -- cgit v1.1 From 8c7fd12d5d63fb5e44070e57a4bef8e74986dea6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 30 Jul 2010 18:06:34 -0700 Subject: Bug fix: make m_HypergridLinker static. --- OpenSim/Services/GridService/GridService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 46d72dc..f49d86d 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -50,7 +50,7 @@ namespace OpenSim.Services.GridService private bool m_DeleteOnUnregister = true; private static GridService m_RootInstance = null; protected IConfigSource m_config; - protected HypergridLinker m_HypergridLinker; + protected static HypergridLinker m_HypergridLinker; protected IAuthenticationService m_AuthenticationService = null; protected bool m_AllowDuplicateNames = false; -- cgit v1.1 From 16bdb53683bf15a39f77603d558eda026fd4d21e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Wed, 4 Aug 2010 00:45:15 +0200 Subject: Allow specifying default region flags. Correct a typo. --- OpenSim/Services/GridService/GridService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index f49d86d..ebaed42 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -124,7 +124,7 @@ namespace OpenSim.Services.GridService { // Regions reserved for the null key cannot be taken. if ((string)region.Data["PrincipalID"] == UUID.Zero.ToString()) - return "Region location us reserved"; + return "Region location is reserved"; // Treat it as an auth request // @@ -210,6 +210,7 @@ namespace OpenSim.Services.GridService { int newFlags = 0; string regionName = rdata.RegionName.Trim().Replace(' ', '_'); + newFlags = ParseFlags(newFlags, gridConfig.GetString("DefaultRegionFlags", String.Empty)); newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + regionName, String.Empty)); newFlags = ParseFlags(newFlags, gridConfig.GetString("Region_" + rdata.RegionID.ToString(), String.Empty)); rdata.Data["flags"] = newFlags.ToString(); -- cgit v1.1 From 7e47ab746ef588648b8edbbc7cfb48c4d90c5e34 Mon Sep 17 00:00:00 2001 From: Marck Date: Fri, 6 Aug 2010 07:46:19 +0200 Subject: Allow creation of link regions if there is an existing region within a 4096 range. Also add GetHyperlinks() to the grid service. --- OpenSim/Services/GridService/GridService.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index ebaed42..79a45fe 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -426,6 +426,22 @@ namespace OpenSim.Services.GridService return ret; } + public List GetHyperlinks(UUID scopeID) + { + List ret = new List(); + + List regions = m_Database.GetHyperlinks(scopeID); + + foreach (RegionData r in regions) + { + if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) + ret.Add(RegionData2RegionInfo(r)); + } + + m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count); + return ret; + } + public int GetRegionFlags(UUID scopeID, UUID regionID) { RegionData region = m_Database.Get(regionID, scopeID); -- cgit v1.1 From 009053479302e7581a85c7574a6cc8eaa23745d8 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 6 Aug 2010 17:43:09 -0700 Subject: Added Check4096 config var under [GridService], at the request of many. Changed the iteration that Marck had on the Hyperlinker. ATTENTION! CONFIGURATION CHANGE AFFECTING Robust.HG.ini.example and StandaloneCommon.ini.example. --- OpenSim/Services/GridService/GridService.cs | 30 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 79a45fe..ce6f64b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -426,21 +426,21 @@ namespace OpenSim.Services.GridService return ret; } - public List GetHyperlinks(UUID scopeID) - { - List ret = new List(); - - List regions = m_Database.GetHyperlinks(scopeID); - - foreach (RegionData r in regions) - { - if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) - ret.Add(RegionData2RegionInfo(r)); - } - - m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count); - return ret; - } + public List GetHyperlinks(UUID scopeID) + { + List ret = new List(); + + List regions = m_Database.GetHyperlinks(scopeID); + + foreach (RegionData r in regions) + { + if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) + ret.Add(RegionData2RegionInfo(r)); + } + + m_log.DebugFormat("[GRID SERVICE]: Hyperlinks returned {0} regions", ret.Count); + return ret; + } public int GetRegionFlags(UUID scopeID, UUID regionID) { -- cgit v1.1 From 69acf9c79b9e83047c2a0494a6f96c7d33839d3b Mon Sep 17 00:00:00 2001 From: Jonathan Freedman Date: Sun, 3 Oct 2010 18:03:53 -0400 Subject: * additional serveruri cleanup --- OpenSim/Services/GridService/GridService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index ce6f64b..add1be0 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -479,7 +479,7 @@ namespace OpenSim.Services.GridService OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); MainConsole.Instance.Output(String.Format("{0,-20} {1}\n{2,-20} {3}\n{4,-39} {5}\n\n", r.RegionName, r.RegionID, - String.Format("{0},{1}", r.posX, r.posY), "http://" + r.Data["serverIP"].ToString() + ":" + r.Data["serverPort"].ToString(), + String.Format("{0},{1}", r.posX, r.posY), r.Data["serverURI"], r.Data["owner_uuid"].ToString(), flags.ToString())); } return; -- cgit v1.1 From 7de30cc57b5f9ad895e865736550c8d7a433ce55 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 18 Oct 2010 22:58:04 +0100 Subject: Change substring matching to prefix matching in region search. This affects both map and login, as they use the same method. --- OpenSim/Services/GridService/GridService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index ce6f64b..e7988d6 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -323,7 +323,7 @@ namespace OpenSim.Services.GridService { m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name); - List rdatas = m_Database.Get("%" + name + "%", scopeID); + List rdatas = m_Database.Get(name + "%", scopeID); int count = 0; List rinfos = new List(); -- cgit v1.1 From 1613d89383574f7bba3102376e6f3a2ee99b1270 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 4 Feb 2011 20:51:51 +0000 Subject: minor: Correct misspelling of neighbour in log messages. Thanks Fly-Man- --- OpenSim/Services/GridService/GridService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 125c2be..aeff9b5 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -286,7 +286,7 @@ namespace OpenSim.Services.GridService } } - m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighours", region.RegionName, rinfos.Count); + m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighbours", region.RegionName, rinfos.Count); return rinfos; } -- cgit v1.1 From 8249d77991352697b4972f7109c014db0ebd5f68 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 18 Feb 2011 23:25:59 +0000 Subject: If GridService.GetNeighbours() could not find the region then log a warning rather than causing a null reference on the normal log line This also extends the TestChildAgentEstablished() test to actually activate the EntityTransferModule, though the test is not yet viable --- OpenSim/Services/GridService/GridService.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index aeff9b5..985d77b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -271,6 +271,7 @@ namespace OpenSim.Services.GridService { List rinfos = new List(); RegionData region = m_Database.Get(regionID, scopeID); + if (region != null) { // Not really? Maybe? @@ -278,15 +279,24 @@ namespace OpenSim.Services.GridService region.posX + (int)Constants.RegionSize + 1, region.posY + (int)Constants.RegionSize + 1, scopeID); foreach (RegionData rdata in rdatas) + { if (rdata.RegionID != regionID) { int flags = Convert.ToInt32(rdata.Data["flags"]); if ((flags & (int)Data.RegionFlags.Hyperlink) == 0) // no hyperlinks as neighbours rinfos.Add(RegionData2RegionInfo(rdata)); } + } + m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighbours", region.RegionName, rinfos.Count); } - m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighbours", region.RegionName, rinfos.Count); + else + { + m_log.WarnFormat( + "[GRID SERVICE]: GetNeighbours() called for scope {0}, region {1} but no such region found", + scopeID, regionID); + } + return rinfos; } -- cgit v1.1 From 8d33a2eaa10ed75146f45cca4d6c19ac814d5fee Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 2 Aug 2011 00:26:17 +0100 Subject: In GridService, have GetRegionByName() call GetRegionsByName() with a max return of 1 instead of duplicating code. This also fixes the problem where this method would not return a hypergrid region, unlike GetRegionsByName() --- OpenSim/Services/GridService/GridService.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 985d77b..1253b5a 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -322,16 +322,17 @@ namespace OpenSim.Services.GridService public GridRegion GetRegionByName(UUID scopeID, string regionName) { - List rdatas = m_Database.Get(regionName + "%", scopeID); - if ((rdatas != null) && (rdatas.Count > 0)) - return RegionData2RegionInfo(rdatas[0]); // get the first + List rinfos = GetRegionsByName(scopeID, regionName, 1); + + if (rinfos.Count > 0) + return rinfos[0]; return null; } public List GetRegionsByName(UUID scopeID, string name, int maxNumber) { - m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name); +// m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name); List rdatas = m_Database.Get(name + "%", scopeID); -- cgit v1.1 From e6fb9d74ef10e381731b31367a96ad751484a867 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 2 Aug 2011 00:40:23 +0100 Subject: Revert "In GridService, have GetRegionByName() call GetRegionsByName() with a max return of 1 instead of duplicating code." This reverts commit 8d33a2eaa10ed75146f45cca4d6c19ac814d5fee. Better fix will be along in a minute --- OpenSim/Services/GridService/GridService.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 1253b5a..985d77b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -322,17 +322,16 @@ namespace OpenSim.Services.GridService public GridRegion GetRegionByName(UUID scopeID, string regionName) { - List rinfos = GetRegionsByName(scopeID, regionName, 1); - - if (rinfos.Count > 0) - return rinfos[0]; + List rdatas = m_Database.Get(regionName + "%", scopeID); + if ((rdatas != null) && (rdatas.Count > 0)) + return RegionData2RegionInfo(rdatas[0]); // get the first return null; } public List GetRegionsByName(UUID scopeID, string name, int maxNumber) { -// m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name); + m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name); List rdatas = m_Database.Get(name + "%", scopeID); -- cgit v1.1 From 17e9d61f4383627434b7b8249cea1a487f001099 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 2 Aug 2011 00:52:48 +0100 Subject: Change GridService.GetRegionByName() to only return info if there is an exact region name match, unlike GetRegionsByName() This should fix the first part of http://opensimulator.org/mantis/view.php?id=5606, and maybe 5605. Thanks to Melanie for helping with this. --- OpenSim/Services/GridService/GridService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 985d77b..a6fbc00 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -322,7 +322,7 @@ namespace OpenSim.Services.GridService public GridRegion GetRegionByName(UUID scopeID, string regionName) { - List rdatas = m_Database.Get(regionName + "%", scopeID); + List rdatas = m_Database.Get(regionName, scopeID); if ((rdatas != null) && (rdatas.Count > 0)) return RegionData2RegionInfo(rdatas[0]); // get the first -- cgit v1.1 From b7f81d34928cb2d7296b91a8569adb488c264e36 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 2 Aug 2011 01:06:32 +0100 Subject: If GetRegionByName can't match something in the local db, then search the hypergrid if that functionality has been enabled. This should fix the problem today where old style HG addresses (e.g. "hg.osgrid.org:80:Vue-6400") stopped working since 8c3eb324c4b666e7abadef4a714d1bd8d5f71ac2 --- OpenSim/Services/GridService/GridService.cs | 33 +++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index a6fbc00..f663dd6 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -320,18 +320,25 @@ namespace OpenSim.Services.GridService return null; } - public GridRegion GetRegionByName(UUID scopeID, string regionName) + public GridRegion GetRegionByName(UUID scopeID, string name) { - List rdatas = m_Database.Get(regionName, scopeID); + List rdatas = m_Database.Get(name, scopeID); if ((rdatas != null) && (rdatas.Count > 0)) return RegionData2RegionInfo(rdatas[0]); // get the first + if (m_AllowHypergridMapSearch) + { + GridRegion r = GetHypergridRegionByName(scopeID, name); + if (r != null) + return r; + } + return null; } public List GetRegionsByName(UUID scopeID, string name, int maxNumber) { - m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name); +// m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name); List rdatas = m_Database.Get(name + "%", scopeID); @@ -340,7 +347,7 @@ namespace OpenSim.Services.GridService if (rdatas != null) { - m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count); +// m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count); foreach (RegionData rdata in rdatas) { if (count++ < maxNumber) @@ -348,9 +355,9 @@ namespace OpenSim.Services.GridService } } - if (m_AllowHypergridMapSearch && (rdatas == null || (rdatas != null && rdatas.Count == 0)) && name.Contains(".")) + if (m_AllowHypergridMapSearch && (rdatas == null || (rdatas != null && rdatas.Count == 0))) { - GridRegion r = m_HypergridLinker.LinkRegion(scopeID, name); + GridRegion r = GetHypergridRegionByName(scopeID, name); if (r != null) rinfos.Add(r); } @@ -358,6 +365,20 @@ namespace OpenSim.Services.GridService return rinfos; } + /// + /// Get a hypergrid region. + /// + /// + /// + /// null if no hypergrid region could be found. + protected GridRegion GetHypergridRegionByName(UUID scopeID, string name) + { + if (name.Contains(".")) + return m_HypergridLinker.LinkRegion(scopeID, name); + else + return null; + } + public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; -- cgit v1.1 From f18780d0e3a6e5130b1c1d86c71630801dc70c57 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 5 Aug 2011 22:56:53 +0100 Subject: Get "show region" command in GridService to show grid co-ordinates rather than meters co-ord. This makes it consistent with "show regions" Addresses http://opensimulator.org/mantis/view.php?id=5619 --- OpenSim/Services/GridService/GridService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index f663dd6..0a4372a 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -510,8 +510,9 @@ namespace OpenSim.Services.GridService OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); MainConsole.Instance.Output(String.Format("{0,-20} {1}\n{2,-20} {3}\n{4,-39} {5}\n\n", r.RegionName, r.RegionID, - String.Format("{0},{1}", r.posX, r.posY), r.Data["serverURI"], - r.Data["owner_uuid"].ToString(), flags.ToString())); + String.Format("{0},{1}", r.posX / Constants.RegionSize, r.posY / Constants.RegionSize), + r.Data["serverURI"], + r.Data["owner_uuid"], flags)); } return; } -- cgit v1.1 From a6c5e00c45b3d64b4e912a65c8ed7f31eb643759 Mon Sep 17 00:00:00 2001 From: Pixel Tomsen Date: Thu, 6 Oct 2011 21:04:20 +0200 Subject: GridService - Region UUID can not be NULL http://opensimulator.org/mantis/view.php?id=3426 --- OpenSim/Services/GridService/GridService.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 0a4372a..0aeae67 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -107,6 +107,8 @@ namespace OpenSim.Services.GridService public string RegisterRegion(UUID scopeID, GridRegion regionInfos) { IConfig gridConfig = m_config.Configs["GridService"]; + // First Check for invalidate NULL-UUID, if true fast quit + if (regionInfos.RegionID == UUID.Zero) return "Invalidate RegionID - can not be UUID-NULL"; // This needs better sanity testing. What if regionInfo is registering in // overlapping coords? RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); -- cgit v1.1 From 156385f48b2b2829f2d427c72f269406c46019fa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 8 Oct 2011 02:15:04 +0100 Subject: Tweak to language of last commit in rejecting UUID.Zero in GridService.RegisterRegion() Allowing regions with UUID.Zero causes problems elsewhere according to http://opensimulator.org/mantis/view.php?id=3426 It's probably a bad idea to allow these in any case. --- OpenSim/Services/GridService/GridService.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 0aeae67..05cfe5f 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -107,8 +107,10 @@ namespace OpenSim.Services.GridService public string RegisterRegion(UUID scopeID, GridRegion regionInfos) { IConfig gridConfig = m_config.Configs["GridService"]; - // First Check for invalidate NULL-UUID, if true fast quit - if (regionInfos.RegionID == UUID.Zero) return "Invalidate RegionID - can not be UUID-NULL"; + + if (regionInfos.RegionID == UUID.Zero) + return "Invalid RegionID - cannot be zero UUID"; + // This needs better sanity testing. What if regionInfo is registering in // overlapping coords? RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); -- cgit v1.1 From 01ae916bad672722aa62ee712b7b580d6f5f4370 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 19 Nov 2011 00:07:34 +0000 Subject: Don't register a region twice on both official registration and maptile regeneration. Maptile storage appears orthogonal to region registration --- OpenSim/Services/GridService/GridService.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 05cfe5f..768e4e1 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -156,6 +156,7 @@ namespace OpenSim.Services.GridService regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); return "Region overlaps another region"; } + if ((region != null) && (region.RegionID == regionInfos.RegionID) && ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) { -- cgit v1.1 From 7a180781778a6369799c244ab95f5e6844b3be05 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 19 Nov 2011 00:10:29 +0000 Subject: improve region deregistration log message --- OpenSim/Services/GridService/GridService.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 768e4e1..82a9193 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -244,11 +244,14 @@ namespace OpenSim.Services.GridService public bool DeregisterRegion(UUID regionID) { - m_log.DebugFormat("[GRID SERVICE]: Region {0} deregistered", regionID); RegionData region = m_Database.Get(regionID, UUID.Zero); if (region == null) return false; + m_log.DebugFormat( + "[GRID SERVICE]: Degistering region {0} ({1}) at {2}-{3}", + region.RegionName, region.RegionID, region.posX, region.posY); + int flags = Convert.ToInt32(region.Data["flags"]); if (!m_DeleteOnUnregister || (flags & (int)OpenSim.Data.RegionFlags.Persistent) != 0) -- cgit v1.1 From d05d065d859c8877cb910cf5748e32e1560086a6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 19 Nov 2011 00:29:52 +0000 Subject: Improve some grid region log messages to express regions at co-ordinate (e.g. 1000, 1000) rather than meter positions (256000, 256000) --- OpenSim/Services/GridService/GridService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 82a9193..eae10e8 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -237,7 +237,7 @@ namespace OpenSim.Services.GridService } m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}", - regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); + regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY); return String.Empty; } @@ -250,8 +250,8 @@ namespace OpenSim.Services.GridService m_log.DebugFormat( "[GRID SERVICE]: Degistering region {0} ({1}) at {2}-{3}", - region.RegionName, region.RegionID, region.posX, region.posY); - + region.RegionName, region.RegionID, region.coordX, region.coordY); + int flags = Convert.ToInt32(region.Data["flags"]); if (!m_DeleteOnUnregister || (flags & (int)OpenSim.Data.RegionFlags.Persistent) != 0) -- cgit v1.1 From 10a23a823edb261af2c0b7895ce0898ea6918ef1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 19 Nov 2011 01:16:07 +0000 Subject: Get rid of the spurious [WEB UTIL] couldn't decode : Invalid character 'O' in input string messages These are just the result of an attempt to canonicalize received messages - it's not important that we constantly log them. Also finally get the deregister grid service message working properly --- OpenSim/Services/GridService/GridService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index eae10e8..89f0716 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -249,7 +249,7 @@ namespace OpenSim.Services.GridService return false; m_log.DebugFormat( - "[GRID SERVICE]: Degistering region {0} ({1}) at {2}-{3}", + "[GRID SERVICE]: Deregistering region {0} ({1}) at {2}-{3}", region.RegionName, region.RegionID, region.coordX, region.coordY); int flags = Convert.ToInt32(region.Data["flags"]); @@ -296,7 +296,7 @@ namespace OpenSim.Services.GridService } } - m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighbours", region.RegionName, rinfos.Count); +// m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighbours", region.RegionName, rinfos.Count); } else { -- cgit v1.1 From 749c3fef8ad2d3af97fcd9ab9c72740675e46715 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 8 Mar 2012 01:51:37 +0000 Subject: Change "help" to display categories/module list then "help " to display commands in a category. This is to deal with the hundred lines of command splurge when one previously typed "help" Modelled somewhat on the mysql console One can still type help to get per command help at any point. Categories capitalized to avoid conflict with the all-lowercase commands (except for commander system, as of yet). Does not affect command parsing or any other aspects of the console apart from the help system. Backwards compatible with existing modules. --- OpenSim/Services/GridService/GridService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 89f0716..3dc87bc 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -84,14 +84,14 @@ namespace OpenSim.Services.GridService if (MainConsole.Instance != null) { - MainConsole.Instance.Commands.AddCommand("grid", true, + MainConsole.Instance.Commands.AddCommand("Regions", true, "show region", "show region ", "Show details on a region", String.Empty, HandleShowRegion); - MainConsole.Instance.Commands.AddCommand("grid", true, + MainConsole.Instance.Commands.AddCommand("Regions", true, "set region flags", "set region flags ", "Set database flags for region", -- cgit v1.1 From 050007b44da97bf155fca95cadc32cb27924e263 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 May 2012 02:30:16 +0100 Subject: Lay out "show region" information in an easier to read line by line format --- OpenSim/Services/GridService/GridService.cs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 3dc87bc..b17fca7 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -509,19 +509,21 @@ namespace OpenSim.Services.GridService return; } - MainConsole.Instance.Output("Region Name Region UUID"); - MainConsole.Instance.Output("Location URI"); - MainConsole.Instance.Output("Owner ID Flags"); - MainConsole.Instance.Output("-------------------------------------------------------------------------------"); + ICommandConsole con = MainConsole.Instance; + foreach (RegionData r in regions) { OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); - MainConsole.Instance.Output(String.Format("{0,-20} {1}\n{2,-20} {3}\n{4,-39} {5}\n\n", - r.RegionName, r.RegionID, - String.Format("{0},{1}", r.posX / Constants.RegionSize, r.posY / Constants.RegionSize), - r.Data["serverURI"], - r.Data["owner_uuid"], flags)); + + con.OutputFormat("{0,-11}: {1}", "Region Name", r.RegionName); + con.OutputFormat("{0,-11}: {1}", "Region ID", r.RegionID); + con.OutputFormat("{0,-11}: {1}", "Location", r.coordX, r.coordY); + con.OutputFormat("{0,-11}: {1}", "URI", r.Data["serverURI"]); + con.OutputFormat("{0,-11}: {1}", "Owner ID", r.Data["owner_uuid"]); + con.OutputFormat("{0,-11}: {1}", "Flags", flags); + con.Output("\n"); } + return; } -- cgit v1.1 From c6ce41bfbab310eae2366ad494a0dbb42cebc070 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 May 2012 02:31:53 +0100 Subject: Add missing Y co-ord in "show region" console command information --- OpenSim/Services/GridService/GridService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index b17fca7..9d81eb5 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -517,7 +517,7 @@ namespace OpenSim.Services.GridService con.OutputFormat("{0,-11}: {1}", "Region Name", r.RegionName); con.OutputFormat("{0,-11}: {1}", "Region ID", r.RegionID); - con.OutputFormat("{0,-11}: {1}", "Location", r.coordX, r.coordY); + con.OutputFormat("{0,-11}: {1},{2}", "Location", r.coordX, r.coordY); con.OutputFormat("{0,-11}: {1}", "URI", r.Data["serverURI"]); con.OutputFormat("{0,-11}: {1}", "Owner ID", r.Data["owner_uuid"]); con.OutputFormat("{0,-11}: {1}", "Flags", flags); -- cgit v1.1 From 059a1e90b92c3c1ca027c0ec59f3628d87a954a6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 23 May 2012 03:19:25 +0100 Subject: Add ConsoleDisplayList for more consistent formatting of console output in list form. Convert "show region" to use this structure rather than hand-constructing --- OpenSim/Services/GridService/GridService.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 9d81eb5..8a60ca5 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -509,19 +509,19 @@ namespace OpenSim.Services.GridService return; } - ICommandConsole con = MainConsole.Instance; - foreach (RegionData r in regions) { OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); - con.OutputFormat("{0,-11}: {1}", "Region Name", r.RegionName); - con.OutputFormat("{0,-11}: {1}", "Region ID", r.RegionID); - con.OutputFormat("{0,-11}: {1},{2}", "Location", r.coordX, r.coordY); - con.OutputFormat("{0,-11}: {1}", "URI", r.Data["serverURI"]); - con.OutputFormat("{0,-11}: {1}", "Owner ID", r.Data["owner_uuid"]); - con.OutputFormat("{0,-11}: {1}", "Flags", flags); - con.Output("\n"); + ConsoleDisplayList dispList = new ConsoleDisplayList(); + dispList.AddRow("Region Name", r.RegionName); + dispList.AddRow("Region ID", r.RegionID); + dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY)); + dispList.AddRow("URI", r.Data["serverURI"]); + dispList.AddRow("Owner ID", r.Data["owner_uuid"]); + dispList.AddRow("Flags", flags); + + MainConsole.Instance.Output(dispList.ToString()); } return; -- cgit v1.1 From 5145356467244d6a4d66cd36eef22a23d6fc73a1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 13 Jun 2012 03:49:22 +0100 Subject: Add "deregister region" by uuid command to grid service to allow manual deregistration of simulators. Useful if a simulator has crashed without removing its regions and those regions have been reconfigured differently --- OpenSim/Services/GridService/GridService.cs | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 8a60ca5..11897f8 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -85,6 +85,13 @@ namespace OpenSim.Services.GridService if (MainConsole.Instance != null) { MainConsole.Instance.Commands.AddCommand("Regions", true, + "deregister region", + "deregister region ", + "Deregister a region manually.", + String.Empty, + HandleDeregisterRegion); + + MainConsole.Instance.Commands.AddCommand("Regions", true, "show region", "show region ", "Show details on a region", @@ -495,6 +502,44 @@ namespace OpenSim.Services.GridService return -1; } + private void HandleDeregisterRegion(string module, string[] cmd) + { + if (cmd.Length != 3) + { + MainConsole.Instance.Output("Syntax: degregister region "); + return; + } + + string rawRegionUuid = cmd[2]; + UUID regionUuid; + + if (!UUID.TryParse(rawRegionUuid, out regionUuid)) + { + MainConsole.Instance.OutputFormat("{0} is not a valid region uuid", rawRegionUuid); + return; + } + + GridRegion region = GetRegionByUUID(UUID.Zero, regionUuid); + + if (region == null) + { + MainConsole.Instance.OutputFormat("No region with UUID {0}", regionUuid); + return; + } + + if (DeregisterRegion(regionUuid)) + { + MainConsole.Instance.OutputFormat("Deregistered {0} {1}", region.RegionName, regionUuid); + } + else + { + // I don't think this can ever occur if we know that the region exists. + MainConsole.Instance.OutputFormat("Error deregistering {0} {1}", region.RegionName, regionUuid); + } + + return; + } + private void HandleShowRegion(string module, string[] cmd) { if (cmd.Length != 3) -- cgit v1.1 From 854f2a913cdedfa252b69d5c3118d35604ab6b4a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 25 Jun 2012 23:55:14 +0100 Subject: Add "show region at" command to grid service to get the details of a region at a specific location. "show region" command becomes "show region name" to disambiguate This is the same format as used by "show object name", etc. "deregister region" also becomes "deregister region id" --- OpenSim/Services/GridService/GridService.cs | 91 ++++++++++++++++++++++------- 1 file changed, 69 insertions(+), 22 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 11897f8..7d2dadb 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -85,20 +85,27 @@ namespace OpenSim.Services.GridService if (MainConsole.Instance != null) { MainConsole.Instance.Commands.AddCommand("Regions", true, - "deregister region", - "deregister region ", + "deregister region id", + "deregister region id ", "Deregister a region manually.", String.Empty, HandleDeregisterRegion); MainConsole.Instance.Commands.AddCommand("Regions", true, - "show region", - "show region ", + "show region name", + "show region name ", "Show details on a region", String.Empty, HandleShowRegion); MainConsole.Instance.Commands.AddCommand("Regions", true, + "show region at", + "show region at ", + "Show details on a region at the given co-ordinate.", + "For example, show region at 1000 1000", + HandleShowRegionAt); + + MainConsole.Instance.Commands.AddCommand("Regions", true, "set region flags", "set region flags ", "Set database flags for region", @@ -504,13 +511,13 @@ namespace OpenSim.Services.GridService private void HandleDeregisterRegion(string module, string[] cmd) { - if (cmd.Length != 3) + if (cmd.Length != 4) { - MainConsole.Instance.Output("Syntax: degregister region "); + MainConsole.Instance.Output("Syntax: degregister region id "); return; } - string rawRegionUuid = cmd[2]; + string rawRegionUuid = cmd[3]; UUID regionUuid; if (!UUID.TryParse(rawRegionUuid, out regionUuid)) @@ -542,34 +549,74 @@ namespace OpenSim.Services.GridService private void HandleShowRegion(string module, string[] cmd) { - if (cmd.Length != 3) + if (cmd.Length != 4) { - MainConsole.Instance.Output("Syntax: show region "); + MainConsole.Instance.Output("Syntax: show region name "); return; } - List regions = m_Database.Get(cmd[2], UUID.Zero); + + string regionName = cmd[3]; + + List regions = m_Database.Get(regionName, UUID.Zero); if (regions == null || regions.Count < 1) { - MainConsole.Instance.Output("Region not found"); + MainConsole.Instance.Output("No region with name {0} found", regionName); return; } - foreach (RegionData r in regions) + OutputRegionsToConsole(regions); + } + + private void HandleShowRegionAt(string module, string[] cmd) + { + if (cmd.Length != 5) { - OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); + MainConsole.Instance.Output("Syntax: show region at "); + return; + } - ConsoleDisplayList dispList = new ConsoleDisplayList(); - dispList.AddRow("Region Name", r.RegionName); - dispList.AddRow("Region ID", r.RegionID); - dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY)); - dispList.AddRow("URI", r.Data["serverURI"]); - dispList.AddRow("Owner ID", r.Data["owner_uuid"]); - dispList.AddRow("Flags", flags); + int x, y; + if (!int.TryParse(cmd[3], out x)) + { + MainConsole.Instance.Output("x-coord must be an integer"); + return; + } - MainConsole.Instance.Output(dispList.ToString()); + if (!int.TryParse(cmd[4], out y)) + { + MainConsole.Instance.Output("y-coord must be an integer"); + return; } - return; + RegionData region = m_Database.Get(x * (int)Constants.RegionSize, y * (int)Constants.RegionSize, UUID.Zero); + if (region == null) + { + MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y); + return; + } + + OutputRegionToConsole(region); + } + + private void OutputRegionToConsole(RegionData r) + { + OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); + + ConsoleDisplayList dispList = new ConsoleDisplayList(); + dispList.AddRow("Region Name", r.RegionName); + dispList.AddRow("Region ID", r.RegionID); + dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY)); + dispList.AddRow("URI", r.Data["serverURI"]); + dispList.AddRow("Owner ID", r.Data["owner_uuid"]); + dispList.AddRow("Flags", flags); + + MainConsole.Instance.Output(dispList.ToString()); + } + + private void OutputRegionsToConsole(List regions) + { + foreach (RegionData r in regions) + OutputRegionToConsole(r); } private int ParseFlags(int prev, string flags) -- cgit v1.1 From 5292b8b8be85696604f4f8086376da568b8342b5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 26 Jun 2012 00:34:37 +0100 Subject: Add "show regions" console command to ROBUST to show all regions currently registered. Command is not added in standalone, which has its own version of "show regions" that can also show estate name --- OpenSim/Services/GridService/GridService.cs | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 7d2dadb..e4c3246 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -91,6 +91,18 @@ namespace OpenSim.Services.GridService String.Empty, HandleDeregisterRegion); + // A messy way of stopping this command being added if we are in standalone (since the simulator + // has an identically named command + // + // XXX: We're relying on the OpenSimulator version being registered first, which is not well defined. + if (MainConsole.Instance.Commands.Resolve(new string[] { "show", "regions" }).Length == 0) + MainConsole.Instance.Commands.AddCommand("Regions", true, + "show regions", + "show all regions", + "Show details on all regions", + String.Empty, + HandleShowRegions); + MainConsole.Instance.Commands.AddCommand("Regions", true, "show region name", "show region name ", @@ -547,6 +559,20 @@ namespace OpenSim.Services.GridService return; } + private void HandleShowRegions(string module, string[] cmd) + { + if (cmd.Length != 2) + { + MainConsole.Instance.Output("Syntax: show regions"); + return; + } + + List regions = m_Database.Get(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue, UUID.Zero); + + OutputRegionsToConsoleSummary(regions); + } + + private void HandleShowRegion(string module, string[] cmd) { if (cmd.Length != 4) @@ -619,6 +645,24 @@ namespace OpenSim.Services.GridService OutputRegionToConsole(r); } + private void OutputRegionsToConsoleSummary(List regions) + { + ConsoleDisplayTable dispTable = new ConsoleDisplayTable(); + dispTable.Columns.Add(new ConsoleDisplayTableColumn("Name", 16)); + dispTable.Columns.Add(new ConsoleDisplayTableColumn("ID", 36)); + dispTable.Columns.Add(new ConsoleDisplayTableColumn("Owner ID", 36)); + dispTable.Columns.Add(new ConsoleDisplayTableColumn("Flags", 60)); + + foreach (RegionData r in regions) + { + OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); + dispTable.Rows.Add( + new ConsoleDisplayTableRow(new List { r.RegionName, r.RegionID.ToString(), r.Data["owner_uuid"].ToString(), flags.ToString() })); + } + + MainConsole.Instance.Output(dispTable.ToString()); + } + private int ParseFlags(int prev, string flags) { OpenSim.Data.RegionFlags f = (OpenSim.Data.RegionFlags)prev; -- cgit v1.1 From 1f22b29ca3d172624087185a4e9056a931f19703 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 26 Jun 2012 00:40:46 +0100 Subject: Add much easier ConsoleDisplayTable AddColumn() and AddRow() methods. Use these for new "show regions" command rather than old cumbersome stuff. --- OpenSim/Services/GridService/GridService.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index e4c3246..842a697 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -648,16 +648,15 @@ namespace OpenSim.Services.GridService private void OutputRegionsToConsoleSummary(List regions) { ConsoleDisplayTable dispTable = new ConsoleDisplayTable(); - dispTable.Columns.Add(new ConsoleDisplayTableColumn("Name", 16)); - dispTable.Columns.Add(new ConsoleDisplayTableColumn("ID", 36)); - dispTable.Columns.Add(new ConsoleDisplayTableColumn("Owner ID", 36)); - dispTable.Columns.Add(new ConsoleDisplayTableColumn("Flags", 60)); + dispTable.AddColumn("Name", 16); + dispTable.AddColumn("ID", 36); + dispTable.AddColumn("Owner ID", 36); + dispTable.AddColumn("Flags", 60); foreach (RegionData r in regions) { OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); - dispTable.Rows.Add( - new ConsoleDisplayTableRow(new List { r.RegionName, r.RegionID.ToString(), r.Data["owner_uuid"].ToString(), flags.ToString() })); + dispTable.AddRow(r.RegionName, r.RegionID.ToString(), r.Data["owner_uuid"].ToString(), flags.ToString()); } MainConsole.Instance.Output(dispTable.ToString()); -- cgit v1.1 From 25245179868990b07d4431e2dc2e800a4de372e5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 26 Jun 2012 22:54:41 +0100 Subject: minor: correct GridService "show regions" cibsike cinnabd usage statement --- OpenSim/Services/GridService/GridService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 842a697..36cd573 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -98,7 +98,7 @@ namespace OpenSim.Services.GridService if (MainConsole.Instance.Commands.Resolve(new string[] { "show", "regions" }).Length == 0) MainConsole.Instance.Commands.AddCommand("Regions", true, "show regions", - "show all regions", + "show regions", "Show details on all regions", String.Empty, HandleShowRegions); -- cgit v1.1 From 97437feb06060fa58f8209e32c362bfe91c279f5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 26 Jun 2012 23:05:10 +0100 Subject: Show region positions in "show regions" robust console command --- OpenSim/Services/GridService/GridService.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 36cd573..aab403a 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -650,13 +650,19 @@ namespace OpenSim.Services.GridService ConsoleDisplayTable dispTable = new ConsoleDisplayTable(); dispTable.AddColumn("Name", 16); dispTable.AddColumn("ID", 36); + dispTable.AddColumn("Position", 11); dispTable.AddColumn("Owner ID", 36); dispTable.AddColumn("Flags", 60); foreach (RegionData r in regions) { OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); - dispTable.AddRow(r.RegionName, r.RegionID.ToString(), r.Data["owner_uuid"].ToString(), flags.ToString()); + dispTable.AddRow( + r.RegionName, + r.RegionID.ToString(), + string.Format("{0},{1}", r.coordX, r.coordY), + r.Data["owner_uuid"].ToString(), + flags.ToString()); } MainConsole.Instance.Output(dispTable.ToString()); -- cgit v1.1 From 6ea95a329451c803048f179abb4b4ea5014dd7b1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 25 Aug 2012 17:32:00 +0100 Subject: Fix and refactor region registration. Reorder checks to short-curcuit expensive and destructive ones. Properly fix region reservation and authentication. Make region moves and flags preservation work again as intended. Prevent failes reservation take-over from damging reservation data. --- OpenSim/Services/GridService/GridService.cs | 53 +++++++++++++++-------------- 1 file changed, 28 insertions(+), 25 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index aab403a..5bdea06 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -137,9 +137,14 @@ namespace OpenSim.Services.GridService if (regionInfos.RegionID == UUID.Zero) return "Invalid RegionID - cannot be zero UUID"; - // This needs better sanity testing. What if regionInfo is registering in - // overlapping coords? RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); + if ((region != null) && (region.RegionID != regionInfos.RegionID)) + { + m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", + regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); + return "Region overlaps another region"; + } + if (region != null) { // There is a preexisting record @@ -176,19 +181,36 @@ namespace OpenSim.Services.GridService } } - if ((region != null) && (region.RegionID != regionInfos.RegionID)) + // If we get here, the destination is clear. Now for the real check. + + if (!m_AllowDuplicateNames) { - m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", - regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); - return "Region overlaps another region"; + List dupe = m_Database.Get(regionInfos.RegionName, scopeID); + if (dupe != null && dupe.Count > 0) + { + foreach (RegionData d in dupe) + { + if (d.RegionID != regionInfos.RegionID) + { + m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.", + regionInfos.RegionName, regionInfos.RegionID); + return "Duplicate region name"; + } + } + } } + // If there is an old record for us, delete it if it is elsewhere. + region = m_Database.Get(regionInfos.RegionID, scopeID); if ((region != null) && (region.RegionID == regionInfos.RegionID) && ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) { if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.NoMove) != 0) return "Can't move this region"; + if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) + return "Region locked out"; + // Region reregistering in other coordinates. Delete the old entry m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.", regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); @@ -203,23 +225,6 @@ namespace OpenSim.Services.GridService } } - if (!m_AllowDuplicateNames) - { - List dupe = m_Database.Get(regionInfos.RegionName, scopeID); - if (dupe != null && dupe.Count > 0) - { - foreach (RegionData d in dupe) - { - if (d.RegionID != regionInfos.RegionID) - { - m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.", - regionInfos.RegionName, regionInfos.RegionID); - return "Duplicate region name"; - } - } - } - } - // Everything is ok, let's register RegionData rdata = RegionInfo2RegionData(regionInfos); rdata.ScopeID = scopeID; @@ -227,8 +232,6 @@ namespace OpenSim.Services.GridService if (region != null) { int oldFlags = Convert.ToInt32(region.Data["flags"]); - if ((oldFlags & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) - return "Region locked out"; oldFlags &= ~(int)OpenSim.Data.RegionFlags.Reservation; -- cgit v1.1 From 73c9abf5f2e2017bf924d6183502e337d28a7232 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 9 Oct 2012 01:35:27 +0100 Subject: Move OpenSim.Data.RegionFlags -> OpenSim.Framework.RegionFlags to make it easier for other code to use (e.g. LSL_Api) without having to reference OpenSim.Data just for this. --- OpenSim/Services/GridService/GridService.cs | 48 ++++++++++++++--------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 5bdea06..ee3b858 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -151,11 +151,11 @@ namespace OpenSim.Services.GridService // // Get it's flags // - OpenSim.Data.RegionFlags rflags = (OpenSim.Data.RegionFlags)Convert.ToInt32(region.Data["flags"]); + OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(region.Data["flags"]); // Is this a reservation? // - if ((rflags & OpenSim.Data.RegionFlags.Reservation) != 0) + if ((rflags & OpenSim.Framework.RegionFlags.Reservation) != 0) { // Regions reserved for the null key cannot be taken. if ((string)region.Data["PrincipalID"] == UUID.Zero.ToString()) @@ -166,10 +166,10 @@ namespace OpenSim.Services.GridService // NOTE: Fudging the flags value here, so these flags // should not be used elsewhere. Don't optimize // this with the later retrieval of the same flags! - rflags |= OpenSim.Data.RegionFlags.Authenticate; + rflags |= OpenSim.Framework.RegionFlags.Authenticate; } - if ((rflags & OpenSim.Data.RegionFlags.Authenticate) != 0) + if ((rflags & OpenSim.Framework.RegionFlags.Authenticate) != 0) { // Can we authenticate at all? // @@ -205,10 +205,10 @@ namespace OpenSim.Services.GridService if ((region != null) && (region.RegionID == regionInfos.RegionID) && ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) { - if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.NoMove) != 0) + if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.NoMove) != 0) return "Can't move this region"; - if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Data.RegionFlags.LockedOut) != 0) + if ((Convert.ToInt32(region.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.LockedOut) != 0) return "Region locked out"; // Region reregistering in other coordinates. Delete the old entry @@ -233,7 +233,7 @@ namespace OpenSim.Services.GridService { int oldFlags = Convert.ToInt32(region.Data["flags"]); - oldFlags &= ~(int)OpenSim.Data.RegionFlags.Reservation; + oldFlags &= ~(int)OpenSim.Framework.RegionFlags.Reservation; rdata.Data["flags"] = oldFlags.ToString(); // Preserve flags } @@ -252,7 +252,7 @@ namespace OpenSim.Services.GridService } int flags = Convert.ToInt32(rdata.Data["flags"]); - flags |= (int)OpenSim.Data.RegionFlags.RegionOnline; + flags |= (int)OpenSim.Framework.RegionFlags.RegionOnline; rdata.Data["flags"] = flags.ToString(); try @@ -283,9 +283,9 @@ namespace OpenSim.Services.GridService int flags = Convert.ToInt32(region.Data["flags"]); - if (!m_DeleteOnUnregister || (flags & (int)OpenSim.Data.RegionFlags.Persistent) != 0) + if (!m_DeleteOnUnregister || (flags & (int)OpenSim.Framework.RegionFlags.Persistent) != 0) { - flags &= ~(int)OpenSim.Data.RegionFlags.RegionOnline; + flags &= ~(int)OpenSim.Framework.RegionFlags.RegionOnline; region.Data["flags"] = flags.ToString(); region.Data["last_seen"] = Util.UnixTimeSinceEpoch(); try @@ -320,7 +320,7 @@ namespace OpenSim.Services.GridService if (rdata.RegionID != regionID) { int flags = Convert.ToInt32(rdata.Data["flags"]); - if ((flags & (int)Data.RegionFlags.Hyperlink) == 0) // no hyperlinks as neighbours + if ((flags & (int)Framework.RegionFlags.Hyperlink) == 0) // no hyperlinks as neighbours rinfos.Add(RegionData2RegionInfo(rdata)); } } @@ -470,7 +470,7 @@ namespace OpenSim.Services.GridService foreach (RegionData r in regions) { - if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) + if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.RegionOnline) != 0) ret.Add(RegionData2RegionInfo(r)); } @@ -486,7 +486,7 @@ namespace OpenSim.Services.GridService foreach (RegionData r in regions) { - if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) + if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.RegionOnline) != 0) ret.Add(RegionData2RegionInfo(r)); } @@ -502,7 +502,7 @@ namespace OpenSim.Services.GridService foreach (RegionData r in regions) { - if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Data.RegionFlags.RegionOnline) != 0) + if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.RegionOnline) != 0) ret.Add(RegionData2RegionInfo(r)); } @@ -629,7 +629,7 @@ namespace OpenSim.Services.GridService private void OutputRegionToConsole(RegionData r) { - OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); + OpenSim.Framework.RegionFlags flags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(r.Data["flags"]); ConsoleDisplayList dispList = new ConsoleDisplayList(); dispList.AddRow("Region Name", r.RegionName); @@ -659,7 +659,7 @@ namespace OpenSim.Services.GridService foreach (RegionData r in regions) { - OpenSim.Data.RegionFlags flags = (OpenSim.Data.RegionFlags)Convert.ToInt32(r.Data["flags"]); + OpenSim.Framework.RegionFlags flags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(r.Data["flags"]); dispTable.AddRow( r.RegionName, r.RegionID.ToString(), @@ -673,7 +673,7 @@ namespace OpenSim.Services.GridService private int ParseFlags(int prev, string flags) { - OpenSim.Data.RegionFlags f = (OpenSim.Data.RegionFlags)prev; + OpenSim.Framework.RegionFlags f = (OpenSim.Framework.RegionFlags)prev; string[] parts = flags.Split(new char[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries); @@ -685,18 +685,18 @@ namespace OpenSim.Services.GridService { if (p.StartsWith("+")) { - val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p.Substring(1)); - f |= (OpenSim.Data.RegionFlags)val; + val = (int)Enum.Parse(typeof(OpenSim.Framework.RegionFlags), p.Substring(1)); + f |= (OpenSim.Framework.RegionFlags)val; } else if (p.StartsWith("-")) { - val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p.Substring(1)); - f &= ~(OpenSim.Data.RegionFlags)val; + val = (int)Enum.Parse(typeof(OpenSim.Framework.RegionFlags), p.Substring(1)); + f &= ~(OpenSim.Framework.RegionFlags)val; } else { - val = (int)Enum.Parse(typeof(OpenSim.Data.RegionFlags), p); - f |= (OpenSim.Data.RegionFlags)val; + val = (int)Enum.Parse(typeof(OpenSim.Framework.RegionFlags), p); + f |= (OpenSim.Framework.RegionFlags)val; } } catch (Exception) @@ -728,7 +728,7 @@ namespace OpenSim.Services.GridService 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; + OpenSim.Framework.RegionFlags f = (OpenSim.Framework.RegionFlags)flags; MainConsole.Instance.Output(String.Format("Set region {0} to {1}", r.RegionName, f)); m_Database.Store(r); -- cgit v1.1 From 1b826b487739220503458ccc6b07ec40c54e1164 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Sun, 16 Dec 2012 09:48:37 +0200 Subject: Allow registering regions whose names are equivalent under LIKE but not truly equal --- OpenSim/Services/GridService/GridService.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index ee3b858..daebf8b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -185,15 +185,15 @@ namespace OpenSim.Services.GridService if (!m_AllowDuplicateNames) { - List dupe = m_Database.Get(regionInfos.RegionName, scopeID); + List dupe = m_Database.Get(Util.EscapeForLike(regionInfos.RegionName), scopeID); if (dupe != null && dupe.Count > 0) { foreach (RegionData d in dupe) { if (d.RegionID != regionInfos.RegionID) { - m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.", - regionInfos.RegionName, regionInfos.RegionID); + m_log.WarnFormat("[GRID SERVICE]: Region tried to register using a duplicate name. New region: {0} ({1}), existing region: {2} ({3}).", + regionInfos.RegionName, regionInfos.RegionID, d.RegionName, d.RegionID); return "Duplicate region name"; } } @@ -359,7 +359,7 @@ namespace OpenSim.Services.GridService public GridRegion GetRegionByName(UUID scopeID, string name) { - List rdatas = m_Database.Get(name, scopeID); + List rdatas = m_Database.Get(Util.EscapeForLike(name), scopeID); if ((rdatas != null) && (rdatas.Count > 0)) return RegionData2RegionInfo(rdatas[0]); // get the first @@ -377,7 +377,7 @@ namespace OpenSim.Services.GridService { // m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name); - List rdatas = m_Database.Get(name + "%", scopeID); + List rdatas = m_Database.Get(Util.EscapeForLike(name) + "%", scopeID); int count = 0; List rinfos = new List(); @@ -586,7 +586,7 @@ namespace OpenSim.Services.GridService string regionName = cmd[3]; - List regions = m_Database.Get(regionName, UUID.Zero); + List regions = m_Database.Get(Util.EscapeForLike(regionName), UUID.Zero); if (regions == null || regions.Count < 1) { MainConsole.Instance.Output("No region with name {0} found", regionName); @@ -716,7 +716,7 @@ namespace OpenSim.Services.GridService return; } - List regions = m_Database.Get(cmd[3], UUID.Zero); + List regions = m_Database.Get(Util.EscapeForLike(cmd[3]), UUID.Zero); if (regions == null || regions.Count < 1) { MainConsole.Instance.Output("Region not found"); -- cgit v1.1 From 2be786709badc9913f348932e75d3481d445caf8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 Aug 2013 01:03:27 +0100 Subject: Make it possible for the "deregister region id" command to accept more than one id --- OpenSim/Services/GridService/GridService.cs | 51 +++++++++++++++-------------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index daebf8b..59b150b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -86,7 +86,7 @@ namespace OpenSim.Services.GridService { MainConsole.Instance.Commands.AddCommand("Regions", true, "deregister region id", - "deregister region id ", + "deregister region id +", "Deregister a region manually.", String.Empty, HandleDeregisterRegion); @@ -526,37 +526,40 @@ namespace OpenSim.Services.GridService private void HandleDeregisterRegion(string module, string[] cmd) { - if (cmd.Length != 4) + if (cmd.Length < 4) { - MainConsole.Instance.Output("Syntax: degregister region id "); + MainConsole.Instance.Output("Usage: degregister region id +"); return; } - string rawRegionUuid = cmd[3]; - UUID regionUuid; - - if (!UUID.TryParse(rawRegionUuid, out regionUuid)) + for (int i = 3; i < cmd.Length; i++) { - MainConsole.Instance.OutputFormat("{0} is not a valid region uuid", rawRegionUuid); - return; - } + string rawRegionUuid = cmd[i]; + UUID regionUuid; - GridRegion region = GetRegionByUUID(UUID.Zero, regionUuid); + if (!UUID.TryParse(rawRegionUuid, out regionUuid)) + { + MainConsole.Instance.OutputFormat("{0} is not a valid region uuid", rawRegionUuid); + return; + } - if (region == null) - { - MainConsole.Instance.OutputFormat("No region with UUID {0}", regionUuid); - return; - } + GridRegion region = GetRegionByUUID(UUID.Zero, regionUuid); - if (DeregisterRegion(regionUuid)) - { - MainConsole.Instance.OutputFormat("Deregistered {0} {1}", region.RegionName, regionUuid); - } - else - { - // I don't think this can ever occur if we know that the region exists. - MainConsole.Instance.OutputFormat("Error deregistering {0} {1}", region.RegionName, regionUuid); + if (region == null) + { + MainConsole.Instance.OutputFormat("No region with UUID {0}", regionUuid); + return; + } + + if (DeregisterRegion(regionUuid)) + { + MainConsole.Instance.OutputFormat("Deregistered {0} {1}", region.RegionName, regionUuid); + } + else + { + // I don't think this can ever occur if we know that the region exists. + MainConsole.Instance.OutputFormat("Error deregistering {0} {1}", region.RegionName, regionUuid); + } } return; -- cgit v1.1 From 04f4dd3dc7da5657ce3f792ef6d5f9191a7281f7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 23 Aug 2013 01:04:03 +0100 Subject: remove redundant return at end of HandleDeregisterRegion() --- OpenSim/Services/GridService/GridService.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 59b150b..a1485c8 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -561,8 +561,6 @@ namespace OpenSim.Services.GridService MainConsole.Instance.OutputFormat("Error deregistering {0} {1}", region.RegionName, regionUuid); } } - - return; } private void HandleShowRegions(string module, string[] cmd) -- cgit v1.1 From 4cbadc3c4984b8bebc7098a720846309f645ad7b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 2 Sep 2013 17:27:45 +0100 Subject: Allow one to specify a DefaultHGRegion flag in [GridService] in order to allow different default regions for HG and direct grid logins. This requires a new GridService.GetDefaultHypergridRegions() so ROBUST services require updating but not simulators. This method still returns regions flagged with just DefaultRegion after any DefaultHGRegions, so if no DefaultHGRegions are specified then existing configured defaults will still work. Immediate use is for conference where we need to be able to specify different defaults However, this is also generally useful to send experienced HG users to one default location and local users whose specified region fails (e.g. no "home" or "last") to another. --- OpenSim/Services/GridService/GridService.cs | 32 +++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index a1485c8..e72b7f9 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -265,8 +265,9 @@ namespace OpenSim.Services.GridService m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); } - m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}", - regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY); + m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3} with flags {4}", + regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY, + (OpenSim.Framework.RegionFlags)flags); return String.Empty; } @@ -478,6 +479,33 @@ namespace OpenSim.Services.GridService return ret; } + public List GetDefaultHypergridRegions(UUID scopeID) + { + List ret = new List(); + + List regions = m_Database.GetDefaultHypergridRegions(scopeID); + + foreach (RegionData r in regions) + { + if ((Convert.ToInt32(r.Data["flags"]) & (int)OpenSim.Framework.RegionFlags.RegionOnline) != 0) + ret.Add(RegionData2RegionInfo(r)); + } + + int hgDefaultRegionsFoundOnline = regions.Count; + + // For now, hypergrid default regions will always be given precedence but we will also return simple default + // regions in case no specific hypergrid regions are specified. + ret.AddRange(GetDefaultRegions(scopeID)); + + int normalDefaultRegionsFoundOnline = ret.Count - hgDefaultRegionsFoundOnline; + + m_log.DebugFormat( + "[GRID SERVICE]: GetDefaultHypergridRegions returning {0} hypergrid default and {1} normal default regions", + hgDefaultRegionsFoundOnline, normalDefaultRegionsFoundOnline); + + return ret; + } + public List GetFallbackRegions(UUID scopeID, int x, int y) { List ret = new List(); -- cgit v1.1 From 6df7d4219d7a82b0323d9fe294473860c0aef0dd Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 2 Nov 2013 15:40:48 -0700 Subject: varregion: add linkage for region size in creations and conversions of GridRegion. New variables for size and code to initialize same. --- OpenSim/Services/GridService/GridService.cs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index e72b7f9..9fa2dc5 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -441,6 +441,8 @@ namespace OpenSim.Services.GridService RegionData rdata = new RegionData(); rdata.posX = (int)rinfo.RegionLocX; rdata.posY = (int)rinfo.RegionLocY; + rdata.sizeX = rinfo.RegionSizeX; + rdata.sizeY = rinfo.RegionSizeY; rdata.RegionID = rinfo.RegionID; rdata.RegionName = rinfo.RegionName; rdata.Data = rinfo.ToKeyValuePairs(); @@ -454,6 +456,8 @@ namespace OpenSim.Services.GridService GridRegion rinfo = new GridRegion(rdata.Data); rinfo.RegionLocX = rdata.posX; rinfo.RegionLocY = rdata.posY; + rinfo.RegionSizeX = rdata.sizeX; + rinfo.RegionSizeY = rdata.sizeY; rinfo.RegionID = rdata.RegionID; rinfo.RegionName = rdata.RegionName; rinfo.ScopeID = rdata.ScopeID; -- cgit v1.1 From 7aa00632b90f9c24ff6b0fa0da385744a6573c32 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 28 Nov 2013 08:20:16 -0800 Subject: varregion: many replacements of in-place arithmetic with calls to the Util functions for converting world addresses to region addresses and converting region handles to locations. --- OpenSim/Services/GridService/GridService.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 9fa2dc5..aa7ffc1 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -347,6 +347,11 @@ namespace OpenSim.Services.GridService return null; } + // Get a region given its base coordinates. + // NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST + // be the base coordinate of the region. + // The snapping is technically unnecessary but is harmless because regions are always + // multiples of the legacy region size (256). public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; -- cgit v1.1 From 2d2bea4aa75ff6e82384f0842fe3719bf946b1cc Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 26 Dec 2013 22:45:59 -0800 Subject: varregion: many more updates removing the constant RegionSize and replacing with a passed region size. This time in the map code and grid services code. --- OpenSim/Services/GridService/GridService.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index aa7ffc1..8198592 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -313,8 +313,10 @@ namespace OpenSim.Services.GridService if (region != null) { // Not really? Maybe? - List rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize - 1, region.posY - (int)Constants.RegionSize - 1, - region.posX + (int)Constants.RegionSize + 1, region.posY + (int)Constants.RegionSize + 1, scopeID); + // The adjacent regions are presumed to be the same size as the current region + List rdatas = m_Database.Get( + region.posX - region.sizeX - 1, region.posY - region.sizeY - 1, + region.posX + region.sizeX + 1, region.posY + region.sizeY + 1, scopeID); foreach (RegionData rdata in rdatas) { @@ -642,20 +644,20 @@ namespace OpenSim.Services.GridService return; } - int x, y; - if (!int.TryParse(cmd[3], out x)) + uint x, y; + if (!uint.TryParse(cmd[3], out x)) { MainConsole.Instance.Output("x-coord must be an integer"); return; } - if (!int.TryParse(cmd[4], out y)) + if (!uint.TryParse(cmd[4], out y)) { MainConsole.Instance.Output("y-coord must be an integer"); return; } - RegionData region = m_Database.Get(x * (int)Constants.RegionSize, y * (int)Constants.RegionSize, UUID.Zero); + RegionData region = m_Database.Get((int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y), UUID.Zero); if (region == null) { MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y); -- cgit v1.1 From 0300ec45ebc7b8696c64bf4575bf674a6b1a8fa7 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 31 May 2014 12:10:50 -0700 Subject: Modifications to debugging printouts. No functional changes. --- OpenSim/Services/GridService/GridService.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 8198592..36957a7 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -46,6 +46,7 @@ namespace OpenSim.Services.GridService private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); + private string LogHeader = "[GRID SERVICE]"; private bool m_DeleteOnUnregister = true; private static GridService m_RootInstance = null; @@ -328,7 +329,11 @@ namespace OpenSim.Services.GridService } } -// m_log.DebugFormat("[GRID SERVICE]: region {0} has {1} neighbours", region.RegionName, rinfos.Count); + // string rNames = ""; + // foreach (GridRegion gr in rinfos) + // rNames += gr.RegionName + ","; + // m_log.DebugFormat("{0} region {1} has {2} neighbours ({3})", + // LogHeader, region.RegionName, rinfos.Count, rNames); } else { @@ -657,7 +662,7 @@ namespace OpenSim.Services.GridService return; } - RegionData region = m_Database.Get((int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y), UUID.Zero); + RegionData region = m_Database.Get((int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y), UUID.Zero); if (region == null) { MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y); -- cgit v1.1 From 82a5d00bc847b4bf5e5ba7b8e47ee109929c63bf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 4 Jul 2014 23:57:24 +0100 Subject: Adjust "show regions" and "show region" robust service console output to show size "show regions" drops the owner id column but is till present in "show region" "show regions" name column expanded to allow for longer hg regions (probably still too short, may eventually have to truncate rather than taking up huge screen space) --- OpenSim/Services/GridService/GridService.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 36957a7..477f54b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -620,7 +620,6 @@ namespace OpenSim.Services.GridService OutputRegionsToConsoleSummary(regions); } - private void HandleShowRegion(string module, string[] cmd) { if (cmd.Length != 4) @@ -679,7 +678,8 @@ namespace OpenSim.Services.GridService ConsoleDisplayList dispList = new ConsoleDisplayList(); dispList.AddRow("Region Name", r.RegionName); dispList.AddRow("Region ID", r.RegionID); - dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY)); + dispList.AddRow("Position", string.Format("{0},{1}", r.coordX, r.coordY)); + dispList.AddRow("Size", string.Format("{0}x{1}", r.sizeX, r.sizeY)); dispList.AddRow("URI", r.Data["serverURI"]); dispList.AddRow("Owner ID", r.Data["owner_uuid"]); dispList.AddRow("Flags", flags); @@ -696,10 +696,10 @@ namespace OpenSim.Services.GridService private void OutputRegionsToConsoleSummary(List regions) { ConsoleDisplayTable dispTable = new ConsoleDisplayTable(); - dispTable.AddColumn("Name", 16); + dispTable.AddColumn("Name", 44); dispTable.AddColumn("ID", 36); dispTable.AddColumn("Position", 11); - dispTable.AddColumn("Owner ID", 36); + dispTable.AddColumn("Size", 11); dispTable.AddColumn("Flags", 60); foreach (RegionData r in regions) @@ -709,7 +709,7 @@ namespace OpenSim.Services.GridService r.RegionName, r.RegionID.ToString(), string.Format("{0},{1}", r.coordX, r.coordY), - r.Data["owner_uuid"].ToString(), + string.Format("{0}x{1}", r.sizeX, r.sizeY), flags.ToString()); } -- cgit v1.1 From 219d2734181e615199ccfd6c10d595ea6aa41b14 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 5 Jul 2014 00:48:01 +0100 Subject: Add experimental "show grid size" robust console command. This will show an approximate grid size that doesn't count regions that are hyperlinks Not particularly trustworthy since it will still count regions that are not active but were not deregistered (deliberately or due to simulator crash or similar) --- OpenSim/Services/GridService/GridService.cs | 39 +++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 477f54b..e0e2f03 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -118,12 +118,19 @@ namespace OpenSim.Services.GridService "For example, show region at 1000 1000", HandleShowRegionAt); - MainConsole.Instance.Commands.AddCommand("Regions", true, - "set region flags", - "set region flags ", - "Set database flags for region", + MainConsole.Instance.Commands.AddCommand("General", true, + "show grid size", + "show grid size", + "Show the current grid size (excluding hyperlink references)", String.Empty, - HandleSetFlags); + HandleShowGridSize); + + MainConsole.Instance.Commands.AddCommand("Regions", true, + "set region flags", + "set region flags ", + "Set database flags for region", + String.Empty, + HandleSetFlags); } m_HypergridLinker = new HypergridLinker(m_config, this, m_Database); } @@ -620,6 +627,28 @@ namespace OpenSim.Services.GridService OutputRegionsToConsoleSummary(regions); } + private void HandleShowGridSize(string module, string[] cmd) + { + List regions = m_Database.Get(int.MinValue, int.MinValue, int.MaxValue, int.MaxValue, UUID.Zero); + + double size = 0; + + foreach (RegionData region in regions) + { + int flags = Convert.ToInt32(region.Data["flags"]); + + if ((flags & (int)Framework.RegionFlags.Hyperlink) == 0) + size += region.sizeX * region.sizeY; + } + + MainConsole.Instance.Output("This is a very rough approximation."); + MainConsole.Instance.Output("Although it will not count regions that are actually links to others over the Hypergrid, "); + MainConsole.Instance.Output("it will count regions that are inactive but were not deregistered from the grid service"); + MainConsole.Instance.Output("(e.g. simulator crashed rather than shutting down cleanly).\n"); + + MainConsole.Instance.OutputFormat("Grid size: {0} km squared.", size / 1000000); + } + private void HandleShowRegion(string module, string[] cmd) { if (cmd.Length != 4) -- cgit v1.1 From e008d54cd4453b22a9572fb3fb2df7592448db49 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 14 Jul 2014 19:28:43 +0100 Subject: minor: Remove compiler warning in GridService --- OpenSim/Services/GridService/GridService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index e0e2f03..02ed90e 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -46,7 +46,7 @@ namespace OpenSim.Services.GridService private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - private string LogHeader = "[GRID SERVICE]"; +// private string LogHeader = "[GRID SERVICE]"; private bool m_DeleteOnUnregister = true; private static GridService m_RootInstance = null; -- cgit v1.1 From 9be935ac6d74fd3b8c0c95058a575e400dd916a4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 18 Jul 2014 22:27:39 +0100 Subject: Add ICommands.HasCommand() method so that we can detect whether a command has already been registered without needing to also run it --- OpenSim/Services/GridService/GridService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 02ed90e..aa19fc7 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -96,7 +96,7 @@ namespace OpenSim.Services.GridService // has an identically named command // // XXX: We're relying on the OpenSimulator version being registered first, which is not well defined. - if (MainConsole.Instance.Commands.Resolve(new string[] { "show", "regions" }).Length == 0) + if (!MainConsole.Instance.Commands.HasCommand("show regions")) MainConsole.Instance.Commands.AddCommand("Regions", true, "show regions", "show regions", -- cgit v1.1 From 6048dfcd715615c0c90b485a72ebbe2641f16d41 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 18 Jul 2014 22:57:04 +0100 Subject: In grid mode, add SuppressConsoleCommands flag to [GridService] so that we can stop misleading grid service only console commands from registering. We need to do this because the simulator initializes and internal copy of the GridService in grid mode for internal purposes --- OpenSim/Services/GridService/GridService.cs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index aa19fc7..2836236 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -64,6 +64,9 @@ namespace OpenSim.Services.GridService m_config = config; IConfig gridConfig = config.Configs["GridService"]; + + bool suppressConsoleCommands = false; + if (gridConfig != null) { m_DeleteOnUnregister = gridConfig.GetBoolean("DeleteOnUnregister", true); @@ -77,13 +80,17 @@ namespace OpenSim.Services.GridService } m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames); m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch); + + // This service is also used locally by a simulator running in grid mode. This switches prevents + // inappropriate console commands from being registered + suppressConsoleCommands = gridConfig.GetBoolean("SuppressConsoleCommands", suppressConsoleCommands); } - + if (m_RootInstance == null) { m_RootInstance = this; - if (MainConsole.Instance != null) + if (!suppressConsoleCommands && MainConsole.Instance != null) { MainConsole.Instance.Commands.AddCommand("Regions", true, "deregister region id", @@ -92,17 +99,12 @@ namespace OpenSim.Services.GridService String.Empty, HandleDeregisterRegion); - // A messy way of stopping this command being added if we are in standalone (since the simulator - // has an identically named command - // - // XXX: We're relying on the OpenSimulator version being registered first, which is not well defined. - if (!MainConsole.Instance.Commands.HasCommand("show regions")) - MainConsole.Instance.Commands.AddCommand("Regions", true, - "show regions", - "show regions", - "Show details on all regions", - String.Empty, - HandleShowRegions); + MainConsole.Instance.Commands.AddCommand("Regions", true, + "show regions", + "show regions", + "Show details on all regions", + String.Empty, + HandleShowRegions); MainConsole.Instance.Commands.AddCommand("Regions", true, "show region name", @@ -132,6 +134,7 @@ namespace OpenSim.Services.GridService String.Empty, HandleSetFlags); } + m_HypergridLinker = new HypergridLinker(m_config, this, m_Database); } } -- cgit v1.1 From aa8b44c001445e0fc72ec5fe68a79bbd970e8753 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 20 Jul 2014 10:34:09 -0700 Subject: Add code to GridService to check for overlapping of varregions when registering a new region. Adds parameter "[GridService]SuppressVarRegionOverlapCheckOnRegistration=false" that can be turned on to suppress the error check if a simulator's database has old regions that overlap. --- OpenSim/Services/GridService/GridService.cs | 129 ++++++++++++++++++++++++++-- 1 file changed, 123 insertions(+), 6 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 2836236..013cc53 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -46,7 +46,7 @@ namespace OpenSim.Services.GridService private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); -// private string LogHeader = "[GRID SERVICE]"; + private string LogHeader = "[GRID SERVICE]"; private bool m_DeleteOnUnregister = true; private static GridService m_RootInstance = null; @@ -57,6 +57,8 @@ namespace OpenSim.Services.GridService protected bool m_AllowDuplicateNames = false; protected bool m_AllowHypergridMapSearch = false; + protected bool m_SuppressVarregionOverlapCheckOnRegistration = false; + public GridService(IConfigSource config) : base(config) { @@ -81,6 +83,8 @@ namespace OpenSim.Services.GridService m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames); m_AllowHypergridMapSearch = gridConfig.GetBoolean("AllowHypergridMapSearch", m_AllowHypergridMapSearch); + m_SuppressVarregionOverlapCheckOnRegistration = gridConfig.GetBoolean("SuppressVarregionOverlapCheckOnRegistration", m_SuppressVarregionOverlapCheckOnRegistration); + // This service is also used locally by a simulator running in grid mode. This switches prevents // inappropriate console commands from being registered suppressConsoleCommands = gridConfig.GetBoolean("SuppressConsoleCommands", suppressConsoleCommands); @@ -148,12 +152,19 @@ namespace OpenSim.Services.GridService if (regionInfos.RegionID == UUID.Zero) return "Invalid RegionID - cannot be zero UUID"; - RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); - if ((region != null) && (region.RegionID != regionInfos.RegionID)) + String reason = "Region overlaps another region"; + RegionData region = FindAnyConflictingRegion(regionInfos, scopeID, out reason); + // If there is a conflicting region, if it has the same ID and same coordinates + // then it is a region re-registering (permissions and ownership checked later). + if ((region != null) + && ( (region.coordX != regionInfos.RegionCoordX) + || (region.coordY != regionInfos.RegionCoordY) + || (region.RegionID != regionInfos.RegionID) ) + ) { - m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", - regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); - return "Region overlaps another region"; + // If not same ID and same coordinates, this new region has conflicts and can't be registered. + m_log.WarnFormat("{0} Register region conflict in scope {1}. {2}", LogHeader, scopeID, reason); + return reason; } if (region != null) @@ -283,6 +294,112 @@ namespace OpenSim.Services.GridService return String.Empty; } + /// + /// Search the region map for regions conflicting with this region. + /// The region to be added is passed and we look for any existing regions that are + /// in the requested location, that are large varregions that overlap this region, or + /// are previously defined regions that would lie under this new region. + /// + /// Information on region requested to be added to the world map + /// Grid id for region + /// The reason the returned region conflicts with passed region + /// + private RegionData FindAnyConflictingRegion(GridRegion regionInfos, UUID scopeID, out string reason) + { + reason = "Reregistration"; + // First see if there is an existing region right where this region is trying to go + // (We keep this result so it can be returned if suppressing errors) + RegionData noErrorRegion = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); + RegionData region = noErrorRegion; + if (region != null + && region.RegionID == regionInfos.RegionID + && region.sizeX == regionInfos.RegionSizeX + && region.sizeY == regionInfos.RegionSizeY) + { + // If this seems to be exactly the same region, return this as it could be + // a re-registration (permissions checked by calling routine). + m_log.DebugFormat("{0} FindAnyConflictingRegion: re-register of {1}", + LogHeader, RegionString(regionInfos)); + return region; + } + + // No region exactly there or we're resizing an existing region. + // Fetch regions that could be varregions overlapping requested location. + int xmin = regionInfos.RegionLocX - (int)Constants.MaximumRegionSize + 10; + int xmax = regionInfos.RegionLocX; + int ymin = regionInfos.RegionLocY - (int)Constants.MaximumRegionSize + 10; + int ymax = regionInfos.RegionLocY; + List rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); + foreach (RegionData rdata in rdatas) + { + // m_log.DebugFormat("{0} FindAnyConflictingRegion: find existing. Checking {1}", LogHeader, RegionString(rdata) ); + if ( (rdata.posX + rdata.sizeX > regionInfos.RegionLocX) + && (rdata.posY + rdata.sizeY > regionInfos.RegionLocY) ) + { + region = rdata; + m_log.WarnFormat("{0} FindAnyConflictingRegion: conflict of {1} by existing varregion {2}", + LogHeader, RegionString(regionInfos), RegionString(region)); + reason = String.Format("Region location is overlapped by existing varregion {0}", + RegionString(region)); + + if (m_SuppressVarregionOverlapCheckOnRegistration) + region = noErrorRegion; + return region; + } + } + + // There isn't a region that overlaps this potential region. + // See if this potential region overlaps an existing region. + // First, a shortcut of not looking for overlap if new region is legacy region sized + // and connot overlap anything. + if (regionInfos.RegionSizeX != Constants.RegionSize + || regionInfos.RegionSizeY != Constants.RegionSize) + { + // trim range looked for so we don't pick up neighbor regions just off the edges + xmin = regionInfos.RegionLocX; + xmax = regionInfos.RegionLocX + regionInfos.RegionSizeX - 10; + ymin = regionInfos.RegionLocY; + ymax = regionInfos.RegionLocY + regionInfos.RegionSizeY - 10; + rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); + + // If the region is being resized, the found region could be ourself. + foreach (RegionData rdata in rdatas) + { + // m_log.DebugFormat("{0} FindAnyConflictingRegion: see if overlap. Checking {1}", LogHeader, RegionString(rdata) ); + if (region == null || region.RegionID != regionInfos.RegionID) + { + region = rdata; + m_log.WarnFormat("{0} FindAnyConflictingRegion: conflict of varregion {1} overlaps existing region {2}", + LogHeader, RegionString(regionInfos), RegionString(region)); + reason = String.Format("Region {0} would overlap existing region {1}", + RegionString(regionInfos), RegionString(region)); + + if (m_SuppressVarregionOverlapCheckOnRegistration) + region = noErrorRegion; + return region; + } + } + } + + // If we get here, region is either null (nothing found here) or + // is the non-conflicting region found at the location being requested. + return region; + } + + // String describing name and region location of passed region + private String RegionString(RegionData reg) + { + return String.Format("{0}/{1} at <{2},{3}>", + reg.RegionName, reg.RegionID, reg.coordX, reg.coordY); + } + + // String describing name and region location of passed region + private String RegionString(GridRegion reg) + { + return String.Format("{0}/{1} at <{2},{3}>", + reg.RegionName, reg.RegionID, reg.RegionCoordX, reg.RegionCoordY); + } + public bool DeregisterRegion(UUID regionID) { RegionData region = m_Database.Get(regionID, UUID.Zero); -- cgit v1.1 From 10a8d2852e529fddb029ae333a3ae6a0f06f0182 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sun, 3 Aug 2014 20:33:40 -0400 Subject: OpenSimExtras Move the experimental extra features functionality into the GridService. This sends default values for map, search and destination guide, plus ExportSupported control to the region on startup. Please watch http://opensimulator.org/wiki/SimulatorFeatures_Extras for changes and documentation. --- OpenSim/Services/GridService/GridService.cs | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 013cc53..e8a545c 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -59,6 +59,8 @@ namespace OpenSim.Services.GridService protected bool m_SuppressVarregionOverlapCheckOnRegistration = false; + private static Dictionary m_ExtraFeatures = new Dictionary(); + public GridService(IConfigSource config) : base(config) { @@ -139,10 +141,38 @@ namespace OpenSim.Services.GridService HandleSetFlags); } + if (!suppressConsoleCommands) + SetExtraServiceURLs(config); + m_HypergridLinker = new HypergridLinker(m_config, this, m_Database); } } + private void SetExtraServiceURLs(IConfigSource config) + { + IConfig loginConfig = config.Configs["LoginService"]; + IConfig gridConfig = config.Configs["GridService"]; + + if (loginConfig == null || gridConfig == null) + return; + + string configVal; + + configVal = loginConfig.GetString("SearchURL", string.Empty); + if (!string.IsNullOrEmpty(configVal)) + m_ExtraFeatures["search-server-url"] = configVal; + + configVal = loginConfig.GetString("MapTileURL", string.Empty); + if (!string.IsNullOrEmpty(configVal)) + m_ExtraFeatures["map-server-url"] = configVal; + + configVal = loginConfig.GetString("DestinationGuide", string.Empty); + if (!string.IsNullOrEmpty(configVal)) + m_ExtraFeatures["destination-guide-url"] = configVal; + + m_ExtraFeatures["ExportSupported"] = gridConfig.GetString("ExportSupported", "true"); + } + #region IGridService public string RegisterRegion(UUID scopeID, GridRegion regionInfos) @@ -928,5 +958,18 @@ namespace OpenSim.Services.GridService m_Database.Store(r); } } + + /// + /// Gets the grid extra service URls we wish for the region to send in OpenSimExtras to dynamically refresh + /// parameters in the viewer used to access services like map, search and destination guides. + /// see "SimulatorFeaturesModule" + /// + /// + /// The grid extra service URls. + /// + public Dictionary GetExtraFeatures() + { + return m_ExtraFeatures; + } } } -- cgit v1.1 From 2d2aa6e07645b3b9f1577b41d0f73803ccafba80 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Dec 2014 21:40:39 +0000 Subject: minor: Just have one message that displays successful registration of a region with its parameters rather than 2 --- OpenSim/Services/GridService/GridService.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index e8a545c..29723d8 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -317,8 +317,10 @@ namespace OpenSim.Services.GridService m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e); } - m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3} with flags {4}", - regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionCoordX, regionInfos.RegionCoordY, + m_log.DebugFormat + ("[GRID SERVICE]: Region {0} ({1}, {2}x{3}) registered at {4},{5} with flags {6}", + regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionSizeX, regionInfos.RegionSizeY, + regionInfos.RegionCoordX, regionInfos.RegionCoordY, (OpenSim.Framework.RegionFlags)flags); return String.Empty; -- cgit v1.1 From 2fd252f5a9ffc06fcaabf2a1e0889f01dcba4889 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Jan 2015 10:32:33 -0800 Subject: SimulatorFeatures: the viewer also takes GridName in OpenSim extras. Added that (plus GridURL, in case viewers want to use it too) to the GridService that gives out that info to simulators. --- OpenSim/Services/GridService/GridService.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 29723d8..3b1a07e 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -170,6 +170,19 @@ namespace OpenSim.Services.GridService if (!string.IsNullOrEmpty(configVal)) m_ExtraFeatures["destination-guide-url"] = configVal; + configVal = Util.GetConfigVarFromSections( + config, "GatekeeperURI", new string[] { "Startup", "Hypergrid" }, String.Empty); + if (!string.IsNullOrEmpty(configVal)) + m_ExtraFeatures["GridURL"] = configVal; + + configVal = Util.GetConfigVarFromSections( + config, "GridName", new string[] { "Const", "Hypergrid" }, String.Empty); + if (string.IsNullOrEmpty(configVal)) + configVal = Util.GetConfigVarFromSections( + config, "gridname", new string[] { "GridInfo" }, String.Empty); + if (!string.IsNullOrEmpty(configVal)) + m_ExtraFeatures["GridName"] = configVal; + m_ExtraFeatures["ExportSupported"] = gridConfig.GetString("ExportSupported", "true"); } -- cgit v1.1 From 185e7048c8dc51fe0705bd26728440cf361564c7 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 22 Jan 2015 10:45:07 -0800 Subject: On the GridService, the central simulator features: ensure that the map tile url ends with '/' because the viewer is dumb and just appends to it. --- OpenSim/Services/GridService/GridService.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 3b1a07e..af7a511 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -164,8 +164,14 @@ namespace OpenSim.Services.GridService configVal = loginConfig.GetString("MapTileURL", string.Empty); if (!string.IsNullOrEmpty(configVal)) + { + // This URL must end with '/', the viewer doesn't check + configVal = configVal.Trim(); + if (!configVal.EndsWith("/")) + configVal = configVal + "/"; m_ExtraFeatures["map-server-url"] = configVal; - + } + configVal = loginConfig.GetString("DestinationGuide", string.Empty); if (!string.IsNullOrEmpty(configVal)) m_ExtraFeatures["destination-guide-url"] = configVal; -- cgit v1.1 From 3a2d4c8b055d906b4a790bf1bf9fb1f09f9781ea Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Wed, 22 Jul 2015 20:13:53 +0300 Subject: Added logging in places where regions are searched for by their location This commit also fixes the log message "Region already exists in coordinates <{0},{1}>": it was actually showing the *requested* coordinates, instead of the coordinates of the previously-existing link. --- OpenSim/Services/GridService/GridService.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services/GridService/GridService.cs') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index af7a511..8807397 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -539,13 +539,24 @@ namespace OpenSim.Services.GridService // multiples of the legacy region size (256). public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { - int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; - int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; + uint regionX = Util.WorldToRegionLoc((uint)x); + uint regionY = Util.WorldToRegionLoc((uint)y); + int snapX = (int)Util.RegionToWorldLoc(regionX); + int snapY = (int)Util.RegionToWorldLoc(regionY); + RegionData rdata = m_Database.Get(snapX, snapY, scopeID); if (rdata != null) + { + m_log.DebugFormat("{0} GetRegionByPosition. Found region {1} in database. Pos=<{2},{3}>", + LogHeader, rdata.RegionName, regionX, regionY); return RegionData2RegionInfo(rdata); - - return null; + } + else + { + m_log.DebugFormat("{0} GetRegionByPosition. Did not find region in database. Pos=<{1},{2}>", + LogHeader, regionX, regionY); + return null; + } } public GridRegion GetRegionByName(UUID scopeID, string name) -- cgit v1.1