From f89f19990cbb9f3f2e7473ac6c159098bdfabec7 Mon Sep 17 00:00:00 2001 From: Mark Palange Date: Fri, 7 Nov 2008 17:51:03 +0000 Subject: QAR-992 Merging revisions 101012-101170,101686-101687 of svn+ssh://svn.lindenlab.com/svn/linden/qa/viewer_combo_1-22-merge into linden/release --- indra/newview/llwaterparammanager.cpp | 85 ++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 32 deletions(-) (limited to 'indra/newview/llwaterparammanager.cpp') diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index 29f086b7f9..50a65450a8 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/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.2.3