Esempio n. 1
0
/**************************************************************************
  Entry point of the freeciv-modpack program
**************************************************************************/
int main(int argc, char *argv[])
{
  GtkWidget *toplevel;
  int loglevel = LOG_NORMAL;
  int ui_options;

  init_nls();
  init_character_encodings(FC_DEFAULT_DATA_ENCODING, FALSE);

  fc_init_network();
  
  g_thread_init(NULL);

  log_init(NULL, loglevel, NULL, NULL, -1);

  /* This modifies argv! */
  ui_options = fcmp_parse_cmdline(argc, argv);

  if (ui_options != -1) {

    /* Process GTK arguments */
    gtk_init(&ui_options, &argv);

    toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    gtk_widget_realize(toplevel);
    gtk_widget_set_name(toplevel, "Freeciv-modpack");
    gtk_window_set_title(GTK_WINDOW(toplevel), _("Freeciv modpack installer"));

    /* Keep the icon of the executable on Windows */
#ifndef WIN32_NATIVE
    {
      /* Unlike main client, this only works if installed. Ignore any
       * errors loading the icon. */
      GError *err;
      (void) gtk_window_set_icon_from_file(GTK_WINDOW(toplevel), MPICON_PATH,
                                           &err);
    }
#endif /* WIN32_NATIVE */

    g_signal_connect(toplevel, "delete_event",
                     G_CALLBACK(quit_dialog_callback), NULL);

    modinst_setup_widgets(toplevel);

    gtk_widget_show_all(toplevel);

    gtk_main();
  }

  return EXIT_SUCCESS;
}
Esempio n. 2
0
void startClient() {
	char *logfile = "/sdcard/client.out";
	FILE *fp;
	  if((fp=freopen("/sdcard/freeciv_out_client.log", "w" ,stdout))==NULL) {
	    printf("Cannot open file.\n");
	    exit(1);
	  }

	  if((fp=freopen("/sdcard/freeciv_err_client.log", "w" ,stderr))==NULL) {
	    printf("Cannot open file.\n");
	    exit(1);
	  }

	  setenv ("HOME", "/sdcard/FreeCiv", 0);
	  setenv ("USER", "Sparky", 0);

	LOGI("Hello JNI");
	  log_init(logfile, LOG_DEBUG
			  , NULL);
	int i, loglevel;
	int ui_options = 0;
	bool ui_separator = FALSE;
	char *option=NULL;
	bool user_tileset = FALSE;

	  i_am_client(); /* Tell to libfreeciv that we are client */

	  /* Ensure that all AIs are initialized to unused state */
	  ai_type_iterate(ai) {
	    init_ai(ai);
	  } ai_type_iterate_end;




	init_our_capability();


	  (void)user_username(default_user_name, MAX_LEN_NAME);
	  if (!is_valid_username(default_user_name)) {
	    char buf[sizeof(default_user_name)];

	    my_snprintf(buf, sizeof(buf), "_%s", default_user_name);
	    if (is_valid_username(buf)) {
	      sz_strlcpy(default_user_name, buf);
	    } else {
	      my_snprintf(default_user_name, sizeof(default_user_name),
			  "player%d", myrand(10000));
	    }
	  }

	  game.all_connections = conn_list_new();
	  game.est_connections = conn_list_new();

	  ui_init();

	  fc_init_network();

	  init_our_capability();
	  chatline_common_init();
	  init_player_dlg_common();
	  init_themes();

	  options_init();

	  strcpy(default_sound_plugin_name,"none");

	  server_port = 9999;
	  sz_strlcpy(server_host, "localhost");
	  options_load();

	  mysrand(time(NULL));
	  helpdata_init();
	  boot_help_texts(NULL);




	  LOGI("Reading tilespec");
	  tilespec_try_read("amplio2", TRUE);
	  LOGI("Done reading tilespec");
	  overview_size_changed();

	  audio_real_init("stdsounds", "none");
	  //audio_play_music("music_start", NULL);

	  auto_connect = TRUE;

	  init_mapcanvas_and_overview();

	  /* run gui-specific client */
	  ui_main(0, NULL);

	  /* termination */
	  client_exit();

	return;
}