Added initial support for reading hypergrid links from a xml config file. Although its currently still activated by using console command: link-region <URI of xml file> , the uri should be able to be a local file path or a http uri. I'm adding details of the format of the xml file to the wiki's hypergrid page.

TODO: Add a initial startup option for setting the uri and making it autoload it. 
Add support for scanning the xml file to check that its own region(s) aren't in the list, and if they are, ignoring them. This would allow setting up "virtual link/grid lists" on webservers, that people can add their own regions to and also point those regions to those same lists, so they load the other region's data.
Add support for automapping of those region/link lists.
0.6.2-post-fixes
MW 2009-01-15 14:37:04 +00:00
parent 9822f8fc8f
commit 940728dad7
1 changed files with 84 additions and 31 deletions

View File

@ -31,6 +31,7 @@ using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Reflection;
using System.Xml;
using log4net;
using Nini.Config;
using OpenSim.Framework;
@ -143,19 +144,39 @@ namespace OpenSim
{
// link-region <Xloc> <Yloc> <HostName> <HttpPort> <LocalName>
if (cmdparams.Length < 4)
{
if (cmdparams.Length == 1)
{
try
{
XmlReader r = XmlReader.Create(cmdparams[0]);
XmlConfigSource cs = new XmlConfigSource(r);
for (int i = 0; i < cs.Configs.Count; i++)
{
ReadLinkFromConfig(cs.Configs[i]);
}
}
catch (Exception)
{
}
}
else
{
LinkRegionCmdUsage();
}
return;
}
RegionInfo regInfo = new RegionInfo();
RegionInfo regInfo;
uint xloc, yloc;
uint externalPort;
string externalHostName;
try
{
xloc = Convert.ToUInt32(cmdparams[0]);
yloc = Convert.ToUInt32(cmdparams[1]);
externalPort = Convert.ToUInt32(cmdparams[3]);
externalHostName = cmdparams[2];
//internalPort = Convert.ToUInt32(cmdparams[4]);
//remotingPort = Convert.ToUInt32(cmdparams[5]);
}
@ -165,9 +186,48 @@ namespace OpenSim
LinkRegionCmdUsage();
return;
}
if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
{
if (cmdparams.Length >= 5)
{
regInfo.RegionName = "";
for (int i = 4; i < cmdparams.Length; i++)
regInfo.RegionName += cmdparams[i] + " ";
}
}
return;
}
base.RunCmd(command, cmdparams);
}
private void ReadLinkFromConfig(IConfig config)
{
RegionInfo regInfo;
uint xloc, yloc;
uint externalPort;
string externalHostName;
xloc = Convert.ToUInt32(config.GetString("xloc", "0"));
yloc = Convert.ToUInt32(config.GetString("yloc", "0"));
externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
externalHostName = config.GetString("externalHostName", "");
if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo))
{
regInfo.RegionName = config.GetString("localName", "");
}
}
private bool TryCreateLink(uint xloc, uint yloc, uint externalPort, string externalHostName, out RegionInfo regInfo)
{
regInfo = new RegionInfo();
regInfo.RegionLocX = xloc;
regInfo.RegionLocY = yloc;
regInfo.ExternalHostName = cmdparams[2];
regInfo.ExternalHostName = externalHostName;
regInfo.HttpPort = externalPort;
//regInfo.RemotingPort = remotingPort;
try
@ -178,7 +238,7 @@ namespace OpenSim
{
m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message);
LinkRegionCmdUsage();
return;
return false;
}
regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString();
@ -190,17 +250,10 @@ namespace OpenSim
catch (Exception e)
{
m_log.Warn("[HGrid] Unable to link region: " + e.StackTrace);
}
if (cmdparams.Length >= 5)
{
regInfo.RegionName = "";
for (int i = 4; i < cmdparams.Length; i++)
regInfo.RegionName += cmdparams[i] + " ";
}
return false;
}
base.RunCmd(command, cmdparams);
return true;
}
private void LinkRegionCmdUsage()