varregion: fix bug where destination region is not found and object is

not restored to its original location.
varregion
Robert Adams 2013-12-24 11:51:50 -08:00
parent a01862509e
commit 5c9fa15f30
1 changed files with 61 additions and 47 deletions

View File

@ -1399,26 +1399,26 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// Compute the entity's position relative to the new region // Compute the entity's position relative to the new region
newpos = new Vector3( (float)(presenceWorldX - (double)neighbourRegion.RegionLocX), newpos = new Vector3( (float)(presenceWorldX - (double)neighbourRegion.RegionLocX),
(float)(presenceWorldY - (double)neighbourRegion.RegionLocY), (float)(presenceWorldY - (double)neighbourRegion.RegionLocY),
pos.Z); pos.Z);
// Check if banned from destination region. // Check if banned from destination region.
ExpiringCache<ulong, DateTime> r; ExpiringCache<ulong, DateTime> r;
DateTime banUntil; DateTime banUntil;
if (m_bannedRegions.TryGetValue(agentID, out r)) if (m_bannedRegions.TryGetValue(agentID, out r))
{ {
if (r.TryGetValue(neighbourRegion.RegionHandle, out banUntil)) if (r.TryGetValue(neighbourRegion.RegionHandle, out banUntil))
{ {
if (DateTime.Now < banUntil) if (DateTime.Now < banUntil)
{ {
// If we're banned from the destination, we just can't go there. // If we're banned from the destination, we just can't go there.
neighbourRegion = null; neighbourRegion = null;
} }
r.Remove(neighbourRegion.RegionHandle); r.Remove(neighbourRegion.RegionHandle);
} }
} }
else else
{ {
r = null; r = null;
} }
// Check to see if we have access to the target region. // Check to see if we have access to the target region.
@ -1434,13 +1434,25 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
m_bannedRegions.Add(agentID, r, TimeSpan.FromSeconds(45)); m_bannedRegions.Add(agentID, r, TimeSpan.FromSeconds(45));
} }
else else
{ {
r.Add(neighbourRegion.RegionHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15)); r.Add(neighbourRegion.RegionHandle, DateTime.Now + TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(15));
} }
neighbourRegion = null; neighbourRegion = null;
} }
} }
if (neighbourRegion == null)
m_log.DebugFormat("{0} GetDestination: region not found. Old region name={1} at <{2},{3}> of size <{4},{5}>. Old pos={6}",
LogHeader, scene.RegionInfo.RegionName,
scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY,
scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY,
pos);
else
m_log.DebugFormat("{0} GetDestination: new region={1} at <{2},{3}> of size <{4},{5}>, newpos=<{6},{7}>",
LogHeader, neighbourRegion.RegionName,
neighbourRegion.RegionLocX, neighbourRegion.RegionLocY, neighbourRegion.RegionSizeX, neighbourRegion.RegionSizeY,
newpos.X, newpos.Y);
return neighbourRegion; return neighbourRegion;
} }
@ -1560,17 +1572,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
/// Calls an asynchronous method to do so.. so it doesn't lag the sim. /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
/// </summary> /// </summary>
public ScenePresence CrossAgentToNewRegionAsync( public ScenePresence CrossAgentToNewRegionAsync(
ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, ScenePresence agent, Vector3 pos, GridRegion neighbourRegion,
bool isFlying, string version) bool isFlying, string version)
{ {
m_log.DebugFormat("{0} CrossAgentToNewRegionAsync: new region={1} at <{2},{3}>. newpos={4}",
LogHeader, neighbourRegion.RegionName, neighbourRegion.RegionLocX, neighbourRegion.RegionLocY, pos);
if (!CrossAgentToNewRegionPrep(agent, neighbourRegion)) if (!CrossAgentToNewRegionPrep(agent, neighbourRegion))
{ {
m_log.DebugFormat("{0} CrossAgentToNewRegionAsync: prep failed. Resetting transfer state", LogHeader);
m_entityTransferStateMachine.ResetFromTransit(agent.UUID); m_entityTransferStateMachine.ResetFromTransit(agent.UUID);
return agent; return agent;
} }
if (!CrossAgentIntoNewRegionMain(agent, pos, neighbourRegion, isFlying)) if (!CrossAgentIntoNewRegionMain(agent, pos, neighbourRegion, isFlying))
{ {
m_log.DebugFormat("{0} CrossAgentToNewRegionAsync: cross main failed. Resetting transfer state", LogHeader);
m_entityTransferStateMachine.ResetFromTransit(agent.UUID); m_entityTransferStateMachine.ResetFromTransit(agent.UUID);
return agent; return agent;
} }
@ -2294,28 +2311,25 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
attemptedPosition.Z); attemptedPosition.Z);
} }
if (destination != null) if (destination == null || !CrossPrimGroupIntoNewRegion(destination, pos, grp, silent))
{ {
if (!CrossPrimGroupIntoNewRegion(destination, pos, grp, silent)) m_log.InfoFormat("[ENTITY TRANSFER MODULE] cross region transfer failed for object {0}", grp.UUID);
{
m_log.InfoFormat("[ENTITY TRANSFER MODULE] cross region transfer failed for object {0}", grp.UUID); // We are going to move the object back to the old position so long as the old position
// is in the region
// We are going to move the object back to the old position so long as the old position oldGroupPosition.X = Util.Clamp<float>(oldGroupPosition.X, 1.0f, (float)(scene.RegionInfo.RegionSizeX - 1));
// is in the region oldGroupPosition.Y = Util.Clamp<float>(oldGroupPosition.Y, 1.0f, (float)(scene.RegionInfo.RegionSizeY - 1));
oldGroupPosition.X = Util.Clamp<float>(oldGroupPosition.X, 1.0f, (float)(scene.RegionInfo.RegionSizeX - 1)); oldGroupPosition.Z = Util.Clamp<float>(oldGroupPosition.Z, 1.0f, Constants.RegionHeight);
oldGroupPosition.Y = Util.Clamp<float>(oldGroupPosition.Y, 1.0f, (float)(scene.RegionInfo.RegionSizeY - 1));
oldGroupPosition.Z = Util.Clamp<float>(oldGroupPosition.Z, 1.0f, Constants.RegionHeight); grp.AbsolutePosition = oldGroupPosition;
grp.Velocity = Vector3.Zero;
grp.AbsolutePosition = oldGroupPosition; if (grp.RootPart.PhysActor != null)
grp.Velocity = Vector3.Zero; grp.RootPart.PhysActor.CrossingFailure();
if (grp.RootPart.PhysActor != null)
grp.RootPart.PhysActor.CrossingFailure(); if (grp.RootPart.KeyframeMotion != null)
grp.RootPart.KeyframeMotion.CrossingFailure();
if (grp.RootPart.KeyframeMotion != null)
grp.RootPart.KeyframeMotion.CrossingFailure(); grp.ScheduleGroupForFullUpdate();
grp.ScheduleGroupForFullUpdate();
}
} }
} }