]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/tcpclient.cpp
Started to add the end monster stuff
[irc/gameservirc.git] / gameserv / tcpclient.cpp
index 31172b464abe68253805a28bb2c58c74f3fdb82b..7e28b16532f96a233bb7e93ac246f1b9df818607 100644 (file)
@@ -36,7 +36,7 @@ using std::cerr;
 using std::endl;
 
 char *PACKAGE = "GameServ";
-char *VERSION = "1.1.8";
+char *VERSION = "1.1.9";
 
 int sock;
 int day;
@@ -53,15 +53,35 @@ int daemon(int nochdir, int noclose);
 // Close all file descriptors from >= fd
 void closeall(int fd);
 
-int main()
+int main(int argc, char *argv[])
 {
   char buffer[1024], buf[1024];
   int connected = 1;
-  char *cmd, *source = NULL;
+  char *cmd, *source = NULL, *conf = "gameserv.conf";
   srand(time(NULL));
-  
+
+  if (argc > 1)
+  {
+       if ( argc > 2 || stricmp(argv[1], "--help") == 0)
+       {
+           cout << "Usage: gameserv [options] [configfile]" << endl;
+           cout << "Options:" << endl;
+           cout << "--help                        Displays this help dialogue" << endl;
+           return 1;
+       }
+       conf = new char[strlen(argv[1])];
+       strcpy(conf, argv[1]);
+  }
+
   prettyIntro();
-  load_config_file();          // default = gameserv.conf
+
+  if (load_config_file(conf))
+  {
+       cout << "Config file loaded ok...\n"
+             << "Turning into a daemon" << endl;
+  }
+  else
+       exit(2);
 
     // Turn into a daemon
     if (daemon(1,0) < 0)
@@ -562,9 +582,9 @@ int daemon(int nochdir, int noclose)
         case -1: return -1;
         default: 
                ofstream outfile;
-               outfile.open("gameserv.pid");
+               outfile.open(pidfile);
                if (outfile.fail())
-                   cerr << "Unable to open gameserv.pid" << endl;
+                   cerr << "Unable to open " << pidfile << endl;
                outfile << pid << endl;
                outfile.close();