From 1d4b173ee4f2121ecc206c47afa9dfe5268b8f1c Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sat, 2 May 2020 23:06:55 +0200 Subject: [PATCH] [FIXED] Re-add missing legacy @[get|set]env_i commands --- indra/newview/rlvenvironment.cpp | 45 +++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/indra/newview/rlvenvironment.cpp b/indra/newview/rlvenvironment.cpp index b4e1c6fbea..f305309e0c 100644 --- a/indra/newview/rlvenvironment.cpp +++ b/indra/newview/rlvenvironment.cpp @@ -488,14 +488,14 @@ bool RlvEnvironment::onHandleCommand(const RlvCommand& rlvCmd, ERlvCmdRet& cmdRe // Legacy handling (blargh) U32 idxComponent = rlvGetColorComponentFromCharacter(strEnvCommand.back()); - if (idxComponent <= VBLUE) + if (idxComponent <= VALPHA) { strEnvCommand.pop_back(); legacy_handler_map_t::const_iterator itLegacyFnEntry = legacyFnLookup.find(strEnvCommand); if (legacyFnLookup.end() != itLegacyFnEntry) { - cmdRet = itLegacyFnEntry->second(rlvCmd.getParam(), idxComponent); + cmdRet = itLegacyFnEntry->second((RLV_TYPE_FORCE == rlvCmd.getParamType()) ? rlvCmd.getOption() : rlvCmd.getParam(), idxComponent); return true; } } @@ -568,9 +568,16 @@ std::string RlvEnvironment::handleLegacyGetFn(const std::function std::string RlvEnvironment::handleLegacyGetFn(const std::function& getFn, U32 idxComponent) { - if (idxComponent > 3) - return LLStringUtil::null; - return std::to_string(getFn(LLEnvironment::instance().getCurrentSky()).mV[idxComponent]); + if ( (idxComponent >= VRED) && (idxComponent <= VBLUE) ) + { + return std::to_string(getFn(LLEnvironment::instance().getCurrentSky()).mV[idxComponent]); + } + else if (idxComponent == VALPHA) + { + const LLColor3& clr = getFn(LLEnvironment::instance().getCurrentSky()); + return std::to_string(llmax(clr.mV[VRED], clr.mV[VGREEN], clr.mV[VBLUE])); + } + return LLStringUtil::null; } template<> @@ -590,11 +597,31 @@ ERlvCmdRet RlvEnvironment::handleLegacySetFn(float optionValue, LLVec template<> ERlvCmdRet RlvEnvironment::handleLegacySetFn(float optionValue, LLColor3 curValue, const std::function& setFn, U32 idxComponent) { - if (idxComponent > 3) - return RLV_RET_FAILED_UNKNOWN; - LLSettingsSky::ptr_t pSky = LLEnvironment::instance().getCurrentSky(); - curValue.mV[idxComponent] = optionValue; + if ( (idxComponent >= VRED) && (idxComponent <= VBLUE) ) + { + curValue.mV[idxComponent] = optionValue; + } + else if (idxComponent == VALPHA) + { + const F32 curMax = llmax(curValue.mV[VRED], curValue.mV[VGREEN], curValue.mV[VBLUE]); + if ( (0.0f == optionValue) || (0.0f == curMax) ) + { + curValue.mV[VRED] = curValue.mV[VGREEN] = curValue.mV[VBLUE] = optionValue; + } + else + { + const F32 nDelta = (optionValue - curMax) / curMax; + curValue.mV[VRED] *= (1.0f + nDelta); + curValue.mV[VGREEN] *= (1.0f + nDelta); + curValue.mV[VBLUE] *= (1.0f + nDelta); + } + } + else + { + return RLV_RET_FAILED_UNKNOWN; + } + setFn(pSky, curValue); pSky->update();