mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 18:55:58 +08:00
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.
This commit is contained in:
@@ -313,8 +313,10 @@ namespace OpenSim.Services.GridService
|
||||
if (region != null)
|
||||
{
|
||||
// Not really? Maybe?
|
||||
List<RegionData> 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<RegionData> 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);
|
||||
|
||||
@@ -183,8 +183,8 @@ namespace OpenSim.Services.GridService
|
||||
public GridRegion LinkRegion(UUID scopeID, string regionDescriptor)
|
||||
{
|
||||
string reason = string.Empty;
|
||||
int xloc = random.Next(0, Int16.MaxValue) * (int)Constants.RegionSize;
|
||||
return TryLinkRegionToCoords(scopeID, regionDescriptor, xloc, 0, out reason);
|
||||
uint xloc = Util.RegionToWorldLoc((uint)random.Next(0, Int16.MaxValue));
|
||||
return TryLinkRegionToCoords(scopeID, regionDescriptor, (int)xloc, 0, out reason);
|
||||
}
|
||||
|
||||
private static Random random = new Random();
|
||||
@@ -260,7 +260,7 @@ namespace OpenSim.Services.GridService
|
||||
{
|
||||
m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0} {1}, in {2}-{3}",
|
||||
((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI),
|
||||
remoteRegionName, xloc / Constants.RegionSize, yloc / Constants.RegionSize);
|
||||
remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc));
|
||||
|
||||
reason = string.Empty;
|
||||
Uri uri = null;
|
||||
@@ -311,7 +311,7 @@ namespace OpenSim.Services.GridService
|
||||
if (region != null)
|
||||
{
|
||||
m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}",
|
||||
regInfo.RegionLocX / Constants.RegionSize, regInfo.RegionLocY / Constants.RegionSize,
|
||||
Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY),
|
||||
region.RegionName, region.RegionID);
|
||||
reason = "Coordinates are already in use";
|
||||
return false;
|
||||
@@ -347,7 +347,7 @@ namespace OpenSim.Services.GridService
|
||||
if (region != null)
|
||||
{
|
||||
m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}",
|
||||
region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize);
|
||||
Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY));
|
||||
regInfo = region;
|
||||
return true;
|
||||
}
|
||||
@@ -424,10 +424,10 @@ namespace OpenSim.Services.GridService
|
||||
// {
|
||||
// uint ux = 0, uy = 0;
|
||||
// Utils.LongToUInts(realHandle, out ux, out uy);
|
||||
// x = ux / Constants.RegionSize;
|
||||
// y = uy / Constants.RegionSize;
|
||||
// x = Util.WorldToRegionLoc(ux);
|
||||
// y = Util.WorldToRegionLoc(uy);
|
||||
//
|
||||
// const uint limit = (4096 - 1) * Constants.RegionSize;
|
||||
// const uint limit = Util.RegionToWorldLoc(4096 - 1);
|
||||
// uint xmin = ux - limit;
|
||||
// uint xmax = ux + limit;
|
||||
// uint ymin = uy - limit;
|
||||
@@ -502,9 +502,14 @@ namespace OpenSim.Services.GridService
|
||||
MainConsole.Instance.Output(new string('-', 72));
|
||||
foreach (RegionData r in regions)
|
||||
{
|
||||
MainConsole.Instance.Output(String.Format("{0}\n{2,-32} {1}\n",
|
||||
r.RegionName, r.RegionID, String.Format("{0},{1} ({2},{3})", r.posX, r.posY,
|
||||
r.posX / Constants.RegionSize, r.posY / Constants.RegionSize)));
|
||||
MainConsole.Instance.Output(
|
||||
String.Format("{0}\n{2,-32} {1}\n",
|
||||
r.RegionName, r.RegionID,
|
||||
String.Format("{0},{1} ({2},{3})", r.posX, r.posY,
|
||||
Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -529,8 +534,8 @@ namespace OpenSim.Services.GridService
|
||||
int xloc, yloc;
|
||||
string serverURI;
|
||||
string remoteName = null;
|
||||
xloc = Convert.ToInt32(cmdparams[0]) * (int)Constants.RegionSize;
|
||||
yloc = Convert.ToInt32(cmdparams[1]) * (int)Constants.RegionSize;
|
||||
xloc = (int)Util.RegionToWorldLoc((uint)Convert.ToInt32(cmdparams[0]));
|
||||
yloc = (int)Util.RegionToWorldLoc((uint)Convert.ToInt32(cmdparams[1]));
|
||||
serverURI = cmdparams[2];
|
||||
if (cmdparams.Length > 3)
|
||||
remoteName = string.Join(" ", cmdparams, 3, cmdparams.Length - 3);
|
||||
@@ -601,13 +606,13 @@ namespace OpenSim.Services.GridService
|
||||
{
|
||||
// old format
|
||||
GridRegion regInfo;
|
||||
int xloc, yloc;
|
||||
uint xloc, yloc;
|
||||
uint externalPort;
|
||||
string externalHostName;
|
||||
try
|
||||
{
|
||||
xloc = Convert.ToInt32(cmdparams[0]);
|
||||
yloc = Convert.ToInt32(cmdparams[1]);
|
||||
xloc = Convert.ToUInt32(cmdparams[0]);
|
||||
yloc = Convert.ToUInt32(cmdparams[1]);
|
||||
externalPort = Convert.ToUInt32(cmdparams[3]);
|
||||
externalHostName = cmdparams[2];
|
||||
//internalPort = Convert.ToUInt32(cmdparams[4]);
|
||||
@@ -621,10 +626,11 @@ namespace OpenSim.Services.GridService
|
||||
}
|
||||
|
||||
// Convert cell coordinates given by the user to meters
|
||||
xloc = xloc * (int)Constants.RegionSize;
|
||||
yloc = yloc * (int)Constants.RegionSize;
|
||||
xloc = Util.RegionToWorldLoc(xloc);
|
||||
yloc = Util.RegionToWorldLoc(yloc);
|
||||
string reason = string.Empty;
|
||||
if (TryCreateLink(UUID.Zero, xloc, yloc, string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
|
||||
if (TryCreateLink(UUID.Zero, (int)xloc, (int)yloc,
|
||||
string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
|
||||
{
|
||||
// What is this? The GridRegion instance will be discarded anyway,
|
||||
// which effectively ignores any local name given with the command.
|
||||
@@ -704,13 +710,13 @@ namespace OpenSim.Services.GridService
|
||||
private void ReadLinkFromConfig(IConfig config)
|
||||
{
|
||||
GridRegion regInfo;
|
||||
int xloc, yloc;
|
||||
uint xloc, yloc;
|
||||
uint externalPort;
|
||||
string externalHostName;
|
||||
uint realXLoc, realYLoc;
|
||||
|
||||
xloc = Convert.ToInt32(config.GetString("xloc", "0"));
|
||||
yloc = Convert.ToInt32(config.GetString("yloc", "0"));
|
||||
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", "");
|
||||
realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
|
||||
@@ -718,18 +724,19 @@ namespace OpenSim.Services.GridService
|
||||
|
||||
if (m_enableAutoMapping)
|
||||
{
|
||||
xloc = (int)((xloc % 100) + m_autoMappingX);
|
||||
yloc = (int)((yloc % 100) + m_autoMappingY);
|
||||
xloc = (xloc % 100) + m_autoMappingX;
|
||||
yloc = (yloc % 100) + m_autoMappingY;
|
||||
}
|
||||
|
||||
if (((realXLoc == 0) && (realYLoc == 0)) ||
|
||||
(((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) &&
|
||||
((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
|
||||
{
|
||||
xloc = xloc * (int)Constants.RegionSize;
|
||||
yloc = yloc * (int)Constants.RegionSize;
|
||||
xloc = Util.RegionToWorldLoc(xloc);
|
||||
yloc = Util.RegionToWorldLoc(yloc);
|
||||
string reason = string.Empty;
|
||||
if (TryCreateLink(UUID.Zero, xloc, yloc, string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
|
||||
if (TryCreateLink(UUID.Zero, (int)xloc, (int)yloc,
|
||||
string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
|
||||
{
|
||||
regInfo.RegionName = config.GetString("localName", "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user