]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/tcpclient.cpp
Fixed some bugs
[irc/gameservirc.git] / gameserv / tcpclient.cpp
index fa50bcbf27e6f5b2b69c67084c0763a99dbc1a1b..69d5dd768fa523e884102b4bac66595a7c772843 100644 (file)
@@ -36,7 +36,7 @@ using std::cerr;
 using std::endl;
 
 char *PACKAGE = "GameServ";
-char *VERSION = "1.1.8";
+char *VERSION = "1.2.0 +devel";
 
 int sock;
 int day;
@@ -45,6 +45,7 @@ List<aClient> clients;
 
 void save_day();
 void load_day();
+void prettyIntro();
 
 // Make this a daemon
 int daemon(int nochdir, int noclose);
@@ -52,15 +53,40 @@ 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));
-  
 
-  load_config_file();          // default = gameserv.conf
+  /*
+   * This needs to be fixed to work for any number of arguments in any
+   * order
+   *
+   */
+  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();
+
+  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)
@@ -125,6 +151,15 @@ int main()
       log("Server: %s",buffer);
   #endif
 
+  strcpy(boss.name, "Red Dragon");
+  strcpy(boss.weapon, "Breath of Unholy Fire");
+  boss.strength = 6667;
+  boss.gold = 2000000000;
+  boss.exp = 2000000000;
+  strcpy(boss.death, "You finally snuff out the deadly murderous "\
+    "dragon's dark flames. You have freed the land of its terror "\
+    "filled reign from above!");
+
   init_masters();
   load_gs_dbase();
   load_day();
@@ -273,7 +308,23 @@ int main()
                clients.remove(quitter);
            if ((quitter = findIRCplayer(source)))
            {
+               if (player_fight(quitter))
+               {
+                   // Stop the fight on the other client
+                   aClient *otherplayer = quitter->stats->battle;
+                   otherplayer->stats->battle = NULL;
+                   notice(s_GameServ, otherplayer->getNick(), "%s "\
+                          "has quit IRC. The fight stops here.",
+                          quitter->stats->name);
+               }
+               quitter->stats->battle = NULL;
+               quitter->stats->fight = NULL;
+               quitter->stats->master = NULL;
+
                quitter->setNick("!NULL!");
+               #ifdef P10
+                   quitter->setRealNick("!NULL!");
+               #endif
                quitter->stats->user = NULL; // Unidentify them
            }
 
@@ -310,11 +361,39 @@ int main()
            else if (stricmp(dest, c_Forest) == 0)
                forest(source, rest);
       #endif
+      #if defined(P10)
+       } else if (stricmp(cmd, "J") == 0) {
+      #else
        } else if (stricmp(cmd, "JOIN") == 0) {
+      #endif
            char *channel;
+           aClient *joiner;
            channel = strtok(NULL, " ");
-           if (stricmp(channel, c_Forest) == 0 && is_playing(source + 1))
-               raw(":%S MODE %s +v %s", c_Forest, (source + 1));
+
+            char z = source[0];
+
+            if (z == ':')
+                source++;
+
+           joiner = find(source);
+
+           if (stricmp(channel, c_Forest) == 0 && is_playing(joiner))
+           {
+               #ifdef DEBUGMODE
+                   log("Player %s (IRC: %s) joined %s", 
+                       joiner->stats->name, 
+                       #ifdef P10
+                           joiner->getRealNick(),
+                       #else
+                           joiner->getNick(),
+                       #endif
+                       c_Forest);
+               #endif
+               raw(":%S MODE %s +v %s", c_Forest, (source));
+           }
+
+           if (z == ':')
+               source--;
 
        #if defined(BAHAMUT)
        } else if (stricmp(cmd, "SJOIN") == 0) {
@@ -561,9 +640,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();
 
@@ -594,4 +673,14 @@ void closeall(int fd)
       close(fd++);
 }
 
-
+void prettyIntro()
+{
+cout << endl;
+cout << "  GGGG     AAA   MM    MM EEEEEEE  SSSSS  EEEEEEE RRRRRR  VV     VV " << endl;
+cout << " GG  GG   AAAAA  MMM  MMM EE      SS      EE      RR   RR VV     VV " << endl;
+cout << "GG       AA   AA MM MM MM EEEEE    SSSSS  EEEEE   RRRRRR   VV   VV  " << endl;
+cout << "GG   GGG AAAAAAA MM    MM EE           SS EE      RR  RR    VV VV   " << endl;
+cout << "G     G  AA   AA MM    MM EEEEEEE  SSSSS  EEEEEEE RR   RR    VVV" << endl;
+cout << " GGGGG                                                        V\n\n" << endl;
+cout << "Version: " << VERSION << endl;
+}