Fixed: hypergrid-linking stopped accepting the following format: "http://grid.example.com" (without a region name)

Fixes http://opensimulator.org/mantis/view.php?id=7128
0.8.0.3
Oren Hurvitz 2014-04-24 08:19:05 +03:00
parent d1865c526d
commit 6efc203ce8
1 changed files with 21 additions and 11 deletions

View File

@ -200,10 +200,13 @@ namespace OpenSim.Services.GridService
reason = string.Empty; reason = string.Empty;
GridRegion regInfo = null; GridRegion regInfo = null;
mapName = mapName.Trim();
if (!mapName.StartsWith("http")) if (!mapName.StartsWith("http"))
{ {
// Formats: grid.example.com:8002:region name // Formats: grid.example.com:8002:region name
// grid.example.com:region name // grid.example.com:region name
// grid.example.com:8002
// grid.example.com // grid.example.com
string host; string host;
@ -222,11 +225,11 @@ namespace OpenSim.Services.GridService
if (parts.Length >= 2) if (parts.Length >= 2)
{ {
string portstr = parts[1]; // If it's a number then assume it's a port. Otherwise, it's a region name.
//m_log.Debug("-- port = " + portstr); if (!UInt32.TryParse(parts[1], out port))
if (!UInt32.TryParse(portstr, out port))
regionName = parts[1]; regionName = parts[1];
} }
// always take the last one // always take the last one
if (parts.Length >= 3) if (parts.Length >= 3)
{ {
@ -245,21 +248,28 @@ namespace OpenSim.Services.GridService
{ {
// Formats: http://grid.example.com region name // Formats: http://grid.example.com region name
// http://grid.example.com "region name" // http://grid.example.com "region name"
// http://grid.example.com
string regionName; string serverURI;
string regionName = "";
string[] parts = mapName.Split(new char[] { ' ' }); string[] parts = mapName.Split(new char[] { ' ' });
if (parts.Length < 2) if (parts.Length == 0)
{ {
reason = "Wrong format for link-region"; reason = "Wrong format for link-region";
return null; return null;
} }
regionName = mapName.Substring(parts[0].Length + 1); serverURI = parts[0];
regionName = regionName.Trim(new char[] {'"'});
if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, parts[0], ownerID, out regInfo, out reason)) if (parts.Length >= 2)
{
regionName = mapName.Substring(serverURI.Length);
regionName = regionName.Trim(new char[] { '"', ' ' });
}
if (TryCreateLink(scopeID, xloc, yloc, regionName, 0, null, serverURI, ownerID, out regInfo, out reason))
{ {
regInfo.RegionName = mapName; regInfo.RegionName = mapName;
return regInfo; return regInfo;