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.varregion
parent
3193bcaae1
commit
7aa00632b9
|
@ -1022,7 +1022,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
|||
// Set home position
|
||||
|
||||
GridRegion home = scene.GridService.GetRegionByPosition(scopeID,
|
||||
(int)(regionXLocation * Constants.RegionSize), (int)(regionYLocation * Constants.RegionSize));
|
||||
(int)Util.RegionToWorldLoc(regionXLocation), (int)Util.RegionToWorldLoc(regionYLocation));
|
||||
if (null == home)
|
||||
{
|
||||
m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", firstName, lastName);
|
||||
|
@ -1252,7 +1252,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
|||
if ((null != regionXLocation) && (null != regionYLocation))
|
||||
{
|
||||
GridRegion home = scene.GridService.GetRegionByPosition(scopeID,
|
||||
(int)(regionXLocation * Constants.RegionSize), (int)(regionYLocation * Constants.RegionSize));
|
||||
(int)Util.RegionToWorldLoc((uint)regionXLocation), (int)Util.RegionToWorldLoc((uint)regionYLocation));
|
||||
if (null == home) {
|
||||
m_log.WarnFormat("[RADMIN]: Unable to set home region for updated user account {0} {1}", firstName, lastName);
|
||||
} else {
|
||||
|
@ -2883,7 +2883,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
|||
// Set home position
|
||||
|
||||
GridRegion home = scene.GridService.GetRegionByPosition(scopeID,
|
||||
(int)(regionXLocation * Constants.RegionSize), (int)(regionYLocation * Constants.RegionSize));
|
||||
(int)Util.RegionToWorldLoc(regionXLocation), (int)Util.RegionToWorldLoc(regionYLocation));
|
||||
if (null == home) {
|
||||
m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", names[0], names[1]);
|
||||
} else {
|
||||
|
|
|
@ -336,6 +336,7 @@ namespace OpenSim.Framework
|
|||
// Regions are identified with a 'handle' made up of its region coordinates packed into a ulong.
|
||||
// Several places rely on the ability to extract a region's location from its handle.
|
||||
// Note the location is in 'world coordinates' (see below).
|
||||
// Region handles are based on the lowest coordinate of the region so trim the passed x,y to be the regions 0,0.
|
||||
public static ulong RegionWorldLocToHandle(uint X, uint Y)
|
||||
{
|
||||
return Utils.UIntsToLong(X, Y);
|
||||
|
|
|
@ -192,6 +192,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
return m_GridService.GetRegionByUUID(scopeID, regionID);
|
||||
}
|
||||
|
||||
// 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.
|
||||
public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
|
||||
{
|
||||
GridRegion region = null;
|
||||
|
|
|
@ -82,6 +82,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
return new List<GridRegion>(m_neighbours.Values);
|
||||
}
|
||||
|
||||
// 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(int x, int y)
|
||||
{
|
||||
uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize;
|
||||
|
|
|
@ -186,10 +186,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
return rinfo;
|
||||
}
|
||||
|
||||
// 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 coordinates are world coords (meters), NOT region units.
|
||||
public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
|
||||
{
|
||||
bool inCache = false;
|
||||
GridRegion rinfo = m_RegionInfoCache.Get(scopeID, Util.UIntsToLong((uint)x, (uint)y), out inCache);
|
||||
GridRegion rinfo = m_RegionInfoCache.Get(scopeID, Util.RegionWorldLocToHandle((uint)x, (uint)y), out inCache);
|
||||
if (inCache)
|
||||
return rinfo;
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ using log4net.Config;
|
|||
using Nini.Config;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
@ -141,7 +142,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
|
|||
Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null");
|
||||
Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match");
|
||||
|
||||
result = m_LocalConnector.GetRegionByPosition(UUID.Zero, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize);
|
||||
result = m_LocalConnector.GetRegionByPosition(UUID.Zero, (int)Util.RegionToWorldLoc(1000), (int)Util.RegionToWorldLoc(1000));
|
||||
Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null");
|
||||
Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match");
|
||||
|
||||
|
|
|
@ -1789,7 +1789,7 @@ namespace OpenSim.Region.CoreModules.World.Land
|
|||
{
|
||||
// most likely still cached from building the extLandData entry
|
||||
uint x = 0, y = 0;
|
||||
Utils.LongToUInts(data.RegionHandle, out x, out y);
|
||||
Util.RegionHandleToWorldLoc(data.RegionHandle, out x, out y);
|
||||
info = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
|
||||
}
|
||||
// we need to transfer the fake parcelID, not the one in landData, so the viewer can match it to the landmark.
|
||||
|
|
|
@ -803,7 +803,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
if (httpserver.Length == 0)
|
||||
{
|
||||
uint x = 0, y = 0;
|
||||
Utils.LongToUInts(regionhandle, out x, out y);
|
||||
Util.RegionHandleToWorldLoc(regionhandle, out x, out y);
|
||||
GridRegion mreg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
|
||||
|
||||
if (mreg != null)
|
||||
|
|
|
@ -166,7 +166,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// we only want to send one update to each simulator; the simulator will
|
||||
// hand it off to the regions where a child agent exists, this does assume
|
||||
// that the region position is cached or performance will degrade
|
||||
Utils.LongToUInts(regionHandle, out x, out y);
|
||||
Util.RegionHandleToWorldLoc(regionHandle, out x, out y);
|
||||
GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
|
||||
if (dest == null)
|
||||
continue;
|
||||
|
@ -203,7 +203,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
//m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID);
|
||||
uint x = 0, y = 0;
|
||||
Utils.LongToUInts(regionHandle, out x, out y);
|
||||
Util.RegionHandleToWorldLoc(regionHandle, out x, out y);
|
||||
|
||||
GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y);
|
||||
|
||||
|
|
|
@ -116,9 +116,9 @@ namespace OpenSim.Server.Handlers.MapImage
|
|||
httpResponse.StatusCode = (int)OSHttpStatusCode.ClientErrorBadRequest;
|
||||
return FailureResult("Bad request.");
|
||||
}
|
||||
int x = 0, y = 0;
|
||||
Int32.TryParse(request["X"].ToString(), out x);
|
||||
Int32.TryParse(request["Y"].ToString(), out y);
|
||||
uint x = 0, y = 0;
|
||||
UInt32.TryParse(request["X"].ToString(), out x);
|
||||
UInt32.TryParse(request["Y"].ToString(), out y);
|
||||
|
||||
m_log.DebugFormat("[MAP ADD SERVER CONNECTOR]: Received map data for region at {0}-{1}", x, y);
|
||||
|
||||
|
@ -130,7 +130,7 @@ namespace OpenSim.Server.Handlers.MapImage
|
|||
if (m_GridService != null)
|
||||
{
|
||||
System.Net.IPAddress ipAddr = GetCallerIP(httpRequest);
|
||||
GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, x * (int)Constants.RegionSize, y * (int)Constants.RegionSize);
|
||||
GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, (int)Util.RegionToWorldLoc(x), (int)Util.RegionToWorldLoc(y));
|
||||
if (r != null)
|
||||
{
|
||||
if (r.ExternalEndPoint.Address.ToString() != ipAddr.ToString())
|
||||
|
@ -151,7 +151,7 @@ namespace OpenSim.Server.Handlers.MapImage
|
|||
byte[] data = Convert.FromBase64String(request["DATA"].ToString());
|
||||
|
||||
string reason = string.Empty;
|
||||
bool result = m_MapService.AddMapTile(x, y, data, out reason);
|
||||
bool result = m_MapService.AddMapTile((int)x, (int)y, data, out reason);
|
||||
|
||||
if (result)
|
||||
return SuccessResult();
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace OpenSim.Services.Connectors
|
|||
try
|
||||
{
|
||||
uint xpos = 0, ypos = 0;
|
||||
Utils.LongToUInts(regionHandle, out xpos, out ypos);
|
||||
Util.RegionHandleToWorldLoc(regionHandle, out xpos, out ypos);
|
||||
GridRegion info = m_GridService.GetRegionByPosition(scopeID, (int)xpos, (int)ypos);
|
||||
if (info != null) // just to be sure
|
||||
{
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace OpenSim.Services.Connectors
|
|||
public virtual GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
|
||||
{
|
||||
uint x = 0, y = 0;
|
||||
Utils.LongToUInts(regionHandle, out x, out y);
|
||||
Util.RegionHandleToWorldLoc(regionHandle, out x, out y);
|
||||
GridRegion regInfo = m_GridService.GetRegionByPosition(thisRegion.ScopeID, (int)x, (int)y);
|
||||
if ((regInfo != null) &&
|
||||
// Don't remote-call this instance; that's a startup hickup
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue