From 701e1263f020298f60026376284247db4a79eefb Mon Sep 17 00:00:00 2001 From: kaienfr Date: Thu, 5 Sep 2013 18:45:41 +0200 Subject: [PATCH] New update in code style & fix load function The load function can not load all recent games list if the Key is skeeped as: FileName0 = ... FileName2 = ... ... In this case, only FileName0 is loaded. Now the function is fixed and load all list. --- Core/Config.cpp | 20 +++++++++++++------- UI/GameSettingsScreen.cpp | 5 +++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 3bb174408b..d4edc21263 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -99,8 +99,12 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) std::string fileName; sprintf(keyName,"FileName%d",i); - if (!recent->Get(keyName,&fileName,"") || fileName.length() == 0) break; - recentIsos.push_back(fileName); + if (!recent->Get(keyName,&fileName,"") || fileName.length() == 0) { + // just skip it to get the next key + } + else { + recentIsos.push_back(fileName); + } } IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU"); @@ -276,10 +280,12 @@ void Config::Save() { for (int i = 0; i < iMaxRecent; i++) { char keyName[64]; sprintf(keyName,"FileName%d",i); - if (i < recentIsos.size()){ - recent->Set(keyName, recentIsos[i]);} - else{ - recent->Delete(keyName);} // delete the nonexisting FileName + if (i < recentIsos.size()) { + recent->Set(keyName, recentIsos[i]); + } + else { + recent->Delete(keyName); // delete the nonexisting FileName + } } IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU"); @@ -405,7 +411,7 @@ void Config::CleanRecent() { cleanedRecent.push_back(recentIsos[i]); } for (size_t j=0; j