From dfb6c130cac9e1abbc90956857cf3c516f4633d8 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Sun, 26 Jan 2014 19:22:27 -0800 Subject: [PATCH] - additional bugfix when restoring last game settings --- source/glest_game/main/battle_end.cpp | 6 ++-- .../menu/menu_state_custom_game.cpp | 32 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/source/glest_game/main/battle_end.cpp b/source/glest_game/main/battle_end.cpp index 87a599eb..a10b0f98 100644 --- a/source/glest_game/main/battle_end.cpp +++ b/source/glest_game/main/battle_end.cpp @@ -264,7 +264,7 @@ string BattleEnd::getBattleEndMusic(bool won) { void BattleEnd::initBackgroundMusic() { string music = ""; - if(stats.getThisFactionIndex() > 0 && stats.getTeam(stats.getThisFactionIndex()) != GameConstants::maxPlayers -1 + fpt_Observer) { + if(stats.getThisFactionIndex() >= 0 && stats.getTeam(stats.getThisFactionIndex()) != GameConstants::maxPlayers -1 + fpt_Observer) { if(stats.getVictory(stats.getThisFactionIndex())){ //header += lang.getString("Victory"); music = getBattleEndMusic(true); @@ -299,7 +299,7 @@ void BattleEnd::initBackgroundVideo() { string videoFile = ""; string videoFileFallback = ""; - if(stats.getThisFactionIndex() > 0 && stats.getTeam(stats.getThisFactionIndex()) != GameConstants::maxPlayers -1 + fpt_Observer) { + if(stats.getThisFactionIndex() >= 0 && stats.getTeam(stats.getThisFactionIndex()) != GameConstants::maxPlayers -1 + fpt_Observer) { if(stats.getVictory(stats.getThisFactionIndex())){ //header += lang.getString("Victory"); @@ -682,7 +682,7 @@ void BattleEnd::render() { string header = stats.getDescription() + " - "; - if(stats.getThisFactionIndex() > 0 && stats.getTeam(stats.getThisFactionIndex()) != GameConstants::maxPlayers -1 + fpt_Observer) { + if(stats.getThisFactionIndex() >= 0 && stats.getTeam(stats.getThisFactionIndex()) != GameConstants::maxPlayers -1 + fpt_Observer) { if(stats.getVictory(stats.getThisFactionIndex())){ header += lang.getString("Victory"); } diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 30ebc7c6..9f33fbd6 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -3825,28 +3825,30 @@ void MenuStateCustomGame::saveGameSettingsToFile(std::string fileName) { void MenuStateCustomGame::KeepCurrentHumanPlayerSlots(GameSettings &gameSettings) { //look for human players + bool foundValidHumanControlTypeInFile = false; + for(int index2 = 0; index2 < GameConstants::maxPlayers; ++index2) { + ControlType ctFile = static_cast(gameSettings.getFactionControl(index2)); + if(ctFile == ctHuman) { + ControlType ctUI = static_cast(listBoxControls[index2].getSelectedItemIndex()); + if(ctUI != ctNetwork && ctUI != ctNetworkUnassigned) { + foundValidHumanControlTypeInFile = true; + //printf("Human found in file [%d]\n",index2); + } + else if(labelPlayerNames[index2].getText() == "") { + foundValidHumanControlTypeInFile = true; + } + } + } + for(int index = 0; index < GameConstants::maxPlayers; ++index) { ControlType ct= static_cast(listBoxControls[index].getSelectedItemIndex()); if(ct == ctHuman) { - - bool foundControlType = false; - for(int index2 = 0; index2 < GameConstants::maxPlayers; ++index2) { - ControlType ctFile = static_cast(gameSettings.getFactionControl(index2)); - if(ctFile == ctHuman) { - ControlType ctUI = static_cast(listBoxControls[index2].getSelectedItemIndex()); - if(ctUI != ctNetwork && ctUI != ctNetworkUnassigned) { - foundControlType = true; - //printf("Human found in file [%d]\n",index2); - } - } - } - //printf("Human found in UI [%d] and file [%d]\n",index,foundControlType); - if(foundControlType == false) { + if(foundValidHumanControlTypeInFile == false) { gameSettings.setFactionControl(index,ctHuman); + gameSettings.setNetworkPlayerName(index,getHumanPlayerName()); } - gameSettings.setNetworkPlayerName(index,getHumanPlayerName()); } } }