From 5c9fa15f30f4e245d2f200940e1f89782230fa3e Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 24 Dec 2013 11:51:50 -0800 Subject: [PATCH] varregion: fix bug where destination region is not found and object is not restored to its original location. --- .../EntityTransfer/EntityTransferModule.cs | 108 ++++++++++-------- 1 file changed, 61 insertions(+), 47 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 4954cd915c..893b3c6ce0 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1399,26 +1399,26 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Compute the entity's position relative to the new region newpos = new Vector3( (float)(presenceWorldX - (double)neighbourRegion.RegionLocX), (float)(presenceWorldY - (double)neighbourRegion.RegionLocY), - pos.Z); - - // Check if banned from destination region. + pos.Z); + + // Check if banned from destination region. ExpiringCache r; - DateTime banUntil; - if (m_bannedRegions.TryGetValue(agentID, out r)) - { - if (r.TryGetValue(neighbourRegion.RegionHandle, out banUntil)) - { - if (DateTime.Now < banUntil) - { - // If we're banned from the destination, we just can't go there. - neighbourRegion = null; - } - r.Remove(neighbourRegion.RegionHandle); - } - } - else - { - r = null; + DateTime banUntil; + if (m_bannedRegions.TryGetValue(agentID, out r)) + { + if (r.TryGetValue(neighbourRegion.RegionHandle, out banUntil)) + { + if (DateTime.Now < banUntil) + { + // If we're banned from the destination, we just can't go there. + neighbourRegion = null; + } + r.Remove(neighbourRegion.RegionHandle); + } + } + else + { + r = null; } // 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)); } else - { + { 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; } @@ -1560,17 +1572,22 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer /// Calls an asynchronous method to do so.. so it doesn't lag the sim. /// public ScenePresence CrossAgentToNewRegionAsync( - ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, - bool isFlying, string version) + ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, + 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)) { + m_log.DebugFormat("{0} CrossAgentToNewRegionAsync: prep failed. Resetting transfer state", LogHeader); m_entityTransferStateMachine.ResetFromTransit(agent.UUID); return agent; } if (!CrossAgentIntoNewRegionMain(agent, pos, neighbourRegion, isFlying)) { + m_log.DebugFormat("{0} CrossAgentToNewRegionAsync: cross main failed. Resetting transfer state", LogHeader); m_entityTransferStateMachine.ResetFromTransit(agent.UUID); return agent; } @@ -2294,28 +2311,25 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer attemptedPosition.Z); } - if (destination != null) - { - if (!CrossPrimGroupIntoNewRegion(destination, pos, grp, silent)) - { - 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 - oldGroupPosition.X = Util.Clamp(oldGroupPosition.X, 1.0f, (float)(scene.RegionInfo.RegionSizeX - 1)); - oldGroupPosition.Y = Util.Clamp(oldGroupPosition.Y, 1.0f, (float)(scene.RegionInfo.RegionSizeY - 1)); - oldGroupPosition.Z = Util.Clamp(oldGroupPosition.Z, 1.0f, Constants.RegionHeight); - - grp.AbsolutePosition = oldGroupPosition; - grp.Velocity = Vector3.Zero; - if (grp.RootPart.PhysActor != null) - grp.RootPart.PhysActor.CrossingFailure(); - - if (grp.RootPart.KeyframeMotion != null) - grp.RootPart.KeyframeMotion.CrossingFailure(); - - grp.ScheduleGroupForFullUpdate(); - } + if (destination == null || !CrossPrimGroupIntoNewRegion(destination, pos, grp, silent)) + { + 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 + oldGroupPosition.X = Util.Clamp(oldGroupPosition.X, 1.0f, (float)(scene.RegionInfo.RegionSizeX - 1)); + oldGroupPosition.Y = Util.Clamp(oldGroupPosition.Y, 1.0f, (float)(scene.RegionInfo.RegionSizeY - 1)); + oldGroupPosition.Z = Util.Clamp(oldGroupPosition.Z, 1.0f, Constants.RegionHeight); + + grp.AbsolutePosition = oldGroupPosition; + grp.Velocity = Vector3.Zero; + if (grp.RootPart.PhysActor != null) + grp.RootPart.PhysActor.CrossingFailure(); + + if (grp.RootPart.KeyframeMotion != null) + grp.RootPart.KeyframeMotion.CrossingFailure(); + + grp.ScheduleGroupForFullUpdate(); } }