Use argc and argv passed down

This commit is contained in:
mdiluzio 2015-01-02 15:06:04 +00:00
parent 2281bcb6cd
commit 0619031cb6
7 changed files with 13 additions and 17 deletions

View file

@ -1,7 +1,7 @@
#include "client.h" #include "client.h"
int runClient( const std::string& host_address ) int runClient(int argc, char* argv[])
{ {
return 0; return 0;
} }

View file

@ -3,6 +3,6 @@
#include <string> #include <string>
int runClient( const std::string& host_address ); int runClient(int argc, char* argv[]);
#endif #endif

View file

@ -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 // Default for maps
std::string ttrts_maps_dir = getMapsDir(); std::string ttrts_maps_dir = getMapsDir();

View file

@ -13,11 +13,11 @@ bool FileExists( const std::string& name );
void WaitForFile( const std::string& name, const std::chrono::milliseconds& time ); 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); bool OutputGameStateFile(CTTRTSGame &game, const std::string &gameDir);
std::string getMapsDir(); std::string getMapsDir();
std::string getGamesDir(); std::string getGamesDir();
int runFromFilesystem(int argc, char* argv[]);
#endif #endif

View file

@ -22,16 +22,12 @@ int main(int argc, char* argv[])
// Attempt to open the game file // Attempt to open the game file
std::string arg1 = argv[1]; std::string arg1 = argv[1];
// Either run the client, the server, or from local filesystem
if( arg1 == "client" ) if( arg1 == "client" )
{ return runClient(argc,argv+1);
if( argc == 3 )
return runClient(argv[2]);
}
else if ( arg1 == "server" ) else if ( arg1 == "server" )
{ return runServer(argc,argv+1);
return runServer();
}
else else
return runFromFilesystem(arg1); return runFromFilesystem(argc,argv);
}; };

View file

@ -1,6 +1,6 @@
#include "server.h" #include "server.h"
int runServer() int runServer(int argc, char* argv[])
{ {
return 0;
} }

View file

@ -1,6 +1,6 @@
#ifndef _TTRTS_SERVER_H_ #ifndef _TTRTS_SERVER_H_
#define _TTRTS_SERVER_H_ #define _TTRTS_SERVER_H_
int runServer(); int runServer(int argc, char* argv[]);
#endif #endif