From c7c18bd50630eeff6273517fa9609fcddbaf3cbd Mon Sep 17 00:00:00 2001 From: titiger Date: Thu, 14 Jan 2021 00:46:32 +0100 Subject: [PATCH] bugfix for last checkin --- .../menu/menu_state_custom_game.cpp | 19 +++++++++++++------ .../glest_game/menu/menu_state_custom_game.h | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 171cbf76..6d649407 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -4312,12 +4312,13 @@ void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettin void MenuStateCustomGame::refreshCRCCache(GameSettings *gameSettings){ Config &config = Config::getInstance(); + bool forceRefresh=false; if( gameSettings->getTileset() != "" && lastRecalculatedCRCTilesetName != gameSettings->getTileset() ) { lastRecalculatedCRCTilesetName=gameSettings->getTileset() ; // Check if we have calculated the crc since menu_state started time_t lastUpdateDate = getFolderTreeContentsCheckSumRecursivelyLastGenerated(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml"); if(difftime(lastUpdateDate,initTime) <0 ) { - getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL,false); + forceRefresh=true; } } @@ -4326,18 +4327,24 @@ void MenuStateCustomGame::refreshCRCCache(GameSettings *gameSettings){ // Check if we have calculated the crc since menu_state started time_t lastUpdateDate = getFolderTreeContentsCheckSumRecursivelyLastGenerated(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/*", ".xml"); if(difftime(lastUpdateDate,initTime) <0 ) { - getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/*", ".xml", NULL,true); + forceRefresh=true; } } // no need to deal with map CRC this is always calculated + setCRCsToGameSettings( gameSettings,forceRefresh); } -void MenuStateCustomGame::setCRCsToGameSettings(GameSettings *gameSettings){ +void MenuStateCustomGame::setCRCsToGameSettings(GameSettings *gameSettings, bool forceRefresh){ Config &config = Config::getInstance(); + if( forceRefresh ==true ){ + lastCheckedCRCTilesetName=""; + lastCheckedCRCTechtreeName=""; + } + if( gameSettings->getTileset() != "") { if(lastCheckedCRCTilesetName != gameSettings->getTileset()) { //console.addLine("Checking tileset CRC [" + gameSettings->getTileset() + "]"); - lastCheckedCRCTilesetValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL,false); + lastCheckedCRCTilesetValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTilesets,""), string("/") + gameSettings->getTileset() + string("/*"), ".xml", NULL,forceRefresh); lastCheckedCRCTilesetName = gameSettings->getTileset(); } gameSettings->setTilesetCRC(lastCheckedCRCTilesetValue); @@ -4347,7 +4354,7 @@ void MenuStateCustomGame::setCRCsToGameSettings(GameSettings *gameSettings){ if(gameSettings->getTech() != "") { if(lastCheckedCRCTechtreeName != gameSettings->getTech()) { //console.addLine("Checking techtree CRC [" + gameSettings->getTech() + "]"); - lastCheckedCRCTechtreeValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/*", ".xml", NULL,false); + lastCheckedCRCTechtreeValue = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/*", ".xml", NULL,forceRefresh); reloadFactions(true,(checkBoxScenario.getValue() == true ? scenarioFiles[listBoxScenario.getSelectedItemIndex()] : "")); factionCRCList.clear(); @@ -4356,7 +4363,7 @@ void MenuStateCustomGame::setCRCsToGameSettings(GameSettings *gameSettings){ if(factionName != GameConstants::RANDOMFACTION_SLOTNAME && factionName != GameConstants::OBSERVER_SLOTNAME) { //factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true); - uint32 factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL,false); + uint32 factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL,forceRefresh); factionCRCList.push_back(make_pair(factionName,factionCRC)); } } diff --git a/source/glest_game/menu/menu_state_custom_game.h b/source/glest_game/menu/menu_state_custom_game.h index 54824cf9..f2036a73 100644 --- a/source/glest_game/menu/menu_state_custom_game.h +++ b/source/glest_game/menu/menu_state_custom_game.h @@ -266,7 +266,7 @@ public: virtual bool isVideoPlaying(); private: - void setCRCsToGameSettings(GameSettings *gameSettings); + void setCRCsToGameSettings(GameSettings *gameSettings, bool forceRefresh=false); void refreshCRCCache(GameSettings *gameSettings); void setSmallFont(GraphicLabel l); void lastPlayerDisconnected();