- char buffer[1024], buf[1024];
- int connected = 1;
- char *cmd, *source = NULL;
- srand(time(NULL));
-
-
- load_config_file(); // default = gameserv.conf
-
- ignore_pipe();
- sock = make_connection(remoteport, SOCK_STREAM, remoteserver);
- if (sock == -1) {
- fprintf(stderr,"make_connection failed.\n");
+ char buffer[1024], buf[1024];
+ memset(buffer, 0, 1024);
+ memset(buf, 0, 1024);
+ int connected;
+ long lastidlecheck;
+ char *cmd, *source = NULL, *conf;
+ srand(time(NULL));
+ conf = new char[16];
+ strcpy(conf, "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;
+ }
+ delete []conf;
+ conf = argv[1];
+ }
+
+ prettyIntro();
+
+ if (load_config_file(conf))
+ {
+ cout << "Config file loaded ok...\n"
+ << "Turning into a daemon" << endl;
+ }
+ else
+ exit(2);
+
+ if (argc <= 1)
+ delete []conf;
+
+ // Turn into a daemon
+ if (daemon(1,0) < 0)
+ {
+ perror("Could not turn into a daemon");
+ exit(3);
+ }
+ init_masters();
+ load_gs_dbase();
+
+ if (load_monsters() == false)
+ goto end;
+
+ shuttingdown = false;
+
+ char ignoreservers[32][256];
+ char *currentserver;
+ currentserver = strtok(ignoreserverslist, " ");
+ for (int server = 0; server < 32 && currentserver != NULL; server++)
+ {
+ strncpy(ignoreservers[server], currentserver, 255);
+ log("Placing %s on the server ignore list", currentserver);
+ currentserver = strtok(NULL, " ");
+ }
+
+ strcpy(boss.name, "Red Dragon");
+ strcpy(boss.weapon, "Breath of Unholy Fire");
+ boss.strength = 1000;
+ boss.gold = 2000000000;
+ boss.exp = 2000000000;
+ boss.maxhp = 6667;
+ boss.hp = 6667;
+ 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!");
+
+
+ // This loop will retry the connection 3 times
+ for (int retry = 0; retry < 3 && !shuttingdown; retry++)
+ {
+ connected = 1;
+ load_day();
+
+
+ long int loadtime = time(NULL);
+ long int currentTime;
+ long int oldTime = loadtime;
+
+ lastidlecheck = loadtime;
+
+ #ifdef DEBUGMODE
+ log("Setting primary Idle Check timestamp: %ld", lastidlecheck);
+ #endif
+ bool loaded = false;
+
+ ignore_pipe();
+ sock = make_connection(remoteport, SOCK_STREAM, remoteserver);
+ if (sock == -1) {
+ fprintf(stderr,"make_connection failed.\n");