diff --git a/source/client/client.cpp b/source/client/client.cpp index d781ce3..668efcb 100644 --- a/source/client/client.cpp +++ b/source/client/client.cpp @@ -114,10 +114,12 @@ int runClient(int argc, char* argv[]) gamestate+=buffer; } - std::cout<(turnFile)), std::istreambuf_iterator()); + return orders; +} + +int CreateAndCleanGameDir(const std::string& gameDir) +{ struct stat info; int ret = stat( gameDir.c_str(), &info ); if( ret == 0 && info.st_mode & S_IFDIR ) @@ -178,6 +219,30 @@ int runFromFilesystem(int argc, char* argv[]) return -1; } + return 0; +} + +// ===================================================================================================================== +int runFromFilesystem(int argc, char* argv[]) +{ + std::string gamefile = argv[1]; + + std::cout<<"Launching TTRTS with "<(turnFile)),std::istreambuf_iterator()); + std::string orders = GetOrdersFromPlayerFile(game, player); // Issue the orders to the game if( game.IssueOrders(player, orders) ) diff --git a/source/client/filesystem.h b/source/client/filesystem.h index 851da73..aae2e14 100644 --- a/source/client/filesystem.h +++ b/source/client/filesystem.h @@ -15,6 +15,8 @@ void WaitForFile( const std::string& name, const std::chrono::milliseconds& time bool OutputGameStateFile(CTTRTSGame &game, const std::string &gameDir); +std::string GetOrdersFromPlayerFile(const CTTRTSGame &game, player_t &player); + CTTRTSGame GetGameFromFile( const std::string& file ); std::string getMapsDir(); diff --git a/source/client/server.cpp b/source/client/server.cpp index f9238b8..5c07804 100644 --- a/source/client/server.cpp +++ b/source/client/server.cpp @@ -68,7 +68,7 @@ int runServer(int argc, char* argv[]) CTTRTSGame game = GetGameFromFile("Tiny2Player.txt"); std::vector players = game.GetPlayers(); - unsigned int numClients = game.GetPlayers().size(); + unsigned int numClients = players.size(); auto player_iterator = players.begin(); // game mutex @@ -103,10 +103,7 @@ int runServer(int argc, char* argv[]) clientInfo.player = *player_iterator; player_iterator++; - - // Could verify if player is valid here - - myClients.push_back({cli_addr,clientsockfd}); + myClients.push_back(clientInfo); } // Perform the initial handshake with clients