From 31f0c18653b5659bfcee1d0d892c892878091679 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 31 Mar 2012 08:28:42 +0000 Subject: [PATCH] - better error handling in menus --- .../menu/menu_state_connected_game.cpp | 160 +++++------------- .../menu/menu_state_connected_game.h | 2 +- .../menu/menu_state_custom_game.cpp | 115 +++++++------ 3 files changed, 105 insertions(+), 172 deletions(-) diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index c558487c..8d3a4492 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -106,7 +106,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox"); mainMessageBox.init(lang.get("Ok")); mainMessageBox.setEnabled(false); - mainMessageBoxState=0; + //mainMessageBoxState=0; ftpMessageBox.registerGraphicComponent(containerName,"ftpMessageBox"); ftpMessageBox.init(lang.get("Yes"),lang.get("No")); @@ -497,18 +497,30 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM for(int i= 0; i < resultsScenarios.size(); ++i) { string scenario = resultsScenarios[i]; string file = Scenario::getScenarioPath(dirList, scenario); - if(file != "") { - Scenario::loadScenarioInfo(file, &scenarioInfo); - bool isNetworkScenario = false; - for(unsigned int j = 0; isNetworkScenario == false && j < GameConstants::maxPlayers; ++j) { - if(scenarioInfo.factionControls[j] == ctNetwork) { - isNetworkScenario = true; + try { + if(file != "") { + Scenario::loadScenarioInfo(file, &scenarioInfo); + + bool isNetworkScenario = false; + for(unsigned int j = 0; isNetworkScenario == false && j < GameConstants::maxPlayers; ++j) { + if(scenarioInfo.factionControls[j] == ctNetwork) { + isNetworkScenario = true; + } + } + if(isNetworkScenario == true) { + scenarioFiles.push_back(scenario); } } - if(isNetworkScenario == true) { - scenarioFiles.push_back(scenario); - } + } + catch(const std::exception &ex) { + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError loading scenario [%s]:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,scenario.c_str(),ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); + + showMessageBox( szBuf, "Error", false); + //throw runtime_error(szBuf); } } resultsScenarios.clear(); @@ -1442,12 +1454,12 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt } } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); - //showGeneralError=true; - //generalErrorToShow = szBuf; + + showMessageBox( szBuf, "Error", false); } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); @@ -2155,8 +2167,8 @@ void MenuStateConnectedGame::render() { renderer.renderConsole(&console,showFullConsole,true); } catch(const std::exception &ex) { - char szBuf[1024]=""; - sprintf(szBuf,"In [%s::%s %d] error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); throw runtime_error(szBuf); } @@ -2783,8 +2795,8 @@ void MenuStateConnectedGame::update() { } catch(const runtime_error &ex) { - char szBuf[1024]=""; - sprintf(szBuf,"Error [%s]",ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,szBuf); //throw runtime_error(szBuf); @@ -2913,8 +2925,8 @@ bool MenuStateConnectedGame::hasNetworkGameSettings() } } catch(const std::exception &ex) { - char szBuf[1024]=""; - sprintf(szBuf,"Error [%s]",ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,szBuf); showMessageBox( szBuf, "Error", false); @@ -3090,102 +3102,6 @@ void MenuStateConnectedGame::loadFactionTexture(string filepath) { } bool MenuStateConnectedGame::loadMapInfo(string file, MapInfo *mapInfo, bool loadMapPreview) { - - -/* - Lang &lang= Lang::getInstance(); - - bool mapLoaded = false; - try { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] map [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,file.c_str()); - - if(file != "") { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - - lastMissingMap = file; - -#ifdef WIN32 - FILE *f= _wfopen(utf8_decode(file).c_str(), L"rb"); -#else - FILE *f= fopen(file.c_str(), "rb"); -#endif - if(f==NULL) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - throw runtime_error("[2]Can't open file"); - } - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - - MapFileHeader header; - size_t readBytes = fread(&header, sizeof(MapFileHeader), 1, f); - - mapInfo->size.x= header.width; - mapInfo->size.y= header.height; - mapInfo->players= header.maxFactions; - - mapInfo->desc= lang.get("MaxPlayers")+": "+intToStr(mapInfo->players)+"\n"; - mapInfo->desc+=lang.get("Size")+": "+intToStr(mapInfo->size.x) + " x " + intToStr(mapInfo->size.y); - - fclose(f); - - for(int i = 0; i < GameConstants::maxPlayers; ++i) { - labelPlayers[i].setVisible(i+1 <= mapInfo->players); - labelPlayerNames[i].setVisible(i+1 <= mapInfo->players); - listBoxControls[i].setVisible(i+1 <= mapInfo->players); - listBoxFactions[i].setVisible(i+1 <= mapInfo->players); - listBoxTeams[i].setVisible(i+1 <= mapInfo->players); - labelNetStatus[i].setVisible(i+1 <= mapInfo->players); - } - - // Not painting properly so this is on hold - if(loadMapPreview == true) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - if(mapPreview.getMapFileLoaded() != file) { - mapPreview.loadFromFile(file.c_str()); - cleanupMapPreviewTexture(); - } - } - - mapLoaded = true; - } - else { - cleanupMapPreviewTexture(); - mapInfo->desc = ITEM_MISSING; - - NetworkManager &networkManager= NetworkManager::getInstance(); - ClientInterface* clientInterface= networkManager.getClientInterface(); - const GameSettings *gameSettings = clientInterface->getGameSettings(); - - if(lastMissingMap != gameSettings->getMap()) { - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); - - lastMissingMap = gameSettings->getMap(); - - Lang &lang= Lang::getInstance(); - const vector languageList = clientInterface->getGameSettings()->getUniqueNetworkPlayerLanguages(); - for(unsigned int i = 0; i < languageList.size(); ++i) { - - char szMsg[1024]=""; - if(lang.hasString("DataMissingMap",languageList[i]) == true) { - sprintf(szMsg,lang.get("DataMissingMap",languageList[i]).c_str(),getHumanPlayerName().c_str(),gameSettings->getMap().c_str()); - } - else { - sprintf(szMsg,"Player: %s is missing the map: %s",getHumanPlayerName().c_str(),gameSettings->getMap().c_str()); - } - clientInterface->sendTextMessage(szMsg,-1, lang.isLanguageLocal(languageList[i]),languageList[i]); - } - } - } - } - catch(exception &e){ - SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what()); - if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what()); - - showMessageBox( "Error loading map file: "+file+'\n'+e.what(), "Error", false); - } - - return mapLoaded; -*/ - bool mapLoaded = false; try { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] map [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,file.c_str()); @@ -4074,8 +3990,8 @@ int MenuStateConnectedGame::setupMapList(string scenario) { //printf("#7\n"); } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); @@ -4114,8 +4030,8 @@ int MenuStateConnectedGame::setupTechList(string scenario) { listBoxTechTree.setItems(results); } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); @@ -4142,8 +4058,8 @@ void MenuStateConnectedGame::setupTilesetList(string scenario) { listBoxTileset.setItems(results); } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); diff --git a/source/glest_game/menu/menu_state_connected_game.h b/source/glest_game/menu/menu_state_connected_game.h index d6c72551..8ec3e290 100644 --- a/source/glest_game/menu/menu_state_connected_game.h +++ b/source/glest_game/menu/menu_state_connected_game.h @@ -134,7 +134,7 @@ private: MapPreview mapPreview; GraphicMessageBox mainMessageBox; - int mainMessageBoxState; + //int mainMessageBoxState; std::string lastMissingMap; std::string lastMissingTechtree; diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 2cf215a4..5128454a 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -130,13 +130,13 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, } catch(const std::exception &ex) { serverInitError = true; - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nNetwork init error:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); - showGeneralError=true; - generalErrorToShow = ex.what(); + showGeneralError=true; + generalErrorToShow = szBuf; } if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); @@ -608,18 +608,31 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, for(int i= 0; i < resultsScenarios.size(); ++i) { string scenario = resultsScenarios[i]; string file = Scenario::getScenarioPath(dirList, scenario); - if(file != "") { - Scenario::loadScenarioInfo(file, &scenarioInfo); - bool isNetworkScenario = false; - for(unsigned int j = 0; isNetworkScenario == false && j < GameConstants::maxPlayers; ++j) { - if(scenarioInfo.factionControls[j] == ctNetwork) { - isNetworkScenario = true; + try { + if(file != "") { + Scenario::loadScenarioInfo(file, &scenarioInfo); + + bool isNetworkScenario = false; + for(unsigned int j = 0; isNetworkScenario == false && j < GameConstants::maxPlayers; ++j) { + if(scenarioInfo.factionControls[j] == ctNetwork) { + isNetworkScenario = true; + } + } + if(isNetworkScenario == true) { + scenarioFiles.push_back(scenario); } } - if(isNetworkScenario == true) { - scenarioFiles.push_back(scenario); - } + } + catch(const std::exception &ex) { + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError loading scenario [%s]:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,scenario.c_str(),ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); + + showGeneralError=true; + generalErrorToShow = szBuf; + //throw runtime_error(szBuf); } } resultsScenarios.clear(); @@ -648,8 +661,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); @@ -1374,10 +1387,11 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) { } } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); + showGeneralError=true; generalErrorToShow = szBuf; } @@ -1583,7 +1597,7 @@ void MenuStateCustomGame::PlayNow(bool saveGame) { if(dataSynchCheckOk == false) { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); mainMessageBoxState=1; - showMessageBox( "You cannot start the game because\none or more clients do not have the same game data!", "Data Mismatch Error", false); + showMessageBox("You cannot start the game because\none or more clients do not have the same game data!", "Data Mismatch Error", false); safeMutex.ReleaseLock(); return; @@ -1901,14 +1915,14 @@ void MenuStateCustomGame::render() { renderer.renderConsole(&console,showFullConsole,true); } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); //throw runtime_error(szBuf); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); showGeneralError=true; - generalErrorToShow = ex.what(); + generalErrorToShow = szBuf; } } @@ -2504,10 +2518,11 @@ void MenuStateCustomGame::update() { } } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); + showGeneralError=true; generalErrorToShow = szBuf; } @@ -2764,8 +2779,8 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) { //printf("-=-=-=-=- IN MenuStateCustomGame simpleTask - F\n"); } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); @@ -3183,6 +3198,7 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName) catch(const exception &ex) { SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ERROR = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + showMessageBox( ex.what(), "Error", false); setupUIFromGameSettings(originalGameSettings); @@ -3387,12 +3403,13 @@ bool MenuStateCustomGame::hasNetworkGameSettings() { } } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); + showGeneralError=true; - generalErrorToShow = ex.what(); + generalErrorToShow = szBuf; } return hasNetworkSlot; @@ -3468,8 +3485,8 @@ void MenuStateCustomGame::updateControlers() { } } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); throw runtime_error(szBuf); } @@ -3494,8 +3511,8 @@ void MenuStateCustomGame::closeUnusedSlots(){ } } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); throw runtime_error(szBuf); } @@ -3524,7 +3541,7 @@ void MenuStateCustomGame::updateNetworkSlots() { } catch(const std::exception &ex) { char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); showGeneralError=true; @@ -3565,13 +3582,13 @@ void MenuStateCustomGame::updateNetworkSlots() { } } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); //throw runtime_error(szBuf); showGeneralError=true; - generalErrorToShow = ex.what(); + generalErrorToShow = szBuf; } } @@ -4040,13 +4057,13 @@ void MenuStateCustomGame::processScenario() { SetupUIForScenarios(); } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); mainMessageBoxState=1; - showMessageBox( "Error: " + string(ex.what()), "Error detected", false); + showMessageBox( szBuf, "Error detected", false); } } @@ -4092,8 +4109,8 @@ void MenuStateCustomGame::SetupUIForScenarios() { } } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); @@ -4168,8 +4185,8 @@ int MenuStateCustomGame::setupMapList(string scenario) { //printf("#7\n"); } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); @@ -4208,8 +4225,8 @@ int MenuStateCustomGame::setupTechList(string scenario) { listBoxTechTree.setItems(results); } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); @@ -4287,8 +4304,8 @@ void MenuStateCustomGame::reloadFactions(bool keepExistingSelectedItem, string s } } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); @@ -4313,8 +4330,8 @@ void MenuStateCustomGame::setupTilesetList(string scenario) { listBoxTileset.setItems(results); } catch(const std::exception &ex) { - char szBuf[4096]=""; - sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); + char szBuf[8096]=""; + sprintf(szBuf,"In [%s::%s %d]\nError detected:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);