From a47c2185c3d28f98ecef9042ecb764819db4520b Mon Sep 17 00:00:00 2001
From: Kitty Barnett <develop@catznip.com>
Date: Sun, 4 Sep 2011 23:48:57 +0200
Subject: [PATCH] - fixed : @setenv_preset:<name>=force and
 @setenv_daycycle:<name>=force don't change the current sky preset or day
 cycle

--HG--
branch : RLVa
---
 indra/newview/lldaycyclemanager.cpp | 16 ++++++++++++++++
 indra/newview/lldaycyclemanager.h   |  3 +++
 indra/newview/llenvmanager.cpp      | 11 +++++++++++
 indra/newview/llwlparammanager.cpp  | 17 +++++++++++++++++
 indra/newview/llwlparammanager.h    |  4 ++++
 indra/newview/rlvextensions.cpp     | 15 ++++++++++-----
 6 files changed, 61 insertions(+), 5 deletions(-)

diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp
index 347a467a8b..e00294d408 100644
--- a/indra/newview/lldaycyclemanager.cpp
+++ b/indra/newview/lldaycyclemanager.cpp
@@ -30,6 +30,10 @@
 
 #include "lldiriterator.h"
 
+// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
+#include <boost/algorithm/string.hpp>
+// [/RLVa:KB]
+
 void LLDayCycleManager::getPresetNames(preset_name_list_t& names) const
 {
 	names.clear();
@@ -60,6 +64,18 @@ void LLDayCycleManager::getPresetNames(preset_name_list_t& user, preset_name_lis
 	}
 }
 
+// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
+const std::string& LLDayCycleManager::findPreset(const std::string& strPresetName)
+{
+	for (dc_map_t::const_iterator itCycle = mDayCycleMap.begin(); itCycle != mDayCycleMap.end(); ++itCycle)
+	{
+		if (boost::iequals(itCycle->first, strPresetName))
+			return itCycle->first;
+	}
+	return LLStringUtil::null;
+}
+// [/RLVa:KB]
+
 void LLDayCycleManager::getUserPresetNames(preset_name_list_t& user) const
 {
 	preset_name_list_t sys; // unused
diff --git a/indra/newview/lldaycyclemanager.h b/indra/newview/lldaycyclemanager.h
index 3d2144960d..81b31dc71c 100644
--- a/indra/newview/lldaycyclemanager.h
+++ b/indra/newview/lldaycyclemanager.h
@@ -51,6 +51,9 @@ public:
 	void getPresetNames(preset_name_list_t& names) const;
 	void getPresetNames(preset_name_list_t& user, preset_name_list_t& sys) const;
 	void getUserPresetNames(preset_name_list_t& user) const;
+// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
+	const std::string& findPreset(const std::string& strPresetName);
+// [/RLVa:KB]
 
 	bool getPreset(const std::string name, LLWLDayCycle& day_cycle) const;
 	bool getPreset(const std::string name, LLSD& day_cycle) const;
diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp
index 055643ed73..5df9ac428b 100644
--- a/indra/newview/llenvmanager.cpp
+++ b/indra/newview/llenvmanager.cpp
@@ -35,6 +35,10 @@
 #include "llwaterparammanager.h"
 #include "llwlhandlers.h"
 #include "llwlparammanager.h"
+// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
+#include <boost/algorithm/string.hpp>
+#include "rlvhandler.h"
+// [/RLVa:KB]
 
 std::string LLEnvPrefs::getWaterPresetName() const
 {
@@ -597,6 +601,13 @@ void LLEnvManagerNew::updateWaterFromPrefs(bool interpolate)
 
 void LLEnvManagerNew::updateManagersFromPrefs(bool interpolate)
 {
+// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
+	if (gRlvHandler.hasBehaviour(RLV_BHVR_SETENV))
+	{
+		return;
+	}
+// [/RLVa:KB]
+
 	// Apply water settings.
 	updateWaterFromPrefs(interpolate);
 
diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp
index 55608a059f..07a60e6852 100644
--- a/indra/newview/llwlparammanager.cpp
+++ b/indra/newview/llwlparammanager.cpp
@@ -61,6 +61,10 @@
 #include "curl/curl.h"
 #include "llstreamtools.h"
 
+// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
+#include <boost/algorithm/string.hpp>
+// [/RLVa:KB]
+
 LLWLParamManager::LLWLParamManager() :
 
 	//set the defaults for the controls
@@ -645,6 +649,19 @@ void LLWLParamManager::getPresetNames(preset_name_list_t& region, preset_name_li
 	}
 }
 
+// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
+const std::string& LLWLParamManager::findPreset(const std::string& strPresetName, LLEnvKey::EScope eScope)
+{
+	for (std::map<LLWLParamKey, LLWLParamSet>::const_iterator itList = mParamList.begin(); itList != mParamList.end(); itList++)
+	{
+		const LLWLParamKey& wlKey = itList->first;
+		if ( (wlKey.scope == eScope) && (boost::iequals(wlKey.name, strPresetName)) )
+			return wlKey.name;
+	}
+	return LLStringUtil::null;
+}
+// [/RLVa:KB]
+
 void LLWLParamManager::getUserPresetNames(preset_name_list_t& user) const
 {
 	preset_name_list_t region, sys; // unused
diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h
index bc984b9126..5f39b62cc6 100644
--- a/indra/newview/llwlparammanager.h
+++ b/indra/newview/llwlparammanager.h
@@ -288,6 +288,10 @@ public:
 	/// @return user and system preset names as a single list
 	void getPresetNames(preset_name_list_t& region, preset_name_list_t& user, preset_name_list_t& sys) const;
 
+// [RLVa:KB] - Checked: 2011-09-04 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
+	const std::string& findPreset(const std::string& strPresetName, LLEnvKey::EScope eScope);
+// [/RLVa:KB]
+
 	/// @return user preset names
 	void getUserPresetNames(preset_name_list_t& user) const;
 
diff --git a/indra/newview/rlvextensions.cpp b/indra/newview/rlvextensions.cpp
index 0b467d9887..c1308b5092 100644
--- a/indra/newview/rlvextensions.cpp
+++ b/indra/newview/rlvextensions.cpp
@@ -17,6 +17,7 @@
 #include "llviewerprecompiledheaders.h"
 #include "llagent.h"
 #include "llagentcamera.h"
+#include "lldaycyclemanager.h"
 #include "llviewercontrol.h"
 #include "llvoavatarself.h"
 #include "llwlparammanager.h"
@@ -264,7 +265,7 @@ bool RlvWindLight::setValue(const std::string& strRlvName, const std::string& st
 	F32 nValue = 0.0f;
 	// Sanity check - make sure strValue specifies a number for all settings except "preset" and "daycycle"
 	if ( (RlvSettings::getNoSetEnv()) || 
-		 ( (!LLStringUtil::convertToF32(strValue, nValue)) && (("preset" != strRlvName) || ("daycycle" != strRlvName)) ) )
+		 ( (!LLStringUtil::convertToF32(strValue, nValue)) && (("preset" != strRlvName) && ("daycycle" != strRlvName)) ) )
  	{
 		return false;
 	}
@@ -288,13 +289,17 @@ bool RlvWindLight::setValue(const std::string& strRlvName, const std::string& st
 	}
 	else if ("preset" == strRlvName)
 	{
-		pEnvMgr->useSkyPreset(strValue);
-		return true;
+		std::string strPresetName = pWLParams->findPreset(strValue, LLEnvKey::SCOPE_LOCAL);
+		if (!strPresetName.empty())
+			pEnvMgr->useSkyPreset(strPresetName);
+		return !strPresetName.empty();
 	}
 	else if ("daycycle" == strRlvName)
 	{
-		pEnvMgr->useDayCycle(strValue, LLEnvKey::SCOPE_LOCAL);
-		return true;
+		std::string strPresetName = LLDayCycleManager::instance().findPreset(strValue);
+		if (!strPresetName.empty())
+			pEnvMgr->useDayCycle(strValue, LLEnvKey::SCOPE_LOCAL);
+		return !strPresetName.empty();
 	}
 
 	bool fError = false;
-- 
GitLab