From b114a04ed4f06afbdf673c28374e6e3cb9065096 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 29 Aug 2015 03:41:43 +0100
Subject: fix NeighborRegions code
---
.../EntityTransfer/EntityTransferModule.cs | 11 ++--
OpenSim/Region/Framework/Scenes/Scene.cs | 65 ++++++----------------
2 files changed, 21 insertions(+), 55 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index e3cf43c..7861a54 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -1147,7 +1147,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// Past this point we have to attempt clean up if the teleport fails, so update transfer state.
m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring);
-
// We need to set this here to avoid an unlikely race condition when teleporting to a neighbour simulator,
// where that neighbour simulator could otherwise request a child agent create on the source which then
// closes our existing agent which is still signalled as root.
@@ -2184,7 +2183,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
int shifty = (rRegionY - tRegionY) * (int)Constants.RegionSize;
return new Vector3(shiftx, shifty, 0f);
*/
- return new Vector3( sp.Scene.RegionInfo.WorldLocX - neighbour.RegionLocX,
+ return new Vector3(sp.Scene.RegionInfo.WorldLocX - neighbour.RegionLocX,
sp.Scene.RegionInfo.WorldLocY - neighbour.RegionLocY,
0f);
}
@@ -2496,10 +2495,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
uint startY = Util.RegionToWorldLoc(pRegionLocY) + m_regionInfo.RegionSizeY / 2;
uint endY = startY;
- startX -= dd;
- startY -= dd;
- endX += dd;
- endY += dd;
+ startX -= ddX;
+ startY -= ddY;
+ endX += ddX;
+ endY += ddY;
neighbours
= avatar.Scene.GridService.GetRegionRange(
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 41f8871..605c788 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1129,17 +1129,9 @@ namespace OpenSim.Region.Framework.Scenes
/// True after all operations complete, throws exceptions otherwise.
public override void OtherRegionUp(GridRegion otherRegion)
{
- uint xcell = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize);
- uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize);
- //m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}",
- // RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell);
-
if (RegionInfo.RegionHandle != otherRegion.RegionHandle)
{
- // If these are cast to INT because long + negative values + abs returns invalid data
- int resultX = Math.Abs((int)xcell - (int)RegionInfo.RegionLocX);
- int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY);
- if (resultX <= 1 && resultY <= 1)
+ if (isNeighborRegion(otherRegion))
{
// Let the grid service module know, so this can be cached
m_eventManager.TriggerOnRegionUp(otherRegion);
@@ -1174,6 +1166,21 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ public bool isNeighborRegion(GridRegion otherRegion)
+ {
+ int tmp = otherRegion.RegionLocX - (int)RegionInfo.WorldLocX; ;
+
+ if (tmp < -otherRegion.RegionSizeX && tmp > RegionInfo.RegionSizeX)
+ return false;
+
+ tmp = otherRegion.RegionLocY - (int)RegionInfo.WorldLocY;
+
+ if (tmp < -otherRegion.RegionSizeY && tmp > RegionInfo.RegionSizeY)
+ return false;
+
+ return true;
+ }
+
public void AddNeighborRegion(RegionInfo region)
{
lock (m_neighbours)
@@ -1202,46 +1209,6 @@ namespace OpenSim.Region.Framework.Scenes
return found;
}
- ///
- /// Checks whether this region has a neighbour in the given direction.
- ///
- ///
- ///
- ///
- /// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8.
- /// Returns a positive integer if there is a region in that direction, a negative integer if not.
- ///
- public int HaveNeighbor(Cardinals car, ref int[] fix)
- {
- uint neighbourx = RegionInfo.RegionLocX;
- uint neighboury = RegionInfo.RegionLocY;
-
- int dir = (int)car;
-
- if (dir > 1 && dir < 5) //Heading East
- neighbourx++;
- else if (dir > 5) // Heading West
- neighbourx--;
-
- if (dir < 3 || dir == 8) // Heading North
- neighboury++;
- else if (dir > 3 && dir < 7) // Heading Sout
- neighboury--;
-
- int x = (int)(neighbourx * Constants.RegionSize);
- int y = (int)(neighboury * Constants.RegionSize);
- GridRegion neighbourRegion = GridService.GetRegionByPosition(RegionInfo.ScopeID, x, y);
-
- if (neighbourRegion == null)
- {
- fix[0] = (int)(RegionInfo.RegionLocX - neighbourx);
- fix[1] = (int)(RegionInfo.RegionLocY - neighboury);
- return dir * (-1);
- }
- else
- return dir;
- }
-
// Alias IncomingHelloNeighbour OtherRegionUp, for now
public GridRegion IncomingHelloNeighbour(RegionInfo neighbour)
{
--
cgit v1.1