From 48ab8b7b325119b6fd2e996ab0b7b21ca9c028c6 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 1 Jan 2011 10:16:25 +0000 Subject: [PATCH] - added more socket threaded protection and output curl version if ftp transfers fail --- source/glest_game/global/config.cpp | 21 +++++++++++++++++++ source/glest_game/main/main.cpp | 3 ++- .../menu/menu_state_connected_game.cpp | 9 ++++++-- .../glest_game/network/client_interface.cpp | 7 ------- .../glest_game/network/server_interface.cpp | 7 ++++++- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/source/glest_game/global/config.cpp b/source/glest_game/global/config.cpp index bf4a99fe7..c3de9be27 100644 --- a/source/glest_game/global/config.cpp +++ b/source/glest_game/global/config.cpp @@ -409,6 +409,27 @@ vector Config::getPathListForType(PathType type, string scenarioDir) { if(isdir(userData.c_str()) == false) { createDirectoryPaths(userData); } + + string userDataMaps = userData + GameConstants::folder_path_maps; + if(isdir(userDataMaps.c_str()) == false) { + createDirectoryPaths(userDataMaps); + } + string userDataScenarios = userData + GameConstants::folder_path_scenarios; + if(isdir(userDataScenarios.c_str()) == false) { + createDirectoryPaths(userDataScenarios); + } + string userDataTechs = userData + GameConstants::folder_path_techs; + if(isdir(userDataTechs.c_str()) == false) { + createDirectoryPaths(userDataTechs); + } + string userDataTilesets = userData + GameConstants::folder_path_tilesets; + if(isdir(userDataTilesets.c_str()) == false) { + createDirectoryPaths(userDataTilesets); + } + string userDataTutorials = userData + GameConstants::folder_path_tutorials; + if(isdir(userDataTutorials.c_str()) == false) { + createDirectoryPaths(userDataTutorials); + } } if(scenarioDir != "") { pathList.push_back(data_path+scenarioDir); diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 2e92c6f96..58e451ebd 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -1011,7 +1011,8 @@ int glestMain(int argc, char** argv) { 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_LUA_INFO]) == true) && + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LUA_INFO]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_CURL_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 7ffdd59c3..145d215d2 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -1691,8 +1691,10 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName, FTP_Client clientInterface->sendTextMessage(szMsg,-1, true); } else { + curl_version_info_data *curlVersion= curl_version_info(CURLVERSION_NOW); + char szMsg[1024]=""; - sprintf(szMsg,"Player: %s FAILED to download the map: %s",getHumanPlayerName().c_str(),gameSettings->getMap().c_str()); + sprintf(szMsg,"Player: %s FAILED to download the map: [%s] using CURL version [%s]",getHumanPlayerName().c_str(),gameSettings->getMap().c_str(),curlVersion->version); clientInterface->sendTextMessage(szMsg,-1, true); } } @@ -1712,8 +1714,11 @@ void MenuStateConnectedGame::FTPClient_CallbackEvent(string itemName, FTP_Client findDirs(Config::getInstance().getPathListForType(ptTilesets), tileSets); } else { + + curl_version_info_data *curlVersion= curl_version_info(CURLVERSION_NOW); + char szMsg[1024]=""; - sprintf(szMsg,"Player: %s FAILED to download the tileset: %s",getHumanPlayerName().c_str(),gameSettings->getTileset().c_str()); + sprintf(szMsg,"Player: %s FAILED to download the tileset: [%s] using CURL version [%s]",getHumanPlayerName().c_str(),gameSettings->getTileset().c_str(),curlVersion->version); clientInterface->sendTextMessage(szMsg,-1, true); } } diff --git a/source/glest_game/network/client_interface.cpp b/source/glest_game/network/client_interface.cpp index 8e1a68bac..b5caa5fe8 100755 --- a/source/glest_game/network/client_interface.cpp +++ b/source/glest_game/network/client_interface.cpp @@ -142,9 +142,6 @@ void ClientInterface::update() { string sMsg = "may go out of synch: client requestedCommands.size() = " + intToStr(requestedCommands.size()); sendTextMessage(sMsg,-1, true); } - - //clear chat variables - //!!!clearChatInfo(); } std::string ClientInterface::getServerIpAddress() { @@ -153,10 +150,6 @@ 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) diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index 4f66eba97..241c616c6 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -345,11 +345,16 @@ void ServerInterface::updateSlot(ConnectionSlotEvent *event) { bool checkForNewClients = true; // Safety check since we can experience a disconnect and the slot is NULL - MutexSafeWrapper safeMutexSlot(&slotAccessorMutexes[event->triggerId],intToStr(__LINE__) + "_" + intToStr(event->triggerId)); ConnectionSlot *connectionSlot = NULL; + MutexSafeWrapper safeMutexSlot(NULL); if(event->triggerId >= 0 && event->triggerId < GameConstants::maxPlayers) { + safeMutexSlot.setMutex(&slotAccessorMutexes[event->triggerId],intToStr(__LINE__) + "_" + intToStr(event->triggerId)); connectionSlot = slots[event->triggerId]; } + else { + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR CONDITION, event->triggerId = %d\n",__FILE__,__FUNCTION__,__LINE__,event->triggerId); + SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] ERROR CONDITION, event->triggerId = %d\n",__FILE__,__FUNCTION__,__LINE__,event->triggerId); + } if(connectionSlot != NULL && (gameHasBeenInitiated == false ||