From 4ebd156828db869400b9cf28317cde8bd48bd596 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Thu, 26 Aug 2010 16:03:54 +0000 Subject: [PATCH] - added new commandline parameter to display the version of SDL used by the program --- source/glest_game/main/main.cpp | 23 ++++++++++++++- .../menu/menu_state_connected_game.cpp | 28 ++++++++++++++----- .../glest_game/network/client_interface.cpp | 9 ++++-- .../platform/common/simple_threads.cpp | 4 +-- 4 files changed, 51 insertions(+), 13 deletions(-) diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 948a32c5..b22a6419 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -54,6 +54,7 @@ const char *GAME_ARGS[] = { "--starthost", "--version", "--opengl-info", + "--sdl-info", "--validate-techtrees", "--validate-factions" }; @@ -64,6 +65,7 @@ enum GAME_ARG_TYPE { GAME_ARG_SERVER, GAME_ARG_VERSION, GAME_ARG_OPENGL_INFO, + GAME_ARG_SDL_INFO, GAME_ARG_VALIDATE_TECHTREES, GAME_ARG_VALIDATE_FACTIONS }; @@ -447,6 +449,10 @@ bool hasCommandArgument(int argc, char** argv,const string argName, int *foundIn return result; } +void print_SDL_version(char* preamble, SDL_version* v) { + printf("%s %u.%u.%u\n", preamble, v->major, v->minor, v->patch); +} + int glestMain(int argc, char** argv){ #ifdef SL_LEAK_DUMP @@ -475,6 +481,7 @@ int glestMain(int argc, char** argv){ printf("\n%s\t\t\tAuto creates a network server.",GAME_ARGS[GAME_ARG_SERVER]); printf("\n%s\t\t\tdisplays the version string of this program.",GAME_ARGS[GAME_ARG_VERSION]); printf("\n%s\t\t\tdisplays your video driver's OpenGL information.",GAME_ARGS[GAME_ARG_OPENGL_INFO]); + printf("\n%s\t\t\tdisplays your SDL version information.",GAME_ARGS[GAME_ARG_SDL_INFO]); printf("\n%s=x\t\tdisplays a report detailing any known problems related",GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]); printf("\n \t\tto your selected techtrees game data."); printf("\n \t\tWhere x is a comma-delimited list of techtrees to validate."); @@ -492,6 +499,7 @@ int glestMain(int argc, char** argv){ bool haveSpecialOutputCommandLineOption = false; if( hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_OPENGL_INFO]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SDL_INFO]) == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VERSION]) == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]) == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]) == true) { @@ -508,7 +516,20 @@ int glestMain(int argc, char** argv){ #endif } - if( hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VERSION]) == true && + if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SDL_INFO]) == true) { + SDL_version ver; + + // Prints the compile time version + SDL_VERSION(&ver); + print_SDL_version("SDL compile-time version", &ver); + + // Prints the run-time version + ver = *SDL_Linked_Version(); + print_SDL_version("SDL runtime version", &ver); + } + + if( (hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VERSION]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SDL_INFO]) == true) && hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_OPENGL_INFO]) == false && hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]) == false && hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]) == false) { diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index edb0050e..fa7cd653 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -493,13 +493,17 @@ void MenuStateConnectedGame::update() { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pingCount = %d, clientInterface->getLastPingLag() = %f, GameConstants::networkPingInterval = %d\n",__FILE__,__FUNCTION__,__LINE__,pingCount, clientInterface->getLastPingLag(),GameConstants::networkPingInterval); // Starting checking timeout after sending at least 3 pings to server - if(pingCount >= 3 && clientInterface->getLastPingLag() >= (GameConstants::networkPingInterval * 3)) { + if(clientInterface != NULL && clientInterface->isConnected() && + pingCount >= 3 && clientInterface->getLastPingLag() >= (GameConstants::networkPingInterval * 3)) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + string playerNameStr = getHumanPlayerName(); clientInterface->sendTextMessage("connection timed out communicating with server.",-1); clientInterface->close(); } pingCount++; + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } } @@ -575,6 +579,7 @@ void MenuStateConnectedGame::update() { if(clientInterface->getReceivedDataSynchCheck() == true) { updateDataSynchDetailText = false; } + //if(clientInterface->getNetworkGameDataSynchCheckOkFogOfWar() == false) //{ // label = label + " FogOfWar == false"; @@ -650,7 +655,10 @@ void MenuStateConnectedGame::update() { } //process network messages - if(clientInterface->isConnected()) { + if(clientInterface != NULL && clientInterface->isConnected()) { + + //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + bool mustSwitchPlayerName = false; if(clientInterface->getGameSettingsReceived()) { updateDataSynchDetailText = true; @@ -658,7 +666,10 @@ void MenuStateConnectedGame::update() { //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); vector maps,tilesets,techtree; const GameSettings *gameSettings=clientInterface->getGameSettings(); - + + if(gameSettings == NULL) { + throw runtime_error("gameSettings == NULL"); + } // tileset tilesets.push_back(formatString(gameSettings->getTileset())); listBoxTileset.setItems(tilesets); @@ -780,13 +791,16 @@ void MenuStateConnectedGame::update() { } //update lobby - clientInterface->updateLobby(); + clientInterface= NetworkManager::getInstance().getClientInterface(); + if(clientInterface != NULL && clientInterface->isConnected()) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] clientInterface = %p\n",__FILE__,__FUNCTION__,__LINE__,clientInterface); + clientInterface->updateLobby(); + } + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); clientInterface= NetworkManager::getInstance().getClientInterface(); if(clientInterface != NULL && clientInterface->isConnected()) { - //if(mustSwitchPlayerName == true || - // (needToSetChangedGameSettings == true && - // difftime(time(NULL),lastSetChangedGameSettings) >= 2)) { if(clientInterface->getIntroDone() == true && (switchSetupRequestFlagType & ssrft_NetworkPlayerName) == ssrft_NetworkPlayerName) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); diff --git a/source/glest_game/network/client_interface.cpp b/source/glest_game/network/client_interface.cpp index d01a322a..5642273e 100755 --- a/source/glest_game/network/client_interface.cpp +++ b/source/glest_game/network/client_interface.cpp @@ -39,7 +39,9 @@ const int ClientInterface::messageWaitTimeout= 10000; //10 seconds const int ClientInterface::waitSleepTime= 10; const int ClientInterface::maxNetworkCommandListSendTimeWait = 4; -ClientInterface::ClientInterface(){ +ClientInterface::ClientInterface() { + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] constructor for %p\n",__FILE__,__FUNCTION__,__LINE__,this); + clientSocket= NULL; sessionKey = 0; launchGame= false; @@ -60,7 +62,7 @@ ClientInterface::ClientInterface(){ ClientInterface::~ClientInterface() { - SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] destructor for %p\n",__FILE__,__FUNCTION__,__LINE__,this); if(clientSocket != NULL && clientSocket->isConnected() == true) { @@ -151,10 +153,13 @@ std::string ClientInterface::getServerIpAddress() { } void ClientInterface::updateLobby() { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //clear chat variables clearChatInfo(); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); NetworkMessageType networkMessageType = getNextMessageType(true); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); switch(networkMessageType) { case nmtInvalid: diff --git a/source/shared_lib/sources/platform/common/simple_threads.cpp b/source/shared_lib/sources/platform/common/simple_threads.cpp index e320d8b8..c608d0a7 100644 --- a/source/shared_lib/sources/platform/common/simple_threads.cpp +++ b/source/shared_lib/sources/platform/common/simple_threads.cpp @@ -67,10 +67,8 @@ void FileCRCPreCacheThread::execute() { setRunningStatus(false); } + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] FILE CRC PreCache thread is exiting\n",__FILE__,__FUNCTION__,__LINE__); setRunningStatus(false); - SystemFlags::OutputDebug(SystemFlags::debugNetwork,"FILE CRC PreCache thread is exiting\n"); - - SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); }