From 61de0ae6abf3e8f54e6e47ac89c91d59e83b4926 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Fri, 18 Oct 2019 01:55:37 -0400
Subject: [PATCH] Fix animations playing inconsistently(This was never meant to
 be commited in the first place)

---
 indra/llcharacter/llmotioncontroller.cpp | 10 +++++-----
 indra/llcharacter/llmotioncontroller.h   |  3 ++-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp
index ea0c586c8d..11c2336805 100644
--- a/indra/llcharacter/llmotioncontroller.cpp
+++ b/indra/llcharacter/llmotioncontroller.cpp
@@ -333,7 +333,7 @@ void LLMotionController::removeMotionInstance(LLMotion* motionp)
 			motionp->deactivate();
 		mLoadingMotions.erase(motionp);
 		mLoadedMotions.erase(motionp);
-		mActiveMotions.erase(motionp);
+		mActiveMotions.remove(motionp);
 		delete motionp;
 	}
 }
@@ -961,9 +961,9 @@ BOOL LLMotionController::activateMotionInstance(LLMotion *motion, F32 time)
 	
 	if (motion->isActive())
 	{
-		mActiveMotions.erase(motion);
+		mActiveMotions.remove(motion);
 	}
-	mActiveMotions.emplace(motion);
+	mActiveMotions.push_front(motion);
 
 	motion->activate(time);
 	motion->onUpdate(0.f, mJointSignature[1]);
@@ -998,7 +998,7 @@ BOOL LLMotionController::deactivateMotionInstance(LLMotion *motion)
 	else
 	{
 		// for motions that we are keeping, simply remove from active queue
-		mActiveMotions.erase(motion);
+		mActiveMotions.remove(motion);
 	}
 
 	return TRUE;
@@ -1062,7 +1062,7 @@ void LLMotionController::dumpMotions()
 			state_string += std::string("l");
 		if (mLoadedMotions.find(motion) != mLoadedMotions.cend())
 			state_string += std::string("L");
-		if (mActiveMotions.find(motion) != mActiveMotions.cend())
+		if (std::find(mActiveMotions.cbegin(), mActiveMotions.cend(), motion)!=mActiveMotions.cend())
 			state_string += std::string("A");
 		if (mDeprecatedMotions.find(motion) != mDeprecatedMotions.cend())
 			state_string += std::string("D");
diff --git a/indra/llcharacter/llmotioncontroller.h b/indra/llcharacter/llmotioncontroller.h
index f10d0d49e3..3099ab9de2 100644
--- a/indra/llcharacter/llmotioncontroller.h
+++ b/indra/llcharacter/llmotioncontroller.h
@@ -83,6 +83,7 @@ class LLMotionController
 {
 public:
 	using motion_set_t = absl::flat_hash_set<LLMotion*>;
+	using motion_list_t = std::list<LLMotion*>;
 	using motion_deque_t = std::deque<LLMotion*>;
 	BOOL mIsSelf;
 	
@@ -212,7 +213,7 @@ protected:
 
 	motion_set_t		mLoadingMotions;
 	motion_set_t		mLoadedMotions;
-	motion_set_t		mActiveMotions;
+	motion_list_t		mActiveMotions;
 	motion_set_t		mDeprecatedMotions;
 	
 	LLFrameTimer		mTimer;
-- 
GitLab