diff options
author | Dan Lake | 2011-10-19 15:38:25 -0700 |
---|---|---|
committer | Dan Lake | 2011-10-19 15:38:25 -0700 |
commit | eac29396d98a4864923a69e0eb73cecdd8a225b3 (patch) | |
tree | bd9ca40f69659cdeb5902211030d589ac01e6abf /OpenSim/Region/Framework/Scenes/Scene.cs | |
parent | Merge branch 'master' of git://opensimulator.org/git/opensim (diff) | |
download | opensim-SC-eac29396d98a4864923a69e0eb73cecdd8a225b3.zip opensim-SC-eac29396d98a4864923a69e0eb73cecdd8a225b3.tar.gz opensim-SC-eac29396d98a4864923a69e0eb73cecdd8a225b3.tar.bz2 opensim-SC-eac29396d98a4864923a69e0eb73cecdd8a225b3.tar.xz |
Moved HaveNeighbor utility function from ScenePresence to Scene. Fixed line endings from previous commit.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 40 |
1 files changed, 40 insertions, 0 deletions
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 | |||
960 | return found; | 960 | return found; |
961 | } | 961 | } |
962 | 962 | ||
963 | /// <summary> | ||
964 | /// Checks whether this region has a neighbour in the given direction. | ||
965 | /// </summary> | ||
966 | /// <param name="car"></param> | ||
967 | /// <param name="fix"></param> | ||
968 | /// <returns> | ||
969 | /// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8. | ||
970 | /// Returns a positive integer if there is a region in that direction, a negative integer if not. | ||
971 | /// </returns> | ||
972 | public int HaveNeighbor(Cardinals car, ref int[] fix) | ||
973 | { | ||
974 | uint neighbourx = RegionInfo.RegionLocX; | ||
975 | uint neighboury = RegionInfo.RegionLocY; | ||
976 | |||
977 | int dir = (int)car; | ||
978 | |||
979 | if (dir > 1 && dir < 5) //Heading East | ||
980 | neighbourx++; | ||
981 | else if (dir > 5) // Heading West | ||
982 | neighbourx--; | ||
983 | |||
984 | if (dir < 3 || dir == 8) // Heading North | ||
985 | neighboury++; | ||
986 | else if (dir > 3 && dir < 7) // Heading Sout | ||
987 | neighboury--; | ||
988 | |||
989 | int x = (int)(neighbourx * Constants.RegionSize); | ||
990 | int y = (int)(neighboury * Constants.RegionSize); | ||
991 | GridRegion neighbourRegion = GridService.GetRegionByPosition(RegionInfo.ScopeID, x, y); | ||
992 | |||
993 | if (neighbourRegion == null) | ||
994 | { | ||
995 | fix[0] = (int)(RegionInfo.RegionLocX - neighbourx); | ||
996 | fix[1] = (int)(RegionInfo.RegionLocY - neighboury); | ||
997 | return dir * (-1); | ||
998 | } | ||
999 | else | ||
1000 | return dir; | ||
1001 | } | ||
1002 | |||
963 | // Alias IncomingHelloNeighbour OtherRegionUp, for now | 1003 | // Alias IncomingHelloNeighbour OtherRegionUp, for now |
964 | public GridRegion IncomingHelloNeighbour(RegionInfo neighbour) | 1004 | public GridRegion IncomingHelloNeighbour(RegionInfo neighbour) |
965 | { | 1005 | { |