From 7abecb48babe6a6f09bf6692ba55076546cfced9 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Mon, 1 Dec 2008 17:39:58 -0600 Subject: Second Life viewer sources 1.22.0-RC --- linden/indra/newview/llwaterparammanager.cpp | 85 +++++++++++++++++----------- 1 file changed, 53 insertions(+), 32 deletions(-) (limited to 'linden/indra/newview/llwaterparammanager.cpp') diff --git a/linden/indra/newview/llwaterparammanager.cpp b/linden/indra/newview/llwaterparammanager.cpp index f4f1163..e61c5b6 100644 --- a/linden/indra/newview/llwaterparammanager.cpp +++ b/linden/indra/newview/llwaterparammanager.cpp @@ -89,48 +89,57 @@ LLWaterParamManager::~LLWaterParamManager() void LLWaterParamManager::loadAllPresets(const std::string& file_name) { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); - LL_INFOS2("AppInit", "Shaders") << "Loading water settings from " << path_name << LL_ENDL; - - //mParamList.clear(); - + LL_INFOS2("AppInit", "Shaders") << "Loading Default water settings from " << path_name << LL_ENDL; + bool found = true; while(found) { std::string name; found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false); - - LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; - - // if we have one - if(found) + if(found) { + + name=name.erase(name.length()-4); + // bugfix for SL-46920: preventing filenames that break stuff. char * curl_str = curl_unescape(name.c_str(), name.size()); std::string unescaped_name(curl_str); curl_free(curl_str); curl_str = NULL; - // not much error checking here since we're getting rid of this - std::string water_name = unescaped_name.substr(0, unescaped_name.size() - 4); - - std::string cur_path(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", name)); - LL_DEBUGS2("AppInit", "Shaders") << "Loading water from " << cur_path << LL_ENDL; + LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; + loadPreset(unescaped_name,FALSE); + } + } + + // And repeat for user presets, note the user presets will modify any system presets already loaded + + std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", "")); + LL_INFOS2("AppInit", "Shaders") << "Loading User water settings from " << path_name2 << LL_ENDL; - llifstream water_xml(cur_path); - if (water_xml) - { - LLSD water_data(LLSD::emptyMap()); - LLPointer parser = new LLSDXMLParser(); - parser->parse(water_xml, water_data, LLSDSerialize::SIZE_UNLIMITED); + found = true; + while(found) + { + std::string name; + found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name, false); + if(found) + { + name=name.erase(name.length()-4); - addParamSet(water_name, water_data); - water_xml.close(); - } + // bugfix for SL-46920: preventing filenames that break stuff. + char * curl_str = curl_unescape(name.c_str(), name.size()); + std::string unescaped_name(curl_str); + curl_free(curl_str); + curl_str = NULL; + + LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL; + loadPreset(unescaped_name,FALSE); } } + } -void LLWaterParamManager::loadPreset(const std::string & name) +void LLWaterParamManager::loadPreset(const std::string & name,bool propagate) { // bugfix for SL-46920: preventing filenames that break stuff. char * curl_str = curl_escape(name.c_str(), name.size()); @@ -142,8 +151,17 @@ void LLWaterParamManager::loadPreset(const std::string & name) std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", escaped_filename)); llinfos << "Loading water settings from " << pathName << llendl; - - llifstream presetsXML(pathName); + + std::ifstream presetsXML; + presetsXML.open(pathName.c_str()); + + // That failed, try loading from the users area instead. + if(!presetsXML) + { + pathName=gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", escaped_filename); + llinfos << "Loading User water setting from " << pathName << llendl; + presetsXML.open(pathName.c_str()); + } if (presetsXML) { @@ -170,10 +188,12 @@ void LLWaterParamManager::loadPreset(const std::string & name) return; } - getParamSet(name, mCurParams); - - propagateParameters(); -} + if(propagate) + { + getParamSet(name, mCurParams); + propagateParameters(); + } +} void LLWaterParamManager::savePreset(const std::string & name) { @@ -187,7 +207,7 @@ void LLWaterParamManager::savePreset(const std::string & name) // make an empty llsd LLSD paramsData(LLSD::emptyMap()); - std::string pathName(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", escaped_filename)); + std::string pathName(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", escaped_filename)); // fill it with LLSD windlight params paramsData = mParamList[name].getAll(); @@ -390,7 +410,8 @@ bool LLWaterParamManager::removeParamSet(const std::string& name, bool delete_fr if(delete_from_disk) { - std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", "")); + + std::string path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", "")); // use full curl escaped name char * curl_str = curl_escape(name.c_str(), name.size()); -- cgit v1.1 From a87e38229921b48c32187c672a942516722f1b52 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Sun, 11 Jan 2009 16:10:39 -0600 Subject: Second Life viewer sources 1.22.5-RC --- linden/indra/newview/llwaterparammanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'linden/indra/newview/llwaterparammanager.cpp') diff --git a/linden/indra/newview/llwaterparammanager.cpp b/linden/indra/newview/llwaterparammanager.cpp index e61c5b6..83bf555 100644 --- a/linden/indra/newview/llwaterparammanager.cpp +++ b/linden/indra/newview/llwaterparammanager.cpp @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2007&license=viewergpl$ * - * Copyright (c) 2007-2008, Linden Research, Inc. + * Copyright (c) 2007-2009, Linden Research, Inc. * * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab -- cgit v1.1