- if error during reload saved settings, restore original settings (to avoid corrupted game settings not matching the UI). Discovered after renaming romans_beta to romans and faction not found when restoring saved settings

This commit is contained in:
Mark Vejvoda 2011-04-19 22:53:37 +00:00
parent 8063b019a4
commit 6967f23a92
2 changed files with 103 additions and 96 deletions

View File

@ -1085,8 +1085,7 @@ void MenuStateCustomGame::RestoreLastGameSettings() {
needToRepublishToMasterserver = true;
}
if(hasNetworkGameSettings() == true)
{
if(hasNetworkGameSettings() == true) {
needToSetChangedGameSettings = true;
lastSetChangedGameSettings = time(NULL);
}
@ -2426,6 +2425,9 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
GameSettings gameSettings;
GameSettings originalGameSettings;
loadGameSettings(&originalGameSettings);
Config &config = Config::getInstance();
string userData = config.getString("UserData_Root","");
if(userData != "") {
@ -2491,6 +2493,23 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
setupUIFromGameSettings(gameSettings);
}
catch(const exception &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ERROR = [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
showMessageBox( ex.what(), "Error", false);
setupUIFromGameSettings(originalGameSettings);
gameSettings = originalGameSettings;
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
return gameSettings;
}
void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettings) {
listBoxMapFilter.setSelectedItemIndex(gameSettings.getMapFilterIndex());
listBoxMap.setItems(formattedPlayerSortedMaps[gameSettings.getMapFilterIndex()]);
@ -2583,20 +2602,7 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
needToSetChangedGameSettings = true;
lastSetChangedGameSettings = time(NULL);
}
}
catch(const exception &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ERROR = [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
showMessageBox( ex.what(), "Error", false);
gameSettings = GameSettings();
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
return gameSettings;
}
// ============ PRIVATE ===========================
bool MenuStateCustomGame::hasNetworkGameSettings() {

View File

@ -208,6 +208,7 @@ private:
void cleanup();
int32 getNetworkPlayerStatus();
void setupUIFromGameSettings(const GameSettings &gameSettings);
};
}}//end namespace