From 276e151642d8fb83658938e7f3d5817dfec346fe Mon Sep 17 00:00:00 2001
From: Kitty Barnett <develop@catznip.com>
Date: Sun, 4 Sep 2011 23:25:04 +0200
Subject: [PATCH] - internal : deprecate RlvWLSnapshot in favour of the new
 user WindLight preferences

--HG--
branch : RLVa
---
 indra/newview/rlvcommon.h    |  1 -
 indra/newview/rlvhandler.cpp | 45 ++++++++----------------------------
 indra/newview/rlvhandler.h   |  2 --
 indra/newview/rlvhelper.cpp  | 33 --------------------------
 indra/newview/rlvhelper.h    | 17 --------------
 indra/newview/rlvui.cpp      |  5 ++++
 6 files changed, 15 insertions(+), 88 deletions(-)

diff --git a/indra/newview/rlvcommon.h b/indra/newview/rlvcommon.h
index f13d6ec5d2..4a2f64f64e 100644
--- a/indra/newview/rlvcommon.h
+++ b/indra/newview/rlvcommon.h
@@ -56,7 +56,6 @@ struct RlvException;
 typedef boost::variant<std::string, LLUUID, S32, ERlvBehaviour> RlvExceptionOption;
 
 class RlvGCTimer;
-class RlvWLSnapshot;
 
 // ============================================================================
 // RlvSettings
diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp
index bcbaf263e5..4db0f533a3 100644
--- a/indra/newview/rlvhandler.cpp
+++ b/indra/newview/rlvhandler.cpp
@@ -72,7 +72,7 @@ static bool rlvParseNotifyOption(const std::string& strOption, S32& nChannel, st
 //
 
 // Checked: 2010-04-07 (RLVa-1.2.0d) | Modified: RLVa-1.0.1d
-RlvHandler::RlvHandler() : m_fCanCancelTp(true), m_posSitSource(), m_pGCTimer(NULL), m_pWLSnapshot(NULL)
+RlvHandler::RlvHandler() : m_fCanCancelTp(true), m_posSitSource(), m_pGCTimer(NULL)
 {
 	gAgent.addListener(this, "new group");
 
@@ -86,7 +86,6 @@ RlvHandler::~RlvHandler()
 	gAgent.removeListener(this);
 
 	//delete m_pGCTimer;	// <- deletes itself
-	delete m_pWLSnapshot;	// <- delete on NULL is harmless
 }
 
 // ============================================================================
@@ -1103,8 +1102,6 @@ void RlvHandler::clearState()
 	// Clear dynamically allocated memory
 	delete m_pGCTimer;
 	m_pGCTimer = NULL;
-	delete m_pWLSnapshot;
-	m_pWLSnapshot = NULL;
 */
 }
 
@@ -1146,8 +1143,15 @@ ERlvCmdRet RlvHandler::processAddRemCommand(const RlvCommand& rlvCmd)
 		case RLV_BHVR_DETACHALLTHISEXCEPT:	// @detachallthisexcept[:<option>]=n|y
 			eRet = onAddRemFolderLockException(rlvCmd, fRefCount);
 			break;
-		case RLV_BHVR_SETENV:				// @setenv=n|y
-			eRet = onAddRemSetEnv(rlvCmd, fRefCount);
+		case RLV_BHVR_SETENV:				// @setenv=n|y						- Checked: 2011-09-04 (RLVa-1.4.1a) | Modified: RLVa-1.4.1a
+			{
+				if (RlvSettings::getNoSetEnv())
+				{
+					eRet = RLV_RET_FAILED_DISABLED;
+					break;
+				}
+				VERIFY_OPTION_REF(strOption.empty());
+			}
 			break;
 		case RLV_BHVR_ADDOUTFIT:			// @addoutfit[:<layer>]=n|y			- Checked: 2010-08-29 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c
 		case RLV_BHVR_REMOUTFIT:			// @remoutfit[:<layer>]=n|y			- Checked: 2010-08-29 (RLVa-1.2.1c) | Modified: RLVa-1.2.1c
@@ -1557,35 +1561,6 @@ ERlvCmdRet RlvHandler::onAddRemFolderLockException(const RlvCommand& rlvCmd, boo
 	return RLV_RET_SUCCESS;
 }
 
-// Checked: 2010-03-18 (RLVa-1.2.0e) | Modified: RLVa-1.2.0a
-ERlvCmdRet RlvHandler::onAddRemSetEnv(const RlvCommand& rlvCmd, bool& fRefCount)
-{
-	// Sanity check - there shouldn't be an option
-	if (!rlvCmd.getOption().empty())
-		return RLV_RET_FAILED_OPTION;
-	if (RlvSettings::getNoSetEnv())
-		return RLV_RET_FAILED_DISABLED;
-
-	if (RLV_TYPE_ADD == rlvCmd.getParamType())
-	{
-		// Save the current WindLight params so we can restore them on @setenv=y
-		RLV_ASSERT(!m_pWLSnapshot);
-		if (m_pWLSnapshot)
-			delete m_pWLSnapshot;
-		m_pWLSnapshot = RlvWLSnapshot::takeSnapshot();
-	}
-	else
-	{
-		// Restore WindLight parameters to what they were before @setenv=n was issued
-		RlvWLSnapshot::restoreSnapshot(m_pWLSnapshot);
-		delete m_pWLSnapshot;
-		m_pWLSnapshot = NULL;
-	}
-	fRefCount = true;
-
-	return RLV_RET_SUCCESS;
-}
-
 // ============================================================================
 // Command handlers (RLV_TYPE_FORCE)
 //
diff --git a/indra/newview/rlvhandler.h b/indra/newview/rlvhandler.h
index bc141eb4b8..ecc30ce1c6 100644
--- a/indra/newview/rlvhandler.h
+++ b/indra/newview/rlvhandler.h
@@ -163,7 +163,6 @@ protected:
 	ERlvCmdRet onAddRemDetach(const RlvCommand& rlvCmd, bool& fRefCount);
 	ERlvCmdRet onAddRemFolderLock(const RlvCommand& rlvCmd, bool& fRefCount);
 	ERlvCmdRet onAddRemFolderLockException(const RlvCommand& rlvCmd, bool& fRefCount);
-	ERlvCmdRet onAddRemSetEnv(const RlvCommand& rlvCmd, bool& fRefCount);
 	// Command handlers (RLV_TYPE_FORCE)
 	ERlvCmdRet processForceCommand(const RlvCommand& rlvCmd) const;
 	ERlvCmdRet onForceRemAttach(const RlvCommand& rlvCmd) const;
@@ -197,7 +196,6 @@ protected:
 
 	rlv_command_list_t    m_Retained;
 	RlvGCTimer*           m_pGCTimer;
-	RlvWLSnapshot*        m_pWLSnapshot;
 
 	std::stack<const RlvCommand*> m_CurCommandStack;// Convenience (see @tpto)
 	std::stack<LLUUID>    m_CurObjectStack;			// Convenience (see @tpto)
diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp
index 7caf81fcc4..64daa124ca 100644
--- a/indra/newview/rlvhelper.cpp
+++ b/indra/newview/rlvhelper.cpp
@@ -1056,39 +1056,6 @@ void RlvBehaviourNotifyHandler::onReattach(const LLViewerJointAttachment* pAttac
 	sendNotification(llformat("reattached %s %s", (fAllowed) ? "legally" : "illegally", pAttachPt->getName().c_str()));
 }
 
-// ============================================================================
-// RlvWLSnapshot
-//
-
-// Checked: 2010-03-18 (RLVa-1.2.0e) | Added: RLVa-0.2.0h
-void RlvWLSnapshot::restoreSnapshot(const RlvWLSnapshot* pWLSnapshot)
-{
-//	LLWLParamManager* pWLParams = LLWLParamManager::instance();
-//	if ( (pWLSnapshot) && (pWLParams) )
-//	{
-//		pWLParams->mAnimator.mIsRunning = pWLSnapshot->fIsRunning;
-//		pWLParams->mAnimator.mUseLindenTime = pWLSnapshot->fUseLindenTime;
-//		pWLParams->mCurParams = pWLSnapshot->WLParams;
-//		pWLParams->propagateParameters();
-//	}
-}
-
-// Checked: 2010-03-18 (RLVa-1.2.0e) | Modified: RLVa-1.2.0e
-RlvWLSnapshot* RlvWLSnapshot::takeSnapshot()
-{
-//	RlvWLSnapshot* pWLSnapshot = NULL;
-//	LLWLParamManager* pWLParams = LLWLParamManager::instance();
-//	if (pWLParams)
-//	{
-//		pWLSnapshot = new RlvWLSnapshot();
-//		pWLSnapshot->fIsRunning = pWLParams->mAnimator.mIsRunning;
-//		pWLSnapshot->fUseLindenTime = pWLParams->mAnimator.mUseLindenTime;
-//		pWLSnapshot->WLParams = pWLParams->mCurParams;
-//	}
-//	return pWLSnapshot;
-	return NULL;
-}
-
 // =========================================================================
 // Various helper classes/timers/functors
 //
diff --git a/indra/newview/rlvhelper.h b/indra/newview/rlvhelper.h
index ba98329a6f..cb0275e375 100644
--- a/indra/newview/rlvhelper.h
+++ b/indra/newview/rlvhelper.h
@@ -368,23 +368,6 @@ private:
 	RlvException();
 };
 
-// ============================================================================
-// RlvWLSnapshot
-//
-
-class RlvWLSnapshot
-{
-public:
-	static void           restoreSnapshot(const RlvWLSnapshot* pWLSnapshot);
-	static RlvWLSnapshot* takeSnapshot();
-private:
-	RlvWLSnapshot() {}
-
-	bool		 fIsRunning;
-	bool		 fUseLindenTime;
-	LLWLParamSet WLParams;
-};
-
 // ============================================================================
 // Various helper classes/timers/functors
 //
diff --git a/indra/newview/rlvui.cpp b/indra/newview/rlvui.cpp
index c5ecc3009d..2bd8fee68d 100644
--- a/indra/newview/rlvui.cpp
+++ b/indra/newview/rlvui.cpp
@@ -21,6 +21,7 @@
 #include "llbottomtray.h"
 #include "llbutton.h"
 #include "llcallfloater.h"
+#include "llenvmanager.h"				// LLEnvManagerNew
 #include "llhudtext.h"
 #include "llinventorypanel.h"
 #include "llimview.h"					// LLIMMgr
@@ -204,6 +205,10 @@ void RlvUIEnabler::onToggleSetEnv()
 	// Don't allow toggling "Basic Shaders" and/or "Atmopsheric Shaders" through the debug settings under @setenv=n
 	gSavedSettings.getControl("VertexShaderEnable")->setHiddenFromSettingsEditor(!fEnable);
 	gSavedSettings.getControl("WindLightUseAtmosShaders")->setHiddenFromSettingsEditor(!fEnable);
+
+	// Restore the user's WindLight preferences when releasing
+	if (fEnable)
+		LLEnvManagerNew::instance().usePrefs();
 }
 
 // Checked: 2010-09-07 (RLVa-1.4.0a) | Modified: RLVa-1.2.1a
-- 
GitLab