From 0619031cb6da27a4ee04243acfcb769c5904b50d Mon Sep 17 00:00:00 2001 From: mdiluzio Date: Fri, 2 Jan 2015 15:06:04 +0000 Subject: [PATCH] Use argc and argv passed down --- source/client/client.cpp | 2 +- source/client/client.h | 2 +- source/client/filesystem.cpp | 4 ++-- source/client/filesystem.h | 4 ++-- source/client/main.cpp | 12 ++++-------- source/client/server.cpp | 4 ++-- source/client/server.h | 2 +- 7 files changed, 13 insertions(+), 17 deletions(-) diff --git a/source/client/client.cpp b/source/client/client.cpp index 8a59232..fdfeeb1 100644 --- a/source/client/client.cpp +++ b/source/client/client.cpp @@ -1,7 +1,7 @@ #include "client.h" -int runClient( const std::string& host_address ) +int runClient(int argc, char* argv[]) { return 0; } \ No newline at end of file diff --git a/source/client/client.h b/source/client/client.h index bd30a06..ab1e336 100644 --- a/source/client/client.h +++ b/source/client/client.h @@ -3,6 +3,6 @@ #include -int runClient( const std::string& host_address ); +int runClient(int argc, char* argv[]); #endif \ No newline at end of file diff --git a/source/client/filesystem.cpp b/source/client/filesystem.cpp index a2abd1f..6bd7111 100644 --- a/source/client/filesystem.cpp +++ b/source/client/filesystem.cpp @@ -80,9 +80,9 @@ std::string getGamesDir() } // ===================================================================================================================== -int runFromFilesystem( const std::string& gamestring ) +int runFromFilesystem(int argc, char* argv[]) { - std::string gamefile = gamestring; + std::string gamefile = argv[1]; // Default for maps std::string ttrts_maps_dir = getMapsDir(); diff --git a/source/client/filesystem.h b/source/client/filesystem.h index 4204ef9..d6a2ff9 100644 --- a/source/client/filesystem.h +++ b/source/client/filesystem.h @@ -13,11 +13,11 @@ bool FileExists( const std::string& name ); void WaitForFile( const std::string& name, const std::chrono::milliseconds& time ); -int runFromFilesystem( const std::string& gamefile ); - bool OutputGameStateFile(CTTRTSGame &game, const std::string &gameDir); std::string getMapsDir(); std::string getGamesDir(); +int runFromFilesystem(int argc, char* argv[]); + #endif \ No newline at end of file diff --git a/source/client/main.cpp b/source/client/main.cpp index 0d78823..218cab5 100644 --- a/source/client/main.cpp +++ b/source/client/main.cpp @@ -22,16 +22,12 @@ int main(int argc, char* argv[]) // Attempt to open the game file std::string arg1 = argv[1]; + // Either run the client, the server, or from local filesystem if( arg1 == "client" ) - { - if( argc == 3 ) - return runClient(argv[2]); - } + return runClient(argc,argv+1); else if ( arg1 == "server" ) - { - return runServer(); - } + return runServer(argc,argv+1); else - return runFromFilesystem(arg1); + return runFromFilesystem(argc,argv); }; diff --git a/source/client/server.cpp b/source/client/server.cpp index 1e62b61..be07929 100644 --- a/source/client/server.cpp +++ b/source/client/server.cpp @@ -1,6 +1,6 @@ #include "server.h" -int runServer() +int runServer(int argc, char* argv[]) { - + return 0; } \ No newline at end of file diff --git a/source/client/server.h b/source/client/server.h index 4f3af0e..54452c7 100644 --- a/source/client/server.h +++ b/source/client/server.h @@ -1,6 +1,6 @@ #ifndef _TTRTS_SERVER_H_ #define _TTRTS_SERVER_H_ -int runServer(); +int runServer(int argc, char* argv[]); #endif \ No newline at end of file