From eac29396d98a4864923a69e0eb73cecdd8a225b3 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Wed, 19 Oct 2011 15:38:25 -0700 Subject: Moved HaveNeighbor utility function from ScenePresence to Scene. Fixed line endings from previous commit. --- OpenSim/Region/Framework/Scenes/Scene.cs | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 724c635..64ed6c7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -960,6 +960,46 @@ 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