diff --git a/source/glest_game/game/chat_manager.cpp b/source/glest_game/game/chat_manager.cpp index 4e4cdebb..b3ab9db0 100644 --- a/source/glest_game/game/chat_manager.cpp +++ b/source/glest_game/game/chat_manager.cpp @@ -63,7 +63,8 @@ void ChatManager::keyUp(char key){ } catch(const exception &ex) { char szBuf[1024]=""; - sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + sprintf(szBuf,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); throw runtime_error(szBuf); } SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -148,6 +149,7 @@ void ChatManager::keyDown(char key){ catch(const exception &ex) { char szBuf[1024]=""; sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); throw runtime_error(szBuf); } @@ -198,6 +200,7 @@ void ChatManager::updateNetwork() { catch(const std::exception &ex) { char szBuf[1024]=""; sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); throw runtime_error(szBuf); } } diff --git a/source/glest_game/game/console.cpp b/source/glest_game/game/console.cpp index 8a9deda2..6c7cea60 100644 --- a/source/glest_game/game/console.cpp +++ b/source/glest_game/game/console.cpp @@ -59,6 +59,7 @@ void Console::addLine(string line, bool playSound){ catch(const exception &ex) { char szBuf[1024]=""; sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); throw runtime_error(szBuf); } } diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 83e5022d..dc71c429 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -715,7 +715,9 @@ void Game::update() { //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + NetworkManager &networkManager= NetworkManager::getInstance(); if(networkManager.getGameNetworkInterface() != NULL) { networkManager.getGameNetworkInterface()->quitGame(true); @@ -896,6 +898,7 @@ void Game::mouseDownLeft(int x, int y){ } } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); NetworkManager &networkManager= NetworkManager::getInstance(); if(networkManager.getGameNetworkInterface() != NULL) { @@ -910,6 +913,7 @@ void Game::mouseDownRight(int x, int y){ gui.mouseDownRightGraphics(x, y); } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); NetworkManager &networkManager= NetworkManager::getInstance(); if(networkManager.getGameNetworkInterface() != NULL) { @@ -924,6 +928,7 @@ void Game::mouseUpLeft(int x, int y){ gui.mouseUpLeftGraphics(x, y); } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); NetworkManager &networkManager= NetworkManager::getInstance(); if(networkManager.getGameNetworkInterface() != NULL) { @@ -950,6 +955,7 @@ void Game::mouseDoubleClickLeft(int x, int y){ gui.mouseDoubleClickLeftGraphics(x, y); } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); NetworkManager &networkManager= NetworkManager::getInstance(); if(networkManager.getGameNetworkInterface() != NULL) { @@ -1043,6 +1049,7 @@ void Game::mouseMove(int x, int y, const MouseState *ms){ lastMousePos.y = mouseY; } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); NetworkManager &networkManager= NetworkManager::getInstance(); if(networkManager.getGameNetworkInterface() != NULL) { @@ -1060,6 +1067,7 @@ void Game::eventMouseWheel(int x, int y, int zDelta) { //gameCamera.setMoveY(1); } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); NetworkManager &networkManager= NetworkManager::getInstance(); if(networkManager.getGameNetworkInterface() != NULL) { @@ -1237,6 +1245,7 @@ void Game::keyDown(char key) { //throw runtime_error("Test Error!"); } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); NetworkManager &networkManager= NetworkManager::getInstance(); if(networkManager.getGameNetworkInterface() != NULL) { @@ -1277,6 +1286,7 @@ void Game::keyUp(char key){ } } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); NetworkManager &networkManager= NetworkManager::getInstance(); if(networkManager.getGameNetworkInterface() != NULL) { diff --git a/source/glest_game/global/config.cpp b/source/glest_game/global/config.cpp index 6d86dc09..217cc5c8 100644 --- a/source/glest_game/global/config.cpp +++ b/source/glest_game/global/config.cpp @@ -110,6 +110,7 @@ Config::Config(std::pair type, std::pair f } } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ERROR trying to auto-create cfgFile.second = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.second.c_str()); } diff --git a/source/glest_game/global/lang.cpp b/source/glest_game/global/lang.cpp index f70d9dc8..0a5bf69e 100644 --- a/source/glest_game/global/lang.cpp +++ b/source/glest_game/global/lang.cpp @@ -70,22 +70,28 @@ void Lang::loadScenarioStrings(const string &scenarioDir, const string &scenario } } -string Lang::get(const string &s){ +string Lang::get(const string &s) { try{ string result = strings.getString(s); replaceAll(result, "\\n", "\n"); return result; } - catch(exception &){ + catch(exception &ex) { + if(strings.getpath() != "") { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + } return "???" + s + "???"; } } -string Lang::getScenarioString(const string &s){ +string Lang::getScenarioString(const string &s) { try{ return scenarioStrings.getString(s); } - catch(exception &){ + catch(exception &ex) { + if(scenarioStrings.getpath() != "") { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + } return "???" + s + "???"; } } diff --git a/source/glest_game/graphics/particle_type.cpp b/source/glest_game/graphics/particle_type.cpp index e6187442..9b244225 100644 --- a/source/glest_game/graphics/particle_type.cpp +++ b/source/glest_game/graphics/particle_type.cpp @@ -17,11 +17,12 @@ #include "model.h" #include "config.h" #include "game_constants.h" - +#include "util.h" #include "leak_dumper.h" using namespace Shared::Xml; using namespace Shared::Graphics; +using namespace Shared::Util; namespace Glest{ namespace Game{ @@ -202,6 +203,7 @@ void ParticleSystemTypeProjectile::load(const string &dir, const string &path,Re } } catch(const exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error loading ParticleSystem: "+ path + "\n" +e.what()); } } @@ -246,6 +248,7 @@ void ParticleSystemTypeSplash::load(const string &dir, const string &path,Render horizontalSpreadB= horizontalSpreadNode->getAttribute("b")->getFloatValue(-1.0f, 1.0f); } catch(const exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error loading ParticleSystem: "+ path + "\n" +e.what()); } } diff --git a/source/glest_game/graphics/unit_particle_type.cpp b/source/glest_game/graphics/unit_particle_type.cpp index c15fc911..d1110dc6 100644 --- a/source/glest_game/graphics/unit_particle_type.cpp +++ b/source/glest_game/graphics/unit_particle_type.cpp @@ -16,12 +16,12 @@ #include "xml_parser.h" #include "config.h" #include "game_constants.h" -//#include "renderer.h" #include "leak_dumper.h" using namespace Shared::Xml; using namespace Shared::Graphics; +using namespace Shared::Util; namespace Glest{ namespace Game{ @@ -220,6 +220,7 @@ void UnitParticleSystemType::load(const string &dir, const string &path, Rendere UnitParticleSystemType::load(particleSystemNode, dir, renderer); } catch(const exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error loading ParticleSystem: "+ path + "\n" +e.what()); } } diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 6aacf255..57d88aef 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -82,11 +82,12 @@ enum GAME_ARG_TYPE { class ExceptionHandler: public PlatformExceptionHandler{ public: - virtual void handle(){ + virtual void handle() { string msg = "#1 An error ocurred and Glest will close.\nPlease report this bug to "+mailString; #ifdef WIN32 msg += ", attaching the generated "+getCrashDumpFileName()+" file."; #endif + SystemFlags::OutputDebug(SystemFlags::debugError,"%s\n",msg.c_str()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",msg.c_str()); Program *program = Program::getInstance(); @@ -101,6 +102,7 @@ public: static void handleRuntimeError(const char *msg) { Program *program = Program::getInstance(); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] [%s] gameInitialized = %d, program = %p\n",__FILE__,__FUNCTION__,__LINE__,msg,gameInitialized,program); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%s] gameInitialized = %d, program = %p\n",__FILE__,__FUNCTION__,__LINE__,msg,gameInitialized,program); if(program && gameInitialized == true) { @@ -566,13 +568,14 @@ int glestMain(int argc, char** argv){ //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled = config.getBool("DebugMode","false"); - SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled = config.getBool("DebugNetwork","false"); - SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled = config.getBool("DebugPerformance","false"); - SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled = config.getBool("DebugWorldSynch","false"); - SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled = config.getBool("DebugUnitCommands","false"); - SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled = config.getBool("DebugPathFinder","false"); - SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled = config.getBool("DebugLUA","false"); + SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled = config.getBool("DebugMode","false"); + SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled = config.getBool("DebugNetwork","false"); + SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled = config.getBool("DebugPerformance","false"); + SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled = config.getBool("DebugWorldSynch","false"); + SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled = config.getBool("DebugUnitCommands","false"); + SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled = config.getBool("DebugPathFinder","false"); + SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled = config.getBool("DebugLUA","false"); + SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled = config.getBool("DebugError","true"); string debugLogFile = config.getString("DebugLogFile",""); if(getGameReadWritePath() != "") { @@ -602,6 +605,7 @@ int glestMain(int argc, char** argv){ if(debugLUALogFile == "") { debugLUALogFile = debugLogFile; } + string debugErrorLogFile = config.getString("DebugLogFileError",""); SystemFlags::getSystemSettingType(SystemFlags::debugSystem).debugLogFileName = debugLogFile; SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).debugLogFileName = debugNetworkLogFile; @@ -610,16 +614,18 @@ int glestMain(int argc, char** argv){ SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).debugLogFileName = debugUnitCommandsLogFile; SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).debugLogFileName = debugPathFinderLogFile; SystemFlags::getSystemSettingType(SystemFlags::debugLUA).debugLogFileName = debugLUALogFile; + SystemFlags::getSystemSettingType(SystemFlags::debugError).debugLogFileName = debugErrorLogFile; if(haveSpecialOutputCommandLineOption == false) { - printf("Startup settings are: debugSystem [%d], debugNetwork [%d], debugPerformance [%d], debugWorldSynch [%d], debugUnitCommands[%d], debugPathFinder[%d], debugLUA [%d]\n", + printf("Startup settings are: debugSystem [%d], debugNetwork [%d], debugPerformance [%d], debugWorldSynch [%d], debugUnitCommands[%d], debugPathFinder[%d], debugLUA [%d], debugError [%d]\n", SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled, SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled, SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled, SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled, SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled, SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled, - SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled); + SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled, + SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled); } NetworkInterface::setDisplayMessageFunction(ExceptionHandler::DisplayMessage); diff --git a/source/glest_game/main/program.cpp b/source/glest_game/main/program.cpp index e46891fe..888332bd 100644 --- a/source/glest_game/main/program.cpp +++ b/source/glest_game/main/program.cpp @@ -439,8 +439,7 @@ void Program::setState(ProgramState *programState, bool cleanupOldState) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } catch(const exception &e){ - //exceptionMessage(e); - //throw runtime_error(e.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); this->showMessage(e.what()); setState(new Intro(this)); diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 76b1ce7d..58f0f36b 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -617,6 +617,7 @@ void MenuStateConnectedGame::render() { catch(const std::exception &ex) { char szBuf[1024]=""; sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); throw runtime_error(szBuf); } } @@ -1062,6 +1063,7 @@ void MenuStateConnectedGame::update() { catch(const runtime_error &ex) { char szBuf[1024]=""; sprintf(szBuf,"Error [%s]",ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] %s\n",__FILE__,__FUNCTION__,__LINE__,szBuf); //throw runtime_error(szBuf); showMessageBox( szBuf, "Error", false); @@ -1170,6 +1172,7 @@ bool MenuStateConnectedGame::hasNetworkGameSettings() catch(const std::exception &ex) { char szBuf[1024]=""; sprintf(szBuf,"Error [%s]",ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] %s\n",__FILE__,__FUNCTION__,__LINE__,szBuf); //throw runtime_error(szBuf); showMessageBox( szBuf, "Error", false); @@ -1425,6 +1428,7 @@ bool MenuStateConnectedGame::loadMapInfo(string file, MapInfo *mapInfo, bool loa } } catch(exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); //throw runtime_error("Error loading map file: "+file+'\n'+e.what()); diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index d013cebd..4873d013 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -85,7 +85,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b catch(const std::exception &ex) { serverInitError = true; char szBuf[1024]=""; - sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + sprintf(szBuf,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); //throw runtime_error(szBuf);!!! showGeneralError=true; @@ -1237,6 +1238,7 @@ void MenuStateCustomGame::update() { } } catch(const runtime_error &e) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] caught exception error = [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); } } @@ -1262,6 +1264,7 @@ void MenuStateCustomGame::update() { } } catch(const runtime_error &e) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] caught exception error = [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); } } @@ -1548,6 +1551,7 @@ void MenuStateCustomGame::update() { catch(const std::exception &ex) { char szBuf[1024]=""; sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); //throw runtime_error(szBuf); showGeneralError=true; @@ -2023,6 +2027,7 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName) } } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ERROR = [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); showMessageBox( ex.what(), "Error", false); @@ -2055,8 +2060,8 @@ bool MenuStateCustomGame::hasNetworkGameSettings() { } catch(const std::exception &ex) { char szBuf[1024]=""; - sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); - //throw runtime_error(szBuf); + sprintf(szBuf,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); showGeneralError=true; generalErrorToShow = ex.what(); @@ -2111,7 +2116,8 @@ void MenuStateCustomGame::loadMapInfo(string file, MapInfo *mapInfo, bool loadMa mapPreview.loadFromFile(file.c_str()); } } - catch(exception &e){ + catch(exception &e) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s] loading map [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what(),file.c_str()); throw runtime_error("Error loading map file: [" + file + "] msg: " + e.what()); } @@ -2178,7 +2184,8 @@ void MenuStateCustomGame::updateControlers(){ } catch(const std::exception &ex) { char szBuf[1024]=""; - sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + sprintf(szBuf,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); throw runtime_error(szBuf); } } @@ -2197,7 +2204,8 @@ void MenuStateCustomGame::closeUnusedSlots(){ } catch(const std::exception &ex) { char szBuf[1024]=""; - sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + sprintf(szBuf,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); throw runtime_error(szBuf); } } @@ -2215,6 +2223,7 @@ void MenuStateCustomGame::updateNetworkSlots() { catch(const std::exception &ex) { char szBuf[1024]=""; sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); showGeneralError=true; if(serverInterface->isPortBound() == false) { @@ -2236,7 +2245,8 @@ void MenuStateCustomGame::updateNetworkSlots() { } catch(const std::exception &ex) { char szBuf[1024]=""; - sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + sprintf(szBuf,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); //throw runtime_error(szBuf);!!! showGeneralError=true; diff --git a/source/glest_game/menu/menu_state_masterserver.cpp b/source/glest_game/menu/menu_state_masterserver.cpp index 664738d8..db6ddf43 100644 --- a/source/glest_game/menu/menu_state_masterserver.cpp +++ b/source/glest_game/menu/menu_state_masterserver.cpp @@ -531,6 +531,7 @@ void MenuStateMasterserver::updateServerInfo() { safeMutex.ReleaseLock(true); } catch(const exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d, error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); threadedErrorMsg = e.what(); } diff --git a/source/glest_game/network/client_interface.cpp b/source/glest_game/network/client_interface.cpp index cba90e7b..e7129728 100755 --- a/source/glest_game/network/client_interface.cpp +++ b/source/glest_game/network/client_interface.cpp @@ -368,6 +368,7 @@ void ClientInterface::updateLobby() { //} } catch(const runtime_error &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); string sErr = ex.what(); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error during processing, sErr = [%s]\n",__FILE__,__FUNCTION__,__LINE__,sErr.c_str()); diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index 8aeefa46..d7023443 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -134,6 +134,7 @@ void ConnectionSlotThread::execute() { catch(const exception &ex) { setRunningStatus(false); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); throw runtime_error(ex.what()); @@ -644,6 +645,7 @@ void ConnectionSlot::update(bool checkForNewClients) { } } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error detected [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); threadErrorList.push_back(ex.what()); diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index 0e691af7..08aa60c6 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -387,6 +387,7 @@ std::pair ServerInterface::clientLagCheck(ConnectionSlot* connectionS catch(const exception &ex) { alreadyInLagCheck = false; + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); throw runtime_error(ex.what()); } @@ -518,6 +519,7 @@ void ServerInterface::update() { } } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error detected [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); errorMsgList.push_back(ex.what()); } @@ -608,6 +610,7 @@ void ServerInterface::update() { } } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error detected [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); errorMsgList.push_back(ex.what()); } @@ -676,6 +679,7 @@ void ServerInterface::update() { } } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error detected [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); errorMsgList.push_back(ex.what()); } @@ -687,6 +691,7 @@ void ServerInterface::update() { } } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error detected [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); errorMsgList.push_back(ex.what()); } @@ -740,6 +745,7 @@ void ServerInterface::updateKeyframe(int frameCount){ broadcastMessage(&networkMessageCommandList); } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error detected [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); DisplayErrorMessage(ex.what()); } @@ -937,6 +943,7 @@ void ServerInterface::waitUntilReady(Checksum* checksum){ gameStartTime = time(NULL); } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error detected [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); DisplayErrorMessage(ex.what()); } @@ -1168,6 +1175,7 @@ void ServerInterface::broadcastMessage(const NetworkMessage* networkMessage, int } } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); //throw runtime_error(ex.what()); @@ -1196,6 +1204,7 @@ void ServerInterface::broadcastMessageToConnectedClients(const NetworkMessage* n } } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); //throw runtime_error(ex.what()); DisplayErrorMessage(ex.what()); diff --git a/source/glest_game/types/faction_type.cpp b/source/glest_game/types/faction_type.cpp index bbf01916..4db1eaf5 100644 --- a/source/glest_game/types/faction_type.cpp +++ b/source/glest_game/types/faction_type.cpp @@ -85,6 +85,7 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch } } catch(const exception &e) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error loading units: "+ dir + "\n" + e.what()); } @@ -98,6 +99,7 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch } } catch(const exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error loading upgrades: "+ dir + "\n" + e.what()); } diff --git a/source/glest_game/types/resource_type.cpp b/source/glest_game/types/resource_type.cpp index 996fb7f0..a8c99d0f 100644 --- a/source/glest_game/types/resource_type.cpp +++ b/source/glest_game/types/resource_type.cpp @@ -128,6 +128,7 @@ void ResourceType::load(const string &dir, Checksum* checksum){ } } catch(const exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error loading resource type: " + path + "\n" + e.what()); } } diff --git a/source/glest_game/types/tech_tree.cpp b/source/glest_game/types/tech_tree.cpp index 65ac1533..a1b421f8 100644 --- a/source/glest_game/types/tech_tree.cpp +++ b/source/glest_game/types/tech_tree.cpp @@ -64,6 +64,7 @@ void TechTree::load(const string &dir, set &factions, Checksum* checksum } } catch(const exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error loading Resource Types: "+ dir + "\n" + e.what()); } @@ -118,6 +119,7 @@ void TechTree::load(const string &dir, set &factions, Checksum* checksum } } catch(const exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error loading Tech Tree: "+ dir + "\n" + e.what()); } @@ -148,6 +150,7 @@ void TechTree::load(const string &dir, set &factions, Checksum* checksum } } catch(const exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error loading Faction Types: "+ dir + "\n" + e.what()); } SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index dcb97f13..1f59b85c 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -389,6 +389,7 @@ void UnitType::load(int id,const string &dir, const TechTree *techTree, const Fa } //Exception handling (conversions and so on); catch(const exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error loading UnitType: " + path + "\n" + e.what()); } diff --git a/source/glest_game/types/upgrade_type.cpp b/source/glest_game/types/upgrade_type.cpp index 051cf31f..2b0171c6 100644 --- a/source/glest_game/types/upgrade_type.cpp +++ b/source/glest_game/types/upgrade_type.cpp @@ -123,6 +123,7 @@ void UpgradeType::load(const string &dir, const TechTree *techTree, const Factio } catch(const exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error loading UpgradeType: "+ dir + "\n" +e.what()); } diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index d01a24a5..2ee54c6a 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -215,6 +215,7 @@ void Map::load(const string &path, TechTree *techTree, Tileset *tileset){ fclose(f); } catch(const exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error loading map: "+ path+ "\n"+ e.what()); } } diff --git a/source/glest_game/world/scenario.cpp b/source/glest_game/world/scenario.cpp index d6d9f81c..e61ce616 100644 --- a/source/glest_game/world/scenario.cpp +++ b/source/glest_game/world/scenario.cpp @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest (www.glest.org) // -// Copyright (C) 2001-2005 Martiņo Figueroa +// Copyright (C) 2001-2005 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -53,6 +53,7 @@ void Scenario::load(const string &path){ } //Exception handling (conversions and so on); catch(const exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error: " + path + "\n" + e.what()); } } diff --git a/source/glest_game/world/tileset.cpp b/source/glest_game/world/tileset.cpp index 9280adec..ac2e5d8e 100644 --- a/source/glest_game/world/tileset.cpp +++ b/source/glest_game/world/tileset.cpp @@ -242,6 +242,7 @@ void Tileset::load(const string &dir, Checksum *checksum){ } //Exception handling (conversions and so on); catch(const exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error: " + path + "\n" + e.what()); } } diff --git a/source/shared_lib/include/util/properties.h b/source/shared_lib/include/util/properties.h index d718e3c4..568abaf2 100644 --- a/source/shared_lib/include/util/properties.h +++ b/source/shared_lib/include/util/properties.h @@ -71,9 +71,9 @@ public: void setFloat(const string &key, float value); void setString(const string &key, const string &value); + string getpath() const { return path;} + string toString(); - - }; }}//end namespace diff --git a/source/shared_lib/include/util/util.h b/source/shared_lib/include/util/util.h index 1ba57106..4d173810 100644 --- a/source/shared_lib/include/util/util.h +++ b/source/shared_lib/include/util/util.h @@ -44,6 +44,7 @@ public: debugUnitCommands, debugPathFinder, debugLUA, + debugError }; class SystemFlagsType diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index 332a8645..15f2231a 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest Shared Library (www.glest.org) // -// Copyright (C) 2001-2008 Martiņo Figueroa +// Copyright (C) 2001-2008 Martio Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -493,6 +493,7 @@ void Model::loadG3d(const string &path){ fclose(f); } catch(exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Exception caught loading 3d file: " + path +"\n"+ e.what()); } } diff --git a/source/shared_lib/sources/lua/lua_script.cpp b/source/shared_lib/sources/lua/lua_script.cpp index caa0f3d0..294ba318 100644 --- a/source/shared_lib/sources/lua/lua_script.cpp +++ b/source/shared_lib/sources/lua/lua_script.cpp @@ -68,36 +68,49 @@ LuaScript::~LuaScript() { void LuaScript::loadCode(const string &code, const string &name){ Lua_STREFLOP_Wrapper streflopWrapper; - int errorCode= luaL_loadbuffer(luaState, code.c_str(), code.size(), name.c_str()); - if(errorCode!=0){ + int errorCode= luaL_loadbuffer(luaState, code.c_str(), code.length(), name.c_str()); + if(errorCode !=0 ) { throw runtime_error("Error loading lua code: " + errorToString(errorCode)); } + //SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] name [%s], errorCode = %d,\ncode [%s]\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),errorCode,code.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] name [%s], errorCode = %d\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),errorCode); + //run code - errorCode= lua_pcall(luaState, 0, 0, 0)!=0; - if(errorCode!=0){ + errorCode= lua_pcall(luaState, 0, 0, 0); + if(errorCode !=0 ) { throw runtime_error("Error initializing lua: " + errorToString(errorCode)); } + + //SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] name [%s], errorCode = %d,\ncode [%s]\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),errorCode,code.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] name [%s], errorCode = %d\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),errorCode); } void LuaScript::beginCall(const string& functionName){ Lua_STREFLOP_Wrapper streflopWrapper; + SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] functionName [%s]\n",__FILE__,__FUNCTION__,__LINE__,functionName.c_str()); SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] functionName [%s]\n",__FILE__,__FUNCTION__,__LINE__,functionName.c_str()); lua_getglobal(luaState, functionName.c_str()); + //if( lua_isfunction(luaState,lua_gettop(luaState)) == false) { + // throw runtime_error("Error unknown lua function called: [" + functionName + "]"); + //} argumentCount= 0; } void LuaScript::endCall(){ Lua_STREFLOP_Wrapper streflopWrapper; + SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); lua_pcall(luaState, argumentCount, 0, 0); } void LuaScript::registerFunction(LuaFunction luaFunction, const string &functionName) { Lua_STREFLOP_Wrapper streflopWrapper; + SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] functionName [%s]\n",__FILE__,__FUNCTION__,__LINE__,functionName.c_str()); + lua_pushcfunction(luaState, luaFunction); lua_setglobal(luaState, functionName.c_str()); } diff --git a/source/shared_lib/sources/platform/common/simple_threads.cpp b/source/shared_lib/sources/platform/common/simple_threads.cpp index c608d0a7..e0d34a00 100644 --- a/source/shared_lib/sources/platform/common/simple_threads.cpp +++ b/source/shared_lib/sources/platform/common/simple_threads.cpp @@ -59,10 +59,12 @@ void FileCRCPreCacheThread::execute() { } } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); setRunningStatus(false); } catch(...) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] UNKNOWN Error\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] unknown error\n",__FILE__,__FUNCTION__,__LINE__); setRunningStatus(false); } @@ -135,6 +137,8 @@ void SimpleTaskThread::execute() { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str()); } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + setRunningStatus(false); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] uniqueID [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->getUniqueID().c_str()); diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 56685474..1cc36112 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -1560,10 +1560,12 @@ void BroadCastClientSocketThread::execute() { } } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); //setRunningStatus(false); } catch(...) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] UNKNOWN Error\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] unknown error\n",__FILE__,__FUNCTION__,__LINE__); //setRunningStatus(false); } @@ -1886,11 +1888,13 @@ void BroadCastSocketThread::execute() { //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); this->setQuitStatus(true); //setRunningStatus(false); } catch(...) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] UNKNOWN Error\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] unknown error\n",__FILE__,__FUNCTION__,__LINE__); this->setQuitStatus(true); //setRunningStatus(false); diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index 61efc5d8..eb11aa7e 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -272,22 +272,22 @@ bool Window::handleEvent() { } } catch(const char *e){ - std::cerr << "(a1) Couldn't process event: " << e << " codelocation = " << codeLocation << "\n"; - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] (a1) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e,codeLocation.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (a1) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e,codeLocation.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (a1) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e,codeLocation.c_str()); throw runtime_error(e); } catch(const std::runtime_error& e) { - std::cerr << "(a2) Couldn't process event: " << e.what() << " codelocation = " << codeLocation << "\n"; - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] (a2) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (a2) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (a2) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); throw runtime_error(e.what()); } catch(const std::exception& e) { - std::cerr << "(b) Couldn't process event: " << e.what() << " codelocation = " << codeLocation << "\n"; - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] (b) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (b) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (b) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); } catch(...) { - std::cerr << "(c) Couldn't process event: [UNKNOWN ERROR] " << " codelocation = " << codeLocation << "\n"; - SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] (c) Couldn't process event: [UNKNOWN ERROR] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (c) Couldn't process event: [UNKNOWN ERROR] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str()); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (c) Couldn't process event: [UNKNOWN ERROR] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str()); } //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/shared_lib/sources/platform/win32/platform_util.cpp b/source/shared_lib/sources/platform/win32/platform_util.cpp index c0acbb93..5f90123b 100644 --- a/source/shared_lib/sources/platform/win32/platform_util.cpp +++ b/source/shared_lib/sources/platform/win32/platform_util.cpp @@ -152,6 +152,10 @@ void PlatformExceptionHandler::install(string dumpFileName){ //} void message(string message){ + std::cerr << "******************************************************\n"; + std::cerr << " " << message << "\n"; + std::cerr << "******************************************************\n"; + MessageBox(NULL, message.c_str(), "Message", MB_OK); } diff --git a/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp b/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp index a19bf74d..5fbd25a0 100644 --- a/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp +++ b/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp @@ -374,7 +374,9 @@ bool SoundPlayerDs8::init(const SoundPlayerParams *params){ initOk = true; SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); - } catch(const exception &ex) { + } + catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); } diff --git a/source/shared_lib/sources/sound/openal/sound_player_openal.cpp b/source/shared_lib/sources/sound/openal/sound_player_openal.cpp index b5448cd4..a707d4fa 100644 --- a/source/shared_lib/sources/sound/openal/sound_player_openal.cpp +++ b/source/shared_lib/sources/sound/openal/sound_player_openal.cpp @@ -342,7 +342,9 @@ bool SoundPlayerOpenAL::init(const SoundPlayerParams* params) { initOk = true; SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); - } catch(const exception &ex) { + } + catch(const exception &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); printOpenALInfo(); //throw std::runtime_error(ex.what()); @@ -416,7 +418,9 @@ void SoundPlayerOpenAL::play(StaticSound* staticSound) { if(source == 0) return; source->play(staticSound); - } catch(std::exception& e) { + } + catch(std::exception& e) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); std::cerr << "Couldn't play static sound: " << e.what() << "\n"; } } @@ -429,7 +433,9 @@ void SoundPlayerOpenAL::play(StrSound* strSound, int64 fadeOn) { try { StreamSoundSource* source = findStreamSoundSource(); source->play(strSound, fadeOn); - } catch(std::exception& e) { + } + catch(std::exception& e) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); std::cerr << "Couldn't play streaming sound: " << e.what() << "\n"; } } @@ -473,7 +479,10 @@ void SoundPlayerOpenAL::updateStreams() { StreamSoundSource* source = *i; try { source->update(); - } catch(std::exception& e) { + } + catch(std::exception& e) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); + std::cerr << "Error while updating sound stream: " << e.what() << "\n"; } @@ -481,6 +490,7 @@ void SoundPlayerOpenAL::updateStreams() { alcProcessContext(context); checkAlcError("Error while processing audio context: "); } catch(...) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] UNKNOWN Error\n",__FILE__,__FUNCTION__,__LINE__); printOpenALInfo(); throw; } diff --git a/source/shared_lib/sources/util/properties.cpp b/source/shared_lib/sources/util/properties.cpp index 120a8203..c1b2bb90 100644 --- a/source/shared_lib/sources/util/properties.cpp +++ b/source/shared_lib/sources/util/properties.cpp @@ -100,6 +100,7 @@ bool Properties::getBool(const string &key, const char *defaultValueIfNotFound) return strToBool(getString(key,defaultValueIfNotFound)); } catch(exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error accessing value: " + key + " in: " + path+"\n[" + e.what() + "]"); } } @@ -109,6 +110,7 @@ int Properties::getInt(const string &key,const char *defaultValueIfNotFound) con return strToInt(getString(key,defaultValueIfNotFound)); } catch(exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error accessing value: " + key + " in: " + path + "\n[" + e.what() + "]"); } } @@ -126,6 +128,7 @@ float Properties::getFloat(const string &key, const char *defaultValueIfNotFound return strToFloat(getString(key,defaultValueIfNotFound)); } catch(exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error accessing value: " + key + " in: " + path + "\n[" + e.what() + "]"); } } @@ -189,6 +192,7 @@ bool Properties::getBool(const char *key, const char *defaultValueIfNotFound) co return strToBool(getString(key,defaultValueIfNotFound)); } catch(exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error accessing value: " + string(key) + " in: " + path+"\n[" + e.what() + "]"); } } @@ -198,6 +202,7 @@ int Properties::getInt(const char *key,const char *defaultValueIfNotFound) const return strToInt(getString(key,defaultValueIfNotFound)); } catch(exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error accessing value: " + string(key) + " in: " + path + "\n[" + e.what() + "]"); } } @@ -207,6 +212,7 @@ float Properties::getFloat(const char *key, const char *defaultValueIfNotFound) return strToFloat(getString(key,defaultValueIfNotFound)); } catch(exception &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); throw runtime_error("Error accessing value: " + string(key) + " in: " + path + "\n[" + e.what() + "]"); } } diff --git a/source/shared_lib/sources/util/util.cpp b/source/shared_lib/sources/util/util.cpp index 9e668a40..9ae3c13f 100644 --- a/source/shared_lib/sources/util/util.cpp +++ b/source/shared_lib/sources/util/util.cpp @@ -151,12 +151,13 @@ CURL *SystemFlags::initHTTP() { void SystemFlags::init(bool haveSpecialOutputCommandLineOption) { SystemFlags::haveSpecialOutputCommandLineOption = haveSpecialOutputCommandLineOption; if(SystemFlags::debugLogFileList.size() == 0) { - SystemFlags::debugLogFileList[SystemFlags::debugSystem] = SystemFlags::SystemFlagsType(SystemFlags::debugSystem); - SystemFlags::debugLogFileList[SystemFlags::debugNetwork] = SystemFlags::SystemFlagsType(SystemFlags::debugNetwork); - SystemFlags::debugLogFileList[SystemFlags::debugPerformance] = SystemFlags::SystemFlagsType(SystemFlags::debugPerformance); - SystemFlags::debugLogFileList[SystemFlags::debugWorldSynch] = SystemFlags::SystemFlagsType(SystemFlags::debugWorldSynch); - SystemFlags::debugLogFileList[SystemFlags::debugUnitCommands] = SystemFlags::SystemFlagsType(SystemFlags::debugUnitCommands); - SystemFlags::debugLogFileList[SystemFlags::debugLUA] = SystemFlags::SystemFlagsType(SystemFlags::debugLUA); + SystemFlags::debugLogFileList[SystemFlags::debugSystem] = SystemFlags::SystemFlagsType(SystemFlags::debugSystem); + SystemFlags::debugLogFileList[SystemFlags::debugNetwork] = SystemFlags::SystemFlagsType(SystemFlags::debugNetwork); + SystemFlags::debugLogFileList[SystemFlags::debugPerformance] = SystemFlags::SystemFlagsType(SystemFlags::debugPerformance); + SystemFlags::debugLogFileList[SystemFlags::debugWorldSynch] = SystemFlags::SystemFlagsType(SystemFlags::debugWorldSynch); + SystemFlags::debugLogFileList[SystemFlags::debugUnitCommands] = SystemFlags::SystemFlagsType(SystemFlags::debugUnitCommands); + SystemFlags::debugLogFileList[SystemFlags::debugLUA] = SystemFlags::SystemFlagsType(SystemFlags::debugLUA); + SystemFlags::debugLogFileList[SystemFlags::debugError] = SystemFlags::SystemFlagsType(SystemFlags::debugError); } SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -360,9 +361,12 @@ void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) { MutexSafeWrapper safeMutex(currentDebugLog.mutex); - if (type != debugPathFinder) { + if (type != debugPathFinder && type != debugError) { (*currentDebugLog.fileStream) << "[" << szBuf2 << "] " << szBuf; } + else if (type == debugError) { + (*currentDebugLog.fileStream) << "[" << szBuf2 << "] *ERROR* " << szBuf; + } else { (*currentDebugLog.fileStream) << szBuf; } @@ -372,9 +376,12 @@ void SystemFlags::handleDebug(DebugType type, const char *fmt, ...) { } // output to console else { - if (type != debugPathFinder) { + if (type != debugPathFinder && type != debugError) { printf("[%s] %s", szBuf2, szBuf); } + else if (type == debugError) { + printf("[%s] *ERROR* %s", szBuf2, szBuf); + } else { printf("%s", szBuf); } diff --git a/source/shared_lib/sources/xml/xml_parser.cpp b/source/shared_lib/sources/xml/xml_parser.cpp index 727f1705..432598dd 100644 --- a/source/shared_lib/sources/xml/xml_parser.cpp +++ b/source/shared_lib/sources/xml/xml_parser.cpp @@ -15,7 +15,7 @@ #include #include "conversion.h" - +#include "util.h" #include #include #include @@ -26,6 +26,7 @@ XERCES_CPP_NAMESPACE_USE using namespace std; +using namespace Shared::Util; namespace Shared{ namespace Xml{ @@ -59,7 +60,8 @@ XmlIo::XmlIo(){ try{ XMLPlatformUtils::Initialize(); } - catch(const XMLException&){ + catch(const XMLException &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error initializing XML system\n",__FILE__,__FUNCTION__,__LINE__); throw runtime_error("Error initializing XML system"); } @@ -69,7 +71,8 @@ XmlIo::XmlIo(){ implementation = DOMImplementationRegistry::getDOMImplementation(str); } - catch(const DOMException){ + catch(const DOMException &ex){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while creating XML parser\n",__FILE__,__FUNCTION__,__LINE__); throw runtime_error("Exception while creating XML parser"); } } @@ -110,8 +113,9 @@ XmlNode *XmlIo::load(const string &path){ parser->release(); return rootNode; } - catch(const DOMException &e){ - throw runtime_error("Exception while loading: " + path + ": " + XMLString::transcode(e.msg)); + catch(const DOMException &ex) { + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while loading: [%s], %s\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),XMLString::transcode(ex.msg)); + throw runtime_error("Exception while loading: " + path + ": " + XMLString::transcode(ex.msg)); } } @@ -145,6 +149,7 @@ void XmlIo::save(const string &path, const XmlNode *node){ document->release(); } catch(const DOMException &e){ + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while saving: [%s], %s\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),XMLString::transcode(e.msg)); throw runtime_error("Exception while saving: " + path + ": " + XMLString::transcode(e.msg)); } }