summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2018-08-31 11:47:18 -0700
committerRider Linden <rider@lindenlab.com>2018-08-31 11:47:18 -0700
commit3b10414c632e73d66d2840ddcd474a79fa120540 (patch)
tree2d216ef5de0138cf347f9fbbc04defecc618b420 /indra
parentcb7592e4904ce4dcfb472d24b2da50bf50351091 (diff)
Adding optional flags to settings objects.
Diffstat (limited to 'indra')
-rw-r--r--indra/llinventory/llsettingsbase.cpp38
-rw-r--r--indra/llinventory/llsettingsbase.h48
-rw-r--r--indra/llinventory/llsettingssky.cpp1
-rw-r--r--indra/newview/llenvironment.cpp4
4 files changed, 88 insertions, 3 deletions
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp
index 938f614fc9..5283a8dc8a 100644
--- a/indra/llinventory/llsettingsbase.cpp
+++ b/indra/llinventory/llsettingsbase.cpp
@@ -54,6 +54,10 @@ const std::string LLSettingsBase::SETTING_NAME("name");
const std::string LLSettingsBase::SETTING_HASH("hash");
const std::string LLSettingsBase::SETTING_TYPE("type");
const std::string LLSettingsBase::SETTING_ASSETID("asset_id");
+const std::string LLSettingsBase::SETTING_FLAGS("flags");
+
+const U32 LLSettingsBase::FLAG_NOCOPY(0x01 << 0);
+const U32 LLSettingsBase::FLAG_NOMOD(0x01 << 1);
//=========================================================================
LLSettingsBase::LLSettingsBase():
@@ -239,13 +243,23 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F
// case LLSD::TypeBinary:
// case LLSD::TypeDate:
default:
- /* TODO: If the UUID points to an image ID, blend the images. */
// atomic or unknown data types. Lerping between them does not make sense so switch at the break.
newSettings[key_name] = (mix > BREAK_POINT) ? other_value : value;
break;
}
}
+ // Special handling cases
+ // Flags
+ if (settings.has(SETTING_FLAGS))
+ {
+ U32 flags = (U32)settings[SETTING_FLAGS].asInteger();
+ if (other.has(SETTING_FLAGS))
+ flags |= (U32)other[SETTING_FLAGS].asInteger();
+
+ newSettings[SETTING_FLAGS] = LLSD::Integer(flags);
+ }
+
// Now add anything that is in other but not in the settings
for (LLSD::map_const_iterator it = other.beginMap(); it != other.endMap(); ++it)
{
@@ -262,6 +276,19 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F
return newSettings;
}
+LLSettingsBase::stringset_t LLSettingsBase::getSkipInterpolateKeys() const
+{
+ static stringset_t skipSet;
+
+ if (skipSet.empty())
+ {
+ skipSet.insert(SETTING_FLAGS);
+ skipSet.insert(SETTING_HASH);
+ }
+
+ return skipSet;
+}
+
LLSD LLSettingsBase::getSettings() const
{
return mSettings;
@@ -311,6 +338,7 @@ LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &valida
static Validator validateHash(SETTING_HASH, false, LLSD::TypeInteger);
static Validator validateType(SETTING_TYPE, false, LLSD::TypeString);
static Validator validateAssetId(SETTING_ASSETID, false, LLSD::TypeUUID);
+ static Validator validateFlags(SETTING_FLAGS, false, LLSD::TypeInteger);
stringset_t validated;
stringset_t strip;
bool isValid(true);
@@ -353,6 +381,13 @@ LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &valida
}
validated.insert(validateType.getName());
+ if (!validateFlags.verify(settings))
+ {
+ errors.append(LLSD::String("Unable to validate 'flags'."));
+ isValid = false;
+ }
+ validated.insert(validateFlags.getName());
+
// Fields for specific settings.
for (validation_list_t::iterator itv = validations.begin(); itv != validations.end(); ++itv)
{
@@ -415,7 +450,6 @@ bool LLSettingsBase::Validator::verify(LLSD &data)
{
if (!mDefault.isUndefined())
{
- LL_INFOS("SETTINGS") << "Inserting missing default for '" << mName << "'." << LL_ENDL;
data[mName] = mDefault;
return true;
}
diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h
index 7884240ae3..a90cec6323 100644
--- a/indra/llinventory/llsettingsbase.h
+++ b/indra/llinventory/llsettingsbase.h
@@ -70,6 +70,10 @@ public:
static const std::string SETTING_HASH;
static const std::string SETTING_TYPE;
static const std::string SETTING_ASSETID;
+ static const std::string SETTING_FLAGS;
+
+ static const U32 FLAG_NOCOPY;
+ static const U32 FLAG_NOMOD;
typedef std::map<std::string, S32> parammapping_t;
@@ -113,6 +117,48 @@ public:
return LLUUID();
}
+ inline U32 getFlags() const
+ {
+ if (mSettings.has(SETTING_FLAGS))
+ return static_cast<U32>(mSettings[SETTING_FLAGS].asInteger());
+ return 0;
+ }
+
+ inline void setFlags(U32 value)
+ {
+ setLLSD(SETTING_FLAGS, LLSD::Integer(value));
+ }
+
+ inline bool getFlag(U32 flag) const
+ {
+ if (mSettings.has(SETTING_FLAGS))
+ return ((U32)mSettings[SETTING_FLAGS].asInteger() & flag) == flag;
+ return false;
+ }
+
+ inline void setFlag(U32 flag)
+ {
+ U32 flags((mSettings.has(SETTING_FLAGS)) ? (U32)mSettings[SETTING_FLAGS].asInteger() : 0);
+
+ flags |= flag;
+
+ if (flags)
+ mSettings[SETTING_FLAGS] = LLSD::Integer(flags);
+ else
+ mSettings.erase(SETTING_FLAGS);
+ }
+
+ inline void clearFlag(U32 flag)
+ {
+ U32 flags((mSettings.has(SETTING_FLAGS)) ? (U32)mSettings[SETTING_FLAGS].asInteger() : 0);
+
+ flags &= ~flag;
+
+ if (flags)
+ mSettings[SETTING_FLAGS] = LLSD::Integer(flags);
+ else
+ mSettings.erase(SETTING_FLAGS);
+ }
virtual void replaceSettings(LLSD settings)
{
@@ -270,7 +316,7 @@ protected:
/// when lerping between settings, some may require special handling.
/// Get a list of these key to be skipped by the default settings lerp.
/// (handling should be performed in the override of lerpSettings.
- virtual stringset_t getSkipInterpolateKeys() const { return stringset_t(); }
+ virtual stringset_t getSkipInterpolateKeys() const;
// A list of settings that represent quaternions and should be slerped
// rather than lerped.
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index dbf9117882..0203e5067a 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -435,6 +435,7 @@ LLSettingsSky::stringset_t LLSettingsSky::getSkipInterpolateKeys() const
if (skipSet.empty())
{
+ skipSet = LLSettingsBase::getSkipInterpolateKeys();
skipSet.insert(SETTING_RAYLEIGH_CONFIG);
skipSet.insert(SETTING_MIE_CONFIG);
skipSet.insert(SETTING_ABSORPTION_CONFIG);
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index 6e19df0a94..3a1aec6319 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -444,11 +444,15 @@ F32 LLEnvironment::getWaterHeight() const
bool LLEnvironment::getIsSunUp() const
{
+ if (!mCurrentEnvironment || !mCurrentEnvironment->getSky())
+ return false;
return mCurrentEnvironment->getSky()->getIsSunUp();
}
bool LLEnvironment::getIsMoonUp() const
{
+ if (!mCurrentEnvironment || !mCurrentEnvironment->getSky())
+ return false;
return mCurrentEnvironment->getSky()->getIsMoonUp();
}