From 5a76ebc069f86b4e31e74512dba0af2edaa6f628 Mon Sep 17 00:00:00 2001
From: andreykproductengine <akleshchev@productengine.com>
Date: Fri, 21 Mar 2014 22:20:59 +0200
Subject: [PATCH] MAINT-1805 FIXED "Back" button doesn't teleport user to
 correct location after performing several teleports to a different locations

Agent position gets reseted frequently while not all varibles are uptadet,
as result it is not reliable for inter-region teleportation.
Changed to value from message.
---
 indra/newview/llviewerparcelmgr.cpp | 12 +++++++++++-
 indra/newview/llviewerparcelmgr.h   |  1 +
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp
index e361fad9de..04f02872f3 100755
--- a/indra/newview/llviewerparcelmgr.cpp
+++ b/indra/newview/llviewerparcelmgr.cpp
@@ -118,6 +118,7 @@ LLViewerParcelMgr::LLViewerParcelMgr()
 	mHoverRequestResult(0),
 	mHoverWestSouth(),
 	mHoverEastNorth(),
+	mTeleportInProgressPosition(),
 	mRenderCollision(FALSE),
 	mRenderSelection(TRUE),
 	mCollisionBanned(0),
@@ -1586,7 +1587,15 @@ void LLViewerParcelMgr::processParcelProperties(LLMessageSystem *msg, void **use
 			if (instance->mTeleportInProgress)
 			{
 				instance->mTeleportInProgress = FALSE;
-				instance->mTeleportFinishedSignal(gAgent.getPositionGlobal(), false);
+				if(instance->mTeleportInProgressPosition.isNull())
+				{
+					//initial update
+					instance->mTeleportFinishedSignal(gAgent.getPositionGlobal(), false);
+				}
+				else
+				{
+					instance->mTeleportFinishedSignal(instance->mTeleportInProgressPosition, false);
+				}
 			}
 		}
 	}
@@ -2495,6 +2504,7 @@ void LLViewerParcelMgr::onTeleportFinished(bool local, const LLVector3d& new_pos
 		// Non-local teleport (inter-region or between different parcels of the same region).
 		// The agent parcel data has not been updated yet.
 		// Let's wait for the update and then emit the signal.
+		mTeleportInProgressPosition = new_pos;
 		mTeleportInProgress = TRUE;
 	}
 }
diff --git a/indra/newview/llviewerparcelmgr.h b/indra/newview/llviewerparcelmgr.h
index 9da49bb3f3..ee8d4778d9 100755
--- a/indra/newview/llviewerparcelmgr.h
+++ b/indra/newview/llviewerparcelmgr.h
@@ -336,6 +336,7 @@ private:
 	LLDynamicArray<LLParcelObserver*> mObservers;
 
 	BOOL						mTeleportInProgress;
+	LLVector3d					mTeleportInProgressPosition;
 	teleport_finished_signal_t	mTeleportFinishedSignal;
 	teleport_failed_signal_t	mTeleportFailedSignal;
 
-- 
GitLab