From 09e4a6213b84347da4acc900867dee340b0825ff Mon Sep 17 00:00:00 2001
From: Kitty Barnett <develop@catznip.com>
Date: Wed, 11 May 2011 19:10:30 +0200
Subject: [PATCH] - added : @alwaysrun=n|y and @temprun=n|y

--HG--
branch : RLVa
---
 indra/newview/llagent.cpp          | 41 +++++++++++++++++++++++++++---
 indra/newview/llagent.h            | 26 ++++++++++++++-----
 indra/newview/llmoveview.cpp       | 23 ++++++++++++-----
 indra/newview/llviewerjoystick.cpp | 14 +++++++---
 indra/newview/llviewerkeyboard.cpp | 30 ++++++++++++++--------
 indra/newview/llviewermenu.cpp     |  6 ++---
 indra/newview/llviewermessage.cpp  |  5 +++-
 indra/newview/rlvdefines.h         |  2 ++
 indra/newview/rlvhandler.cpp       | 16 ++++++++++++
 indra/newview/rlvhelper.cpp        | 10 ++++----
 10 files changed, 133 insertions(+), 40 deletions(-)

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index 2c0943974d7..fb58407f62d 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -171,7 +171,10 @@ LLAgent::LLAgent() :
 	mDoubleTapRunMode(DOUBLETAP_NONE),
 
 	mbAlwaysRun(false),
-	mbRunning(false),
+//	mbRunning(false),
+// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
+	mbTempRun(false),
+// [/RLVa:KB]
 	mbTeleportKeepsLookAt(false),
 
 	mAgentAccess(gSavedSettings),
@@ -2602,7 +2605,36 @@ void LLAgent::sendAnimationRequest(const LLUUID &anim_id, EAnimRequest request)
 	sendReliableMessage();
 }
 
-void LLAgent::sendWalkRun(bool running)
+// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
+void LLAgent::setAlwaysRun()
+{
+	mbAlwaysRun = (!rlv_handler_t::isEnabled()) || (!gRlvHandler.hasBehaviour(RLV_BHVR_ALWAYSRUN));
+	sendWalkRun();
+}
+
+void LLAgent::setTempRun()
+{
+	mbTempRun = (!rlv_handler_t::isEnabled()) || (!gRlvHandler.hasBehaviour(RLV_BHVR_TEMPRUN));
+	sendWalkRun();
+}
+
+void LLAgent::clearAlwaysRun()
+{
+	mbAlwaysRun = false;
+	sendWalkRun();
+}
+
+void LLAgent::clearTempRun()
+{
+	mbTempRun = false;
+	sendWalkRun();
+}
+// [/RLVa:KB]
+
+//void LLAgent::sendWalkRun(bool running)
+// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
+void LLAgent::sendWalkRun()
+// [/RLVa:KB]
 {
 	LLMessageSystem* msgsys = gMessageSystem;
 	if (msgsys)
@@ -2611,7 +2643,10 @@ void LLAgent::sendWalkRun(bool running)
 		msgsys->nextBlockFast(_PREHASH_AgentData);
 		msgsys->addUUIDFast(_PREHASH_AgentID, getID());
 		msgsys->addUUIDFast(_PREHASH_SessionID, getSessionID());
-		msgsys->addBOOLFast(_PREHASH_AlwaysRun, BOOL(running) );
+//		msgsys->addBOOLFast(_PREHASH_AlwaysRun, BOOL(running) );
+// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
+		msgsys->addBOOLFast(_PREHASH_AlwaysRun, BOOL(getRunning()) );
+// [/RLVa:KB]
 		sendReliableMessage();
 	}
 }
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index 896408c0dd6..ea3fa3ce647 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -330,19 +330,31 @@ class LLAgent : public LLOldEvents::LLObservable
 		DOUBLETAP_SLIDERIGHT
 	};
 
-	void			setAlwaysRun() 			{ mbAlwaysRun = true; }
-	void			clearAlwaysRun() 		{ mbAlwaysRun = false; }
-	void			setRunning() 			{ mbRunning = true; }
-	void			clearRunning() 			{ mbRunning = false; }
-	void 			sendWalkRun(bool running);
+// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
+	void			setAlwaysRun();
+	void			setTempRun();
+	void			clearAlwaysRun();
+	void			clearTempRun();
+	void 			sendWalkRun();
+	bool			getTempRun()		{ return mbTempRun; }
+	bool			getRunning() const 		{ return (mbAlwaysRun) || (mbTempRun); }
+// [/RLVa:KB]
+//	void			setAlwaysRun() 			{ mbAlwaysRun = true; }
+//	void			clearAlwaysRun() 		{ mbAlwaysRun = false; }
+//	void			setRunning() 			{ mbRunning = true; }
+//	void			clearRunning() 			{ mbRunning = false; }
+//	void 			sendWalkRun(bool running);
 	bool			getAlwaysRun() const 	{ return mbAlwaysRun; }
-	bool			getRunning() const 		{ return mbRunning; }
+//	bool			getRunning() const 		{ return mbRunning; }
 public:
 	LLFrameTimer 	mDoubleTapRunTimer;
 	EDoubleTapRunMode mDoubleTapRunMode;
 private:
 	bool 			mbAlwaysRun; 			// Should the avatar run by default rather than walk?
-	bool 			mbRunning;				// Is the avatar trying to run right now?
+// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
+	bool 			mbTempRun;
+// [/RLVa:KB]
+//	bool 			mbRunning;				// Is the avatar trying to run right now?
 	bool			mbTeleportKeepsLookAt;	// Try to keep look-at after teleport is complete
 
 	//--------------------------------------------------------------------
diff --git a/indra/newview/llmoveview.cpp b/indra/newview/llmoveview.cpp
index c7b187612a9..d7168ef55b1 100644
--- a/indra/newview/llmoveview.cpp
+++ b/indra/newview/llmoveview.cpp
@@ -326,23 +326,32 @@ void LLFloaterMove::setMovementMode(const EMovementMode mode)
 	{
 	case MM_RUN:
 		gAgent.setAlwaysRun();
-		gAgent.setRunning();
+//		gAgent.setRunning();
 		break;
 	case MM_WALK:
 		gAgent.clearAlwaysRun();
-		gAgent.clearRunning();
+//		gAgent.clearRunning();
 		break;
 	default:
 		//do nothing for other modes (MM_FLY)
 		break;
 	}
 	// tell the simulator.
-	gAgent.sendWalkRun(gAgent.getAlwaysRun());
-	
-	updateButtonsWithMovementMode(mode);
+//	gAgent.sendWalkRun(gAgent.getAlwaysRun());
+//	
+//	updateButtonsWithMovementMode(mode);
+//
+//	bool bHideModeButtons = MM_FLY == mode
+//		|| (isAgentAvatarValid() && gAgentAvatarp->isSitting());
+// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
+	// Running may have been restricted so update walk-vs-run from the agent's actual running state
+	if ( (MM_WALK == mode) || (MM_RUN == mode) )
+		mCurrentMode = (gAgent.getRunning()) ? MM_RUN : MM_WALK;
 
-	bool bHideModeButtons = MM_FLY == mode
-		|| (isAgentAvatarValid() && gAgentAvatarp->isSitting());
+	updateButtonsWithMovementMode(mCurrentMode);
+
+	bool bHideModeButtons = (MM_FLY == mCurrentMode) || (isAgentAvatarValid() && gAgentAvatarp->isSitting());
+// [/RLVa:KB]
 
 	showModeButtons(!bHideModeButtons);
 
diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp
index e1dd72dddcc..b7dccd08d60 100644
--- a/indra/newview/llviewerjoystick.cpp
+++ b/indra/newview/llviewerjoystick.cpp
@@ -329,8 +329,11 @@ void LLViewerJoystick::handleRun(F32 inc)
 		if (1 == mJoystickRun)
 		{
 			++mJoystickRun;
-			gAgent.setRunning();
-			gAgent.sendWalkRun(gAgent.getRunning());
+//			gAgent.setRunning();
+//			gAgent.sendWalkRun(gAgent.getRunning());
+// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
+			gAgent.setTempRun();
+// [/RLVa:KB]
 		}
 		else if (0 == mJoystickRun)
 		{
@@ -345,8 +348,11 @@ void LLViewerJoystick::handleRun(F32 inc)
 			--mJoystickRun;
 			if (0 == mJoystickRun)
 			{
-				gAgent.clearRunning();
-				gAgent.sendWalkRun(gAgent.getRunning());
+//				gAgent.clearRunning();
+//				gAgent.sendWalkRun(gAgent.getRunning());
+// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
+				gAgent.clearTempRun();
+// [/RLVa:KB]
 			}
 		}
 	}
diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp
index 1aa9fd8a45d..6f4f449e463 100644
--- a/indra/newview/llviewerkeyboard.cpp
+++ b/indra/newview/llviewerkeyboard.cpp
@@ -41,6 +41,9 @@
 #include "llvoavatarself.h"
 #include "llfloatercamera.h"
 #include "llinitparam.h"
+// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
+#include "rlvhandler.h"
+// [/RLVa:KB]
 
 //
 // Constants
@@ -91,14 +94,18 @@ static void agent_handle_doubletap_run(EKeystate s, LLAgent::EDoubleTapRunMode m
 {
 	if (KEYSTATE_UP == s)
 	{
-		if (gAgent.mDoubleTapRunMode == mode &&
-		    gAgent.getRunning() &&
-		    !gAgent.getAlwaysRun())
-		{
-			// Turn off temporary running.
-			gAgent.clearRunning();
-			gAgent.sendWalkRun(gAgent.getRunning());
-		}
+//		if (gAgent.mDoubleTapRunMode == mode &&
+//		    gAgent.getRunning() &&
+//		    !gAgent.getAlwaysRun())
+//		{
+//			// Turn off temporary running.
+//			gAgent.clearRunning();
+//			gAgent.sendWalkRun(gAgent.getRunning());
+//		}
+// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
+		if ( (gAgent.mDoubleTapRunMode == mode) && (gAgent.getTempRun()) )
+			gAgent.clearTempRun();
+// [/RLVa:KB]
 	}
 	else if (gSavedSettings.getBOOL("AllowTapTapHoldRun") &&
 		 KEYSTATE_DOWN == s &&
@@ -109,8 +116,11 @@ static void agent_handle_doubletap_run(EKeystate s, LLAgent::EDoubleTapRunMode m
 		{
 			// Same walk-key was pushed again quickly; this is a
 			// double-tap so engage temporary running.
-			gAgent.setRunning();
-			gAgent.sendWalkRun(gAgent.getRunning());
+//			gAgent.setRunning();
+//			gAgent.sendWalkRun(gAgent.getRunning());
+// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
+			gAgent.setTempRun();
+// [/RLVa:KB]
 		}
 
 		// Pressing any walk-key resets the double-tap timer
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 2bef71da1a1..2957a60da20 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -5317,16 +5317,16 @@ class LLWorldAlwaysRun : public view_listener_t
 		if (gAgent.getAlwaysRun())
 		{
 			gAgent.clearAlwaysRun();
-			gAgent.clearRunning();
+//			gAgent.clearRunning();
 		}
 		else
 		{
 			gAgent.setAlwaysRun();
-			gAgent.setRunning();
+//			gAgent.setRunning();
 		}
 
 		// tell the simulator.
-		gAgent.sendWalkRun(gAgent.getAlwaysRun());
+//		gAgent.sendWalkRun(gAgent.getAlwaysRun());
 
 		// Update Movement Controls according to AlwaysRun mode
 		LLFloaterMove::setAlwaysRunMode(gAgent.getAlwaysRun());
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 091e520af69..f34f18d4f33 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -4233,7 +4233,10 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**)
 	}
 	
 	// send walk-vs-run status
-	gAgent.sendWalkRun(gAgent.getRunning() || gAgent.getAlwaysRun());
+//	gAgent.sendWalkRun(gAgent.getRunning() || gAgent.getAlwaysRun());
+// [RLVa:KB] - Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
+	gAgent.sendWalkRun();
+// [/RLVa:KB]
 
 	// If the server version has changed, display an info box and offer
 	// to display the release notes, unless this is the initial log in.
diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h
index 6ca7eb4db6a..4042c244d90 100644
--- a/indra/newview/rlvdefines.h
+++ b/indra/newview/rlvdefines.h
@@ -191,6 +191,8 @@ enum ERlvBehaviour {
 	RLV_BHVR_STANDTP,				// "standtp"
 	RLV_BHVR_SETDEBUG,				// "setdebug"
 	RLV_BHVR_SETENV,				// "setenv"
+	RLV_BHVR_ALWAYSRUN,				// "alwaysrun"
+	RLV_BHVR_TEMPRUN,				// "temprun
 	RLV_BHVR_DETACHME,				// "detachme"
 	RLV_BHVR_ATTACHOVER,			// "attachover"
 	RLV_BHVR_ATTACHTHIS,			// "attachthis"
diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp
index cefa6910756..20a0b7e8826 100644
--- a/indra/newview/rlvhandler.cpp
+++ b/indra/newview/rlvhandler.cpp
@@ -1106,6 +1106,22 @@ ERlvCmdRet RlvHandler::processAddRemCommand(const RlvCommand& rlvCmd)
 					pObj->mText->setString( (RLV_TYPE_ADD == eType) ? "" : pObj->mText->getObjectText());
 			}
 			break;
+		case RLV_BHVR_ALWAYSRUN:			// @alwaysrun=n|y					- Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
+			{
+				VERIFY_OPTION_REF(strOption.empty());
+
+				if (RLV_TYPE_ADD == eType)
+					gAgent.clearAlwaysRun();
+			}
+			break;
+		case RLV_BHVR_TEMPRUN:				// @temprun=n|y						- Checked: 2011-05-11 (RLVa-1.3.0i) | Added: RLVa-1.3.0i
+			{
+				VERIFY_OPTION_REF(strOption.empty());
+
+				if (RLV_TYPE_ADD == eType)
+					gAgent.clearTempRun();
+			}
+			break;
 		// The following block is only valid if there's no option
 		case RLV_BHVR_SHOWLOC:				// @showloc=n|y						- Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h
 		case RLV_BHVR_SHOWNAMES:			// @shownames=n|y					- Checked: 2009-12-05 (RLVa-1.1.0h) | Modified: RLVa-1.1.0h
diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp
index 672d5d53d13..458cc773cac 100644
--- a/indra/newview/rlvhelper.cpp
+++ b/indra/newview/rlvhelper.cpp
@@ -156,11 +156,11 @@ void RlvCommand::initLookupTable()
 				"tplm", "tploc", "tplure", "viewnote", "viewscript", "viewtexture", "acceptpermission", "accepttp", "allowidle", 
 				"displayname", "edit", "editobj", "rez", "fartouch", "interact", "touchobj", "touchattach", "touchattachself", 
 				"touchattachother", "touchhud", "touchworld", "touchall", "fly", "unsit", "sit", "sittp", "standtp", "setdebug", "setenv", 
-				"detachme", "attachover", "attachthis", "attachthisover", "detachthis", "attachall", "attachallover", "detachall", 
-				"attachallthis", "attachallthisover", "detachallthis", "tpto", "version", "versionnew", "versionnum", "getattach", 
-				"getattachnames", "getaddattachnames", "getremattachnames", "getoutfit", "getoutfitnames", "getaddoutfitnames", 
-				"getremoutfitnames", "findfolder", "findfolders", "getpath", "getpathnew", "getinv", "getinvworn", "getsitid", 
-				"getcommand", "getstatus", "getstatusall"
+				"alwaysrun", "temprun", "detachme", "attachover", "attachthis", "attachthisover", "detachthis", "attachall", "attachallover",
+				"detachall", "attachallthis", "attachallthisover", "detachallthis", "tpto", "version", "versionnew", "versionnum", 
+				"getattach", "getattachnames", "getaddattachnames", "getremattachnames", "getoutfit", "getoutfitnames", 
+				"getaddoutfitnames", "getremoutfitnames", "findfolder", "findfolders", "getpath", "getpathnew", "getinv", "getinvworn", 
+				"getsitid", "getcommand", "getstatus", "getstatusall"
 			};
 
 		for (int idxBvhr = 0; idxBvhr < RLV_BHVR_COUNT; idxBvhr++)
-- 
GitLab