- 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:
parent
8063b019a4
commit
6967f23a92
|
@ -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()]);
|
||||
|
||||
|
@ -2584,19 +2603,6 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
|||
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() {
|
||||
|
|
|
@ -208,6 +208,7 @@ private:
|
|||
void cleanup();
|
||||
|
||||
int32 getNetworkPlayerStatus();
|
||||
void setupUIFromGameSettings(const GameSettings &gameSettings);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
|
Loading…
Reference in New Issue
Block a user