Ejemplo n.º 1
0
JNIEXPORT void JNICALL Java_net_hackcasual_freeciv_NativeHarness_startServer
  (JNIEnv *je, jobject o) {

	LOGI("Fake server start");

	FILE *fp;
	  if((fp=freopen("/data/data/net.hackcasual.freeciv/freeciv_out.log", "w" ,stdout))==NULL) {
	    printf("Cannot open file.\n");
	    exit(1);
	  }

	  if((fp=freopen("/data/data/net.hackcasual.freeciv/freeciv_err.log", "w" ,stderr))==NULL) {
	    printf("Cannot open file.\n");
	    exit(1);
	  }

	  setenv ("HOME", "/data/data/net.hackcasual.freeciv/Freeciv", 0);



	srv_init();

	  srvarg.log_filename="/data/data/net.hackcasual.freeciv/log.out";
	  srvarg.loglevel=LOG_DEBUG;


	init_our_capability();
	srv_main();
    /* test */
	return;
}
Ejemplo 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;
}