summaryrefslogtreecommitdiff
path: root/indra/newview/lldaycyclemanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lldaycyclemanager.cpp')
-rw-r--r--indra/newview/lldaycyclemanager.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp
index 960879c32c..ab442d7c83 100644
--- a/indra/newview/lldaycyclemanager.cpp
+++ b/indra/newview/lldaycyclemanager.cpp
@@ -88,19 +88,40 @@ bool LLDayCycleManager::savePreset(const std::string& name, const LLSD& data)
bool LLDayCycleManager::deletePreset(const std::string& name)
{
- std::string path;
- std::string filename = LLURI::escape(name) + ".xml";
+ // Remove it from the map.
+ dc_map_t::iterator it = mDayCycleMap.find(name);
+ if (it == mDayCycleMap.end())
+ {
+ LL_WARNS("Windlight") << "No day cycle named " << name << LL_ENDL;
+ return false;
+ }
+ mDayCycleMap.erase(it);
- // Try removing specified user preset.
- path = getUserDir() + filename;
- if (gDirUtilp->fileExists(path))
+ // Remove from the filesystem.
+ std::string filename = LLURI::escape(name) + ".xml";
+ if (gDirUtilp->fileExists(getUserDir() + filename))
{
gDirUtilp->deleteFilesInDir(getUserDir(), filename);
- mModifySignal();
- return true;
}
- // Invalid or system preset.
+ // Signal interested parties.
+ mModifySignal();
+ return true;
+}
+
+bool LLDayCycleManager::isSkyPresetReferenced(const std::string& preset_name) const
+{
+ // We're traversing local day cycles, they can only reference local skies.
+ LLWLParamKey key(preset_name, LLEnvKey::SCOPE_LOCAL);
+
+ for (dc_map_t::const_iterator it = mDayCycleMap.begin(); it != mDayCycleMap.end(); ++it)
+ {
+ if (it->second.hasReferencesTo(key))
+ {
+ return true;
+ }
+ }
+
return false;
}
@@ -144,7 +165,7 @@ bool LLDayCycleManager::loadPreset(const std::string& path)
LLSD data = LLWLDayCycle::loadDayCycleFromPath(path);
if (data.isUndefined())
{
- LL_WARNS("Windlight") << "Error loading day cycle from " << path << LL_ENDL;
+ llwarns << "Error loading day cycle from " << path << llendl;
return false;
}