Fix problem with megaregions where teleporting into a different region which already had a child agent would stop the eq working for the agent in the new region.

This was because the calculation as to whether a new agent was needed in the receiving region did not take megaregions into account,
unlike the original calculation when the user first teleported into the region.
This meant that on teleport, entity transfer would create a new CAP but this would be ignored by the viewer and receiving region, meaning that the EQ could no longer be used.
This would prevent subsequent teleport, amongst other things.
Currently, regions up to 512m from a megaregion are considered neighbours.
user_profiles
Justin Clark-Casey (justincc) 2013-03-28 00:12:48 +00:00
parent da5dbaf1d0
commit dd7d7683c9
1 changed files with 44 additions and 1 deletions

View File

@ -727,6 +727,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
IClientIPEndpoint ipepClient;
if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY))
{
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Determined that region {0} at {1},{2} needs new child agent for incoming agent {3} from {4}",
finalDestination.RegionName, newRegionX, newRegionY, sp.Name, Scene.Name);
//sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
#region IP Translation for NAT
// Uses ipepClient above
@ -1001,7 +1005,46 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY)
{
return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY);
Border[] northBorders = Scene.NorthBorders.ToArray();
Border[] southBorders = Scene.SouthBorders.ToArray();
Border[] eastBorders = Scene.EastBorders.ToArray();
Border[] westBorders = Scene.WestBorders.ToArray();
// Leaving this as a "megaregions" computation vs "non-megaregions" computation; it isn't
// clear what should be done with a "far view" given that megaregions already extended the
// view to include everything in the megaregion
if (northBorders.Length > 1 || southBorders.Length > 1 || eastBorders.Length > 1 || westBorders.Length > 1)
{
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++)
{
extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
}
// Loss of fraction on purpose
extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
uint startX = oldRegionX - 1;
uint startY = oldRegionY - 1;
uint endX = oldRegionX + (uint)extent.X;
uint endY = oldRegionY + (uint)extent.Y;
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Megaregion view of {0} is from {1},{2} to {3},{4} with new agent check for {5},{6}",
Scene.Name, startX, startY, endX, endY, newRegionX, newRegionY);
return !(newRegionX >= startX && newRegionX <= endX && newRegionY >= startY && newRegionY <= endY);
}
else
{
return Util.IsOutsideView(drawdist, oldRegionX, newRegionX, oldRegionY, newRegionY);
}
}
protected virtual bool NeedsClosing(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY, GridRegion reg)