From 33feeb0a01a111dc8f50bb83518459d421cccfc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liru=20F=C3=A6rs?= Date: Tue, 7 Jan 2020 17:40:43 -0500 Subject: [PATCH] Make Follow Great Again! --- indra/newview/llagent.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index f820919fa..20bfac5d9 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -1690,7 +1690,7 @@ void LLAgent::startFollowPilot(const LLUUID &leader_id, BOOL allow_flying, F32 s } startAutoPilotGlobal(object->getPositionGlobal(), - std::string(), // behavior_name + "Follow", // behavior_name NULL, // target_rotation NULL, // finish_callback NULL, // callback_data @@ -1707,6 +1707,9 @@ void LLAgent::stopAutoPilot(BOOL user_cancel) { if (mAutoPilot) { + if (!user_cancel && mAutoPilotBehaviorName == "Follow") + return; // Follow means actually follow + mAutoPilot = FALSE; if (mAutoPilotUseRotation && !user_cancel) { @@ -1751,20 +1754,24 @@ void LLAgent::autoPilot(F32 *delta_yaw) { if (mAutoPilot) { - if (!mLeaderID.isNull()) + bool follow = !mLeaderID.isNull(); //mAutoPilotBehaviorName == "Follow"; + if (follow) { LLViewerObject* object = gObjectList.findObject(mLeaderID); - if (!object) + if (!object) { + mAutoPilotBehaviorName.clear(); // Nothing left to follow pilot stopAutoPilot(); return; } mAutoPilotTargetGlobal = object->getPositionGlobal(); + if (const auto& av = object->asAvatar()) // Fly if avatar target is flying + setFlying(av->mInAir); } if (!isAgentAvatarValid()) return; - if (gAgentAvatarp->mInAir && mAutoPilotAllowFlying) + if (!follow && gAgentAvatarp->mInAir && mAutoPilotAllowFlying) { setFlying(TRUE); } @@ -1776,7 +1783,7 @@ void LLAgent::autoPilot(F32 *delta_yaw) F32 target_dist = direction.magVec(); - if (target_dist >= mAutoPilotTargetDist) + if (!follow && target_dist >= mAutoPilotTargetDist) { mAutoPilotNoProgressFrameCount++; if (mAutoPilotNoProgressFrameCount > AUTOPILOT_MAX_TIME_NO_PROGRESS * gFPSClamped)