From 05847617e628bcdccb9dea698baac3b3b7aaab55 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Mon, 18 Apr 2011 02:22:26 +0000 Subject: [PATCH] - bugfix to get proper factions for faction listing in menus (ignore files and look only at folders) - split apart crc mismatch faction names if string too long --- .../menu/menu_state_connected_game.cpp | 27 +++++++++++++++++-- .../menu/menu_state_custom_game.cpp | 7 +++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 478607b4..8c5d3b24 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -1299,6 +1299,7 @@ void MenuStateConnectedGame::update() { bool localEcho = lang.isLanguageLocal(languageList[i]); string mismatchedFactionText = ""; + vector mismatchedFactionTextList; vector > serverFactionCRCList = gameSettings->getFactionCRCList(); for(unsigned int factionIdx = 0; factionIdx < serverFactionCRCList.size(); ++factionIdx) { @@ -1311,6 +1312,10 @@ void MenuStateConnectedGame::update() { if(serverFaction.first == clientFaction.first) { foundFaction = true; if(serverFaction.second != clientFaction.second) { + if(mismatchedFactionText.length() >= 150) { + mismatchedFactionTextList.push_back(mismatchedFactionText); + mismatchedFactionText = ""; + } if(mismatchedFactionText == "") { mismatchedFactionText = "The following factions are mismatched: "; if(lang.hasString("MismatchedFactions",languageList[i]) == true) { @@ -1326,6 +1331,11 @@ void MenuStateConnectedGame::update() { } if(foundFaction == false) { + if(mismatchedFactionText.length() >= 150) { + mismatchedFactionTextList.push_back(mismatchedFactionText); + mismatchedFactionText = ""; + } + if(mismatchedFactionText == "") { mismatchedFactionText = "The following factions are mismatched: "; if(lang.hasString("MismatchedFactions",languageList[i]) == true) { @@ -1357,6 +1367,11 @@ void MenuStateConnectedGame::update() { } if(foundFaction == false) { + if(mismatchedFactionText.length() >= 150) { + mismatchedFactionTextList.push_back(mismatchedFactionText); + mismatchedFactionText = ""; + } + if(mismatchedFactionText == "") { mismatchedFactionText = "The following factions are mismatched: "; if(lang.hasString("MismatchedFactions",languageList[i]) == true) { @@ -1375,7 +1390,14 @@ void MenuStateConnectedGame::update() { } if(mismatchedFactionText != "") { - clientInterface->sendTextMessage(mismatchedFactionText,-1,localEcho,languageList[i]); + if(mismatchedFactionTextList.size() > 0) { + for(unsigned int splitIdx = 0; splitIdx < mismatchedFactionTextList.size(); ++splitIdx) { + clientInterface->sendTextMessage(mismatchedFactionTextList[splitIdx],-1,localEcho,languageList[i]); + } + } + else { + clientInterface->sendTextMessage(mismatchedFactionText,-1,localEcho,languageList[i]); + } } } } @@ -1947,7 +1969,8 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool for(int idx = 0; idx < techPaths.size(); idx++) { string &techPath = techPaths[idx]; endPathWithSlash(techPath); - findAll(techPath + gameSettings->getTech() + "/factions/*.", results, false, false); + //findAll(techPath + gameSettings->getTech() + "/factions/*.", results, false, false); + findDirs(techPath + gameSettings->getTech() + "/factions/", results, false, false); if(results.size() > 0) { break; } diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 9c4df28f..3f146019 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -473,7 +473,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b for(int idx = 0; idx < techPaths.size(); idx++) { string &techPath = techPaths[idx]; endPathWithSlash(techPath); - findAll(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false); + //findAll(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false); + findDirs(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/", results, false, false); if(results.size() > 0) { break; @@ -2673,7 +2674,9 @@ void MenuStateCustomGame::reloadFactions(bool keepExistingSelectedItem) { for(int idx = 0; idx < techPaths.size(); idx++) { string &techPath = techPaths[idx]; endPathWithSlash(techPath); - findAll(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false); + //findAll(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/*.", results, false, false); + findDirs(techPath + techTreeFiles[listBoxTechTree.getSelectedItemIndex()] + "/factions/", results, false, false); + if(results.size() > 0) { break; }