Пример #1
0
int main(int argc, char *argv[])
{
  FILE *fp;

#if USING_DMALLOC
  dmalloc_debug(1);
#endif

	/* start the clock (which is used by the Logit fnc) */
  (void) refetch_ticker();
  GetArgs(argc, argv);
  if (conf_file_read(confname)) {
    Logit("Failed to read config file \"%s\"", confname);
    strcpy(confname, "./nngs.cnf");
    conf_file_write(confname);
    Logit("Created \"%s\"", confname);
  }
  Logit("Starting %s (%s %s) From: %s"
  , conffile.version_string, conffile.compile_date, conffile.compile_time, confname);
  if (daemonise()) {
    Logit("Failed to daemonise, giving up");
    main_exit(1);
  }
  conf_file_write("written.cnf");
  signal(SIGTERM, TerminateServer);
  signal(SIGINT, TerminateServer);
#if 0
  signal(SIGPIPE, SIG_IGN);
#else
  signal(SIGPIPE, BrokenPipe);
#endif
  signal(SIGCHLD, reapchild);
  mink_init();
  startuptime = time(NULL);
  srand(startuptime);
  read_ban_ip_list();
  if (!all_the_internets() ) {
    fprintf(stderr, "Network initialize failed on ports %s.\n"
    , conffile.server_ports);
    main_exit(1);
  }
  player_high = 0;
  game_high = 0;
  bytes_sent = 0;
  bytes_received = 0;

#ifdef SGI
  /*mallopt(100, 1);*/  /* Turn on malloc(3X) debugging (Irix only) */
#endif
  command_init();
  EmoteInit(conffile.emotes_file);
  help_init();
  /*Logit("commands_init()");*/
  commands_init();
  /*Logit("channel_init()");*/
  channel_init();
  /*Logit("player_array_init()");*/
  player_array_init();
  player_init();
  ladder_init(NUM_LADDERS);
  Ladder9 = ladder_new(LADDERSIZE);
  Ladder19 = ladder_new(LADDERSIZE);

  completed_games = 0;
  num_logins = num_logouts = new_players = 0;

  num_9 = 0;
  fp = xyfopen(FILENAME_LADDER9, "r");
  if (fp) {
    num_9 = ladder_load(fp, Ladder9);
    Logit("%d players loaded from file %s", num_9, filename() );
    fclose(fp);
  }

  num_19 = 0;
  fp = xyfopen(FILENAME_LADDER19, "r");
  if (fp) {
    num_19 = ladder_load(fp, Ladder19);
    Logit("%d players loaded from file %s", num_19, filename() );
    fclose(fp);
  }

  /* mink_init();*/
  if (conffile.admin_name) create_admin_account(conffile.admin_name );
  Logit("Server up and running.");
  main_event_loop();
  Logit("Closing down.");
  net_closeAll();
  main_exit(0);
  return 0;
}
Пример #2
0
	Emote::Emote(IntPtr dxHandle) {
		LoadEmoteEngine();
		EmoteInit(dxHandle);
	}