From 877bdcdce1533d8dc3e13c0def7b015080ee881e Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 15 Feb 2014 16:01:43 -0800 Subject: Rewrite of mega-region code to use new form of border checking. This commit eliminates all of the 'border' class and list code and replaces it with testing if in the current region. Impacts: can make a mega-region out of varregions of the same size; and mega-region combinations must be rectangular (not square but rectangular) --- .../EntityTransfer/EntityTransferModule.cs | 48 +++++++--------------- 1 file changed, 14 insertions(+), 34 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index a038f73..3eff96e 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -464,7 +464,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer sp.Name, position, sp.Scene.RegionInfo.RegionName); // Teleport within the same region - if (IsOutsideRegion(sp.Scene, position) || position.Z < 0) + if (!sp.Scene.PositionIsInCurrentRegion(position) || position.Z < 0) { Vector3 emergencyPos = new Vector3(128, 128, 128); @@ -580,7 +580,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer MapBlockData block = new MapBlockData(); block.X = (ushort)regX; block.Y = (ushort)regY; - block.Access = 254; // == not there + block.Access = (byte)SimAccess.Down; List blocks = new List(); blocks.Add(block); @@ -713,10 +713,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; } - uint newRegionX = (uint)(reg.RegionHandle >> 40); - uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); - uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40); - uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8); + uint newRegionX, newRegionY, oldRegionX, oldRegionY; + Util.RegionHandleToRegionLoc(reg.RegionHandle, out newRegionX, out newRegionY); + Util.RegionHandleToRegionLoc(sp.Scene.RegionInfo.RegionHandle, out oldRegionX, out oldRegionY); ulong destinationHandle = finalDestination.RegionHandle; @@ -1333,6 +1332,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return region; } + // This returns 'true' if the new region already has a child agent for our + // incoming agent. The implication is that, if 'false', we have to create the + // child and then teleport into the region. protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) { if (m_regionCombinerModule != null && m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID)) @@ -1357,20 +1359,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY); } - protected virtual bool IsOutsideRegion(Scene s, Vector3 pos) - { - if (s.TestBorderCross(pos, Cardinals.N)) - return true; - if (s.TestBorderCross(pos, Cardinals.S)) - return true; - if (s.TestBorderCross(pos, Cardinals.E)) - return true; - if (s.TestBorderCross(pos, Cardinals.W)) - return true; - - return false; - } - #endregion #region Landmark Teleport @@ -2077,7 +2065,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer public NotFoundLocationCache() { } - // Add an area to the lost of 'not found' places. The area is the snapped region + // Add an area to the list of 'not found' places. The area is the snapped region // area around the added point. public void Add(double pX, double pY) { @@ -2305,23 +2293,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer /// private void GetMegaregionViewRange(out Vector2 swCorner, out Vector2 neCorner) { - Border[] northBorders = Scene.NorthBorders.ToArray(); - Border[] eastBorders = Scene.EastBorders.ToArray(); - Vector2 extent = Vector2.Zero; - for (int i = 0; i < eastBorders.Length; i++) - { - extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X; - } - for (int i = 0; i < northBorders.Length; i++) + + if (m_regionCombinerModule != null) { - extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; + Vector2 megaRegionSize = m_regionCombinerModule.GetSizeOfMegaregion(Scene.RegionInfo.RegionID); + extent.X = (float)Util.WorldToRegionLoc((uint)megaRegionSize.X); + extent.Y = (float)Util.WorldToRegionLoc((uint)megaRegionSize.Y); } - // Loss of fraction on purpose - extent.X = ((int)extent.X / (int)Constants.RegionSize); - extent.Y = ((int)extent.Y / (int)Constants.RegionSize); - swCorner.X = Scene.RegionInfo.RegionLocX - 1; swCorner.Y = Scene.RegionInfo.RegionLocY - 1; neCorner.X = Scene.RegionInfo.RegionLocX + extent.X; -- cgit v1.1