diff options
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 65 |
1 files changed, 16 insertions, 49 deletions
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 | |||
1129 | /// <returns>True after all operations complete, throws exceptions otherwise.</returns> | 1129 | /// <returns>True after all operations complete, throws exceptions otherwise.</returns> |
1130 | public override void OtherRegionUp(GridRegion otherRegion) | 1130 | public override void OtherRegionUp(GridRegion otherRegion) |
1131 | { | 1131 | { |
1132 | uint xcell = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize); | ||
1133 | uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize); | ||
1134 | //m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}", | ||
1135 | // RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell); | ||
1136 | |||
1137 | if (RegionInfo.RegionHandle != otherRegion.RegionHandle) | 1132 | if (RegionInfo.RegionHandle != otherRegion.RegionHandle) |
1138 | { | 1133 | { |
1139 | // If these are cast to INT because long + negative values + abs returns invalid data | 1134 | if (isNeighborRegion(otherRegion)) |
1140 | int resultX = Math.Abs((int)xcell - (int)RegionInfo.RegionLocX); | ||
1141 | int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY); | ||
1142 | if (resultX <= 1 && resultY <= 1) | ||
1143 | { | 1135 | { |
1144 | // Let the grid service module know, so this can be cached | 1136 | // Let the grid service module know, so this can be cached |
1145 | m_eventManager.TriggerOnRegionUp(otherRegion); | 1137 | m_eventManager.TriggerOnRegionUp(otherRegion); |
@@ -1174,6 +1166,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1174 | } | 1166 | } |
1175 | } | 1167 | } |
1176 | 1168 | ||
1169 | public bool isNeighborRegion(GridRegion otherRegion) | ||
1170 | { | ||
1171 | int tmp = otherRegion.RegionLocX - (int)RegionInfo.WorldLocX; ; | ||
1172 | |||
1173 | if (tmp < -otherRegion.RegionSizeX && tmp > RegionInfo.RegionSizeX) | ||
1174 | return false; | ||
1175 | |||
1176 | tmp = otherRegion.RegionLocY - (int)RegionInfo.WorldLocY; | ||
1177 | |||
1178 | if (tmp < -otherRegion.RegionSizeY && tmp > RegionInfo.RegionSizeY) | ||
1179 | return false; | ||
1180 | |||
1181 | return true; | ||
1182 | } | ||
1183 | |||
1177 | public void AddNeighborRegion(RegionInfo region) | 1184 | public void AddNeighborRegion(RegionInfo region) |
1178 | { | 1185 | { |
1179 | lock (m_neighbours) | 1186 | lock (m_neighbours) |
@@ -1202,46 +1209,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1202 | return found; | 1209 | return found; |
1203 | } | 1210 | } |
1204 | 1211 | ||
1205 | /// <summary> | ||
1206 | /// Checks whether this region has a neighbour in the given direction. | ||
1207 | /// </summary> | ||
1208 | /// <param name="car"></param> | ||
1209 | /// <param name="fix"></param> | ||
1210 | /// <returns> | ||
1211 | /// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8. | ||
1212 | /// Returns a positive integer if there is a region in that direction, a negative integer if not. | ||
1213 | /// </returns> | ||
1214 | public int HaveNeighbor(Cardinals car, ref int[] fix) | ||
1215 | { | ||
1216 | uint neighbourx = RegionInfo.RegionLocX; | ||
1217 | uint neighboury = RegionInfo.RegionLocY; | ||
1218 | |||
1219 | int dir = (int)car; | ||
1220 | |||
1221 | if (dir > 1 && dir < 5) //Heading East | ||
1222 | neighbourx++; | ||
1223 | else if (dir > 5) // Heading West | ||
1224 | neighbourx--; | ||
1225 | |||
1226 | if (dir < 3 || dir == 8) // Heading North | ||
1227 | neighboury++; | ||
1228 | else if (dir > 3 && dir < 7) // Heading Sout | ||
1229 | neighboury--; | ||
1230 | |||
1231 | int x = (int)(neighbourx * Constants.RegionSize); | ||
1232 | int y = (int)(neighboury * Constants.RegionSize); | ||
1233 | GridRegion neighbourRegion = GridService.GetRegionByPosition(RegionInfo.ScopeID, x, y); | ||
1234 | |||
1235 | if (neighbourRegion == null) | ||
1236 | { | ||
1237 | fix[0] = (int)(RegionInfo.RegionLocX - neighbourx); | ||
1238 | fix[1] = (int)(RegionInfo.RegionLocY - neighboury); | ||
1239 | return dir * (-1); | ||
1240 | } | ||
1241 | else | ||
1242 | return dir; | ||
1243 | } | ||
1244 | |||
1245 | // Alias IncomingHelloNeighbour OtherRegionUp, for now | 1212 | // Alias IncomingHelloNeighbour OtherRegionUp, for now |
1246 | public GridRegion IncomingHelloNeighbour(RegionInfo neighbour) | 1213 | public GridRegion IncomingHelloNeighbour(RegionInfo neighbour) |
1247 | { | 1214 | { |