diff --git a/source/client/client.cpp b/source/client/client.cpp index 1fd192b..2776971 100644 --- a/source/client/client.cpp +++ b/source/client/client.cpp @@ -82,22 +82,22 @@ int runClient(int argc, char* argv[]) error("ERROR recieving handshake from server"); std::string handshake(buffer); + std::cout<<"Handshake:"<= 0 ) { diff --git a/source/client/filesystem.cpp b/source/client/filesystem.cpp index 061303d..1ab70f5 100644 --- a/source/client/filesystem.cpp +++ b/source/client/filesystem.cpp @@ -179,8 +179,9 @@ std::string GetOrdersFromPlayerFile(const CTTRTSGame &game, player_t &player) return orders; } -int CreateAndCleanGameDir(const std::string& gameDir) +int CreateAndCleanGameDir(const std::string& gameName) { + std::string gameDir = getGamesDir()+gameName; struct stat info; int ret = stat( gameDir.c_str(), &info ); if( ret == 0 && info.st_mode & S_IFDIR ) @@ -236,11 +237,8 @@ int runFromFilesystem(int argc, char* argv[]) // Default for games std::string ttrts_games_dir = getGamesDir(); - // Current game directory - std::string gameDir = ttrts_games_dir + game.GetName(); - // Empty the current game directory - if ( CreateAndCleanGameDir(gameDir) < 0) + if ( CreateAndCleanGameDir(game.GetName()) < 0) return -1; // While the game isn't finished diff --git a/source/client/filesystem.h b/source/client/filesystem.h index 8d63fc1..7b7c338 100644 --- a/source/client/filesystem.h +++ b/source/client/filesystem.h @@ -24,4 +24,6 @@ std::string getGamesDir(); int runFromFilesystem(int argc, char* argv[]); +int CreateAndCleanGameDir(const std::string& gameName); + #endif \ No newline at end of file diff --git a/source/client/net.h b/source/client/net.h index fdab7d1..af8b64e 100644 --- a/source/client/net.h +++ b/source/client/net.h @@ -15,6 +15,8 @@ #include #include +#define TTRTS_HANDSHAKE_FORMAT "player %u name %s" + // Struct for net client info struct ClientInfo { diff --git a/source/client/server.cpp b/source/client/server.cpp index 5c07804..17fb421 100644 --- a/source/client/server.cpp +++ b/source/client/server.cpp @@ -110,13 +110,14 @@ int runServer(int argc, char* argv[]) for( auto client : myClients ) { // Handshake currently just player - std::string handshake = std::string("player ")+std::to_string((int)client.player); + char handshake[64]; + snprintf(handshake, sizeof(handshake), TTRTS_HANDSHAKE_FORMAT,(unsigned int)client.player,game.GetName().c_str()); // Output the handshake - std::cout<<"Handshaking with "<