Exemplo n.º 1
0
void append_zero(const unsigned char * buf)
{
  load_all(buf, "");
  load_int(0, true, sizeof(char), "");
  // load_str("00");
  Append();
  store_all(buf);
}
Exemplo n.º 2
0
void initialize_projectile()
{
	PROJECTILES = make_list();

	PROJECTILE_PROTOTYPES = make_hash_map();

	__api_projectile_tag = scm_make_smob_type("projectile", sizeof(projectile));
	scm_c_define_gsubr("build-projectile-prototype", 6, 0, 0, __api_build_projectile_prototype);
	scm_c_define_gsubr("make-projectile", 5, 0, 0, __api_make_projectile);
	scm_c_define_gsubr("spawn-projectile", 1, 0, 0, __api_spawn_projectile);

	load_all("script/projectiles");
}
Exemplo n.º 3
0
void load_data(const char* datafile) {
	if(str_ends_with(datafile, "descriptors.txt")) load_all(datafile);
	else X.load(datafile);
	if(LIMIT_NDATA!=-1 && X.height > LIMIT_NDATA) X.height = LIMIT_NDATA;
	n = X.height;
	D = X.width;

	distribute_data();


	DBGV(LIMIT_NDATA);
	DBGV(N);
	DBGV(D);
	DBGV(n);
}
Exemplo n.º 4
0
void *PluginManagerPrivate::processEvent(Event *e)
{
    CmdParam *p;
#ifndef WIN32
    ExecParam *exec;
#endif
    switch (e->type()){
    case EventArg:
        p = (CmdParam*)(e->param());
        return (void*)findParam(p->arg, p->descr, p->value);
    case EventPluginGetInfo:
        return getInfo((unsigned)(e->param()));
    case EventApplyPlugin:
        return (void*)setInfo((const char*)(e->param()));
    case EventPluginsUnload:
        release_all((Plugin*)(e->param()));
        return e->param();
    case EventPluginsLoad:
        load_all((Plugin*)(e->param()));
        return e->param();
    case EventUnloadPlugin:
        release((const char*)(e->param()));
        return e->param();
    case EventLoadPlugin:
        load((const char*)(e->param()));
        return e->param();
    case EventSaveState:
        saveState();
        break;
    case EventGetPluginInfo:
        return getInfo((const char*)(e->param()));
    case EventArgc:
        return (void*)(m_argc);
    case EventArgv:
        return (void*)(m_argv);
#ifndef WIN32
    case EventExec:
        exec = (ExecParam*)(e->param());
        execute(exec->cmd, exec->arg);
        return e->param();
#endif
    default:
        break;
    }
    return NULL;
}
const std::map<std::string, firearm_properties> & firearm::properties() {
	load_all(all_firearm_properties);
	return all_firearm_properties;
}
Exemplo n.º 6
0
void getKeyboardPress(unsigned char key, int x, int y)
{
	switch (key)
	{
	case 27:
		exit(0);
	case 'w':
		walk_up();
		break;
	case 's':
		walk_down();
		break;
	case 'a':
		//cout << "a";
		walk_left();
		break;
	case 'd':
		walk_right();
		break;
	case 'q':
		turn_left();
		break;
	case 'e':
		turn_right();
		break;
	case 'f':
		if ((CreatFlower == false) && (CreatTree == false))
		{
			Flower* tem = new Flower;
			int temx, temy, temz;
			get_Groung_position(mouse_x, mouse_y, temx, temy, temz);
			tem->setPosition(temx, temz);
			tem->setAlpha(0.35f);
			flower_display_list.push_back(tem);
			CreatFlower = true;
		}
		coutstat();
		break;
	case 't':
		if ((CreatFlower == false) && (CreatTree == false))
		{
			Tree* tem = new Tree;
			int temx, temy, temz;
			get_Groung_position(mouse_x, mouse_y, temx, temy, temz);
			tem->setPosition(temx, temz);
			tree_display_list.push_back(tem);
			CreatTree = true;
		}
		coutstat();
		break;
	case 'z':
		save_all();
		break;
	case 'l':
		load_all();
		break;
	case 'r':
		if (CreatFlower == true)
		{
			flower_display_list[flower_display_list.size() - 1]->change_petal_R(0.1f);
		}
		coutstat();
		break;
	case 'g':
		if (CreatFlower == true)
		{
			flower_display_list[flower_display_list.size() - 1]->change_petal_G(0.1f);
		}
		coutstat();
		break;

	case 'b':
		if (CreatFlower == true)
		{
			flower_display_list[flower_display_list.size() - 1]->change_petal_B(0.1f);
		}
		coutstat();
		break;

	case 'n':
		if (CreatFlower == true)
		{
			flower_display_list[flower_display_list.size() - 1]->change_petal_NUM(1);
		}
		if (CreatTree == true)
		{
			tree_display_list[tree_display_list.size() - 1]->change_tree_level(1);
		}
		coutstat();
		break;

	case 'm':
		if (CreatFlower == true)
		{
			flower_display_list[flower_display_list.size() - 1]->change_petal_NUM(-1);
		}
		if (CreatTree == true)
		{
			tree_display_list[tree_display_list.size() - 1]->change_tree_level(-1);
		}
		coutstat();
		break;

	case 'p':
		is_snow = 1 - is_snow;
		snowcount = 0;
		coutstat();
		break;

	case 'o':
		if (have_wind) stop_wind();
		else start_wind();
		coutstat();
		break;

	case 'i':
		snow_down();
		break;

	case 'j':
		change_snow_level(-5);
		coutstat();
		break;

	case 'k':
		change_snow_level(5);
		coutstat();
		break;
	}

	

}
Exemplo n.º 7
0
int cmd_pack_redundant(int argc, const char **argv, const char *prefix)
{
	int i;
	struct pack_list *min, *red, *pl;
	struct llist *ignore;
	struct object_id *oid;
	char buf[GIT_MAX_HEXSZ + 2]; /* hex hash + \n + \0 */

	if (argc == 2 && !strcmp(argv[1], "-h"))
		usage(pack_redundant_usage);

	for (i = 1; i < argc; i++) {
		const char *arg = argv[i];
		if (!strcmp(arg, "--")) {
			i++;
			break;
		}
		if (!strcmp(arg, "--all")) {
			load_all_packs = 1;
			continue;
		}
		if (!strcmp(arg, "--verbose")) {
			verbose = 1;
			continue;
		}
		if (!strcmp(arg, "--alt-odb")) {
			alt_odb = 1;
			continue;
		}
		if (*arg == '-')
			usage(pack_redundant_usage);
		else
			break;
	}

	if (load_all_packs)
		load_all();
	else
		while (*(argv + i) != NULL)
			add_pack_file(*(argv + i++));

	if (local_packs == NULL)
		die("Zero packs found!");

	load_all_objects();

	cmp_local_packs();
	if (alt_odb)
		scan_alt_odb_packs();

	/* ignore objects given on stdin */
	llist_init(&ignore);
	if (!isatty(0)) {
		while (fgets(buf, sizeof(buf), stdin)) {
			oid = xmalloc(sizeof(*oid));
			if (get_oid_hex(buf, oid))
				die("Bad object ID on stdin: %s", buf);
			llist_insert_sorted_unique(ignore, oid, NULL);
		}
	}
	llist_sorted_difference_inplace(all_objects, ignore);
	pl = local_packs;
	while (pl) {
		llist_sorted_difference_inplace(pl->unique_objects, ignore);
		pl = pl->next;
	}

	minimize(&min);

	if (verbose) {
		fprintf(stderr, "There are %lu packs available in alt-odbs.\n",
			(unsigned long)pack_list_size(altodb_packs));
		fprintf(stderr, "The smallest (bytewise) set of packs is:\n");
		pl = min;
		while (pl) {
			fprintf(stderr, "\t%s\n", pl->pack->pack_name);
			pl = pl->next;
		}
		fprintf(stderr, "containing %lu duplicate objects "
				"with a total size of %lukb.\n",
			(unsigned long)get_pack_redundancy(min),
			(unsigned long)pack_set_bytecount(min)/1024);
		fprintf(stderr, "A total of %lu unique objects were considered.\n",
			(unsigned long)all_objects->size);
		fprintf(stderr, "Redundant packs (with indexes):\n");
	}
	pl = red = pack_list_difference(local_packs, min);
	while (pl) {
		printf("%s\n%s\n",
		       sha1_pack_index_name(pl->pack->sha1),
		       pl->pack->pack_name);
		pl = pl->next;
	}
	if (verbose)
		fprintf(stderr, "%luMB of redundant packs in total.\n",
			(unsigned long)pack_set_bytecount(red)/(1024*1024));

	return 0;
}
Exemplo n.º 8
0
void
GncSqlBackend::load (QofBook* book, QofBackendLoadType loadType)
{
    Account* root;

    g_return_if_fail (book != NULL);

    ENTER ("sql_be=%p, book=%p", this, book);

    m_loading = TRUE;

    if (loadType == LOAD_TYPE_INITIAL_LOAD)
    {
        assert (m_book == nullptr);
        m_book = book;

        /* Load any initial stuff. Some of this needs to happen in a certain order */
        for (auto type : fixed_load_order)
        {
            auto obe = m_backend_registry.get_object_backend(type);
            if (obe)
            {
                update_progress();
                obe->load_all(this);
            }
        }
        for (auto type : business_fixed_load_order)
        {
            auto obe = m_backend_registry.get_object_backend(type);
            if (obe)
            {
                update_progress();
                obe->load_all(this);
            }
        }

        root = gnc_book_get_root_account( book );
        gnc_account_foreach_descendant(root, (AccountCb)xaccAccountBeginEdit,
                                       nullptr);

        m_backend_registry.load_remaining(this);

        gnc_account_foreach_descendant(root, (AccountCb)xaccAccountCommitEdit,
                                       nullptr);
    }
    else if (loadType == LOAD_TYPE_LOAD_ALL)
    {
        // Load all transactions
        auto obe = m_backend_registry.get_object_backend (GNC_ID_TRANS);
        obe->load_all (this);
    }

    m_loading = FALSE;
    std::for_each(m_postload_commodities.begin(), m_postload_commodities.end(),
                 [](gnc_commodity* comm) {
                      gnc_commodity_begin_edit(comm);
                      gnc_commodity_commit_edit(comm);
                  });
    m_postload_commodities.empty();

    /* Mark the sessoion as clean -- though it should never be marked
     * dirty with this backend
     */
    qof_book_mark_session_saved (book);
    finish_progress();

    LEAVE ("");
}
Exemplo n.º 9
0
/**
 * @brief The entry point of Naev.
 *
 *    @param[in] argc Number of arguments.
 *    @param[in] argv Array of argc arguments.
 *    @return EXIT_SUCCESS on success.
 */
int main( int argc, char** argv )
{
   char buf[PATH_MAX];

   /* Save the binary path. */
   binary_path = strdup(argv[0]);

   /* Print the version */
   LOG( " "APPNAME" v%s", naev_version(0) );
#ifdef GIT_COMMIT
   DEBUG( " git HEAD at " GIT_COMMIT );
#endif /* GIT_COMMIT */

   /* Initializes SDL for possible warnings. */
   SDL_Init(0);

   /* Initialize the threadpool */
   threadpool_init();

   /* Set up debug signal handlers. */
   debug_sigInit();

   /* Must be initialized before input_init is called. */
   if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
      WARN("Unable to initialize SDL Video: %s", SDL_GetError());
      return -1;
   }

   /* Get desktop dimensions. */
#if SDL_VERSION_ATLEAST(1,2,10)
   const SDL_VideoInfo *vidinfo = SDL_GetVideoInfo();
   gl_screen.desktop_w = vidinfo->current_w;
   gl_screen.desktop_h = vidinfo->current_h;
#else /* #elif SDL_VERSION_ATLEAST(1,2,10) */
   gl_screen.desktop_w = 0;
   gl_screen.desktop_h = 0;
#endif /* #elif SDL_VERSION_ATLEAST(1,2,10) */

   /* We'll be parsing XML. */
   LIBXML_TEST_VERSION
   xmlInitParser();

   /* Input must be initialized for config to work. */
   input_init();

   conf_setDefaults(); /* set the default config values */

   /*
    * Attempts to load the data path from datapath.lua
    * At this early point in the load process, the binary path
    * is the only place likely to be checked.
    */
   conf_loadConfigPath();

   /* Parse the user data path override first. */
   conf_parseCLIPath( argc, argv );

   /* Create the home directory if needed. */
   if (nfile_dirMakeExist("%s", nfile_configPath()))
      WARN("Unable to create config directory '%s'", nfile_configPath());

   /* Set the configuration. */
   nsnprintf(buf, PATH_MAX, "%s"CONF_FILE, nfile_configPath());

#if HAS_UNIX
   /* TODO get rid of this cruft ASAP. */
   int oldconfig = 0;
   if (!nfile_fileExists( buf )) {
      char *home, buf2[PATH_MAX];
      home = SDL_getenv( "HOME" );
      if (home != NULL) {
         nsnprintf( buf2, PATH_MAX, "%s/.naev/"CONF_FILE, home );
         if (nfile_fileExists( buf2 ))
            oldconfig = 1;
      }
   }
#endif /* HAS_UNIX */

   conf_loadConfig(buf); /* Lua to parse the configuration file */
   conf_parseCLI( argc, argv ); /* parse CLI arguments */

   /* Enable FPU exceptions. */
#if defined(HAVE_FEENABLEEXCEPT) && defined(DEBUGGING)
   if (conf.fpu_except)
      feenableexcept( FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW );
#endif /* defined(HAVE_FEENABLEEXCEPT) && defined(DEBUGGING) */

   /* Open data. */
   if (ndata_open() != 0)
      ERR("Failed to open ndata.");

   /* Load the start info. */
   if (start_load())
      ERR("Failed to load module start data.");

   /* Load the data basics. */
   LOG(" %s", ndata_name());
   DEBUG();

   /* Display the SDL Version. */
   print_SDLversion();
   DEBUG();

   /* random numbers */
   rng_init();

   /*
    * OpenGL
    */
   if (gl_init()) { /* initializes video output */
      ERR("Initializing video output failed, exiting...");
      SDL_Quit();
      exit(EXIT_FAILURE);
   }
   window_caption();
   gl_fontInit( NULL, NULL, conf.font_size_def ); /* initializes default font to size */
   gl_fontInit( &gl_smallFont, NULL, conf.font_size_small ); /* small font */

   /* Display the load screen. */
   loadscreen_load();
   loadscreen_render( 0., "Initializing subsystems..." );
   time_ms = SDL_GetTicks();


   /*
    * Input
    */
   if ((conf.joystick_ind >= 0) || (conf.joystick_nam != NULL)) {
      if (joystick_init()) WARN("Error initializing joystick input");
      if (conf.joystick_nam != NULL) { /* use the joystick name to find a joystick */
         if (joystick_use(joystick_get(conf.joystick_nam))) {
            WARN("Failure to open any joystick, falling back to default keybinds");
            input_setDefault();
         }
         free(conf.joystick_nam);
      }
      else if (conf.joystick_ind >= 0) /* use a joystick id instead */
         if (joystick_use(conf.joystick_ind)) {
            WARN("Failure to open any joystick, falling back to default keybinds");
            input_setDefault();
         }
   }


   /*
    * OpenAL - Sound
    */
   if (conf.nosound) {
      LOG("Sound is disabled!");
      sound_disabled = 1;
      music_disabled = 1;
   }
   if (sound_init()) WARN("Problem setting up sound!");
   music_choose("load");

   /* FPS stuff. */
   fps_setPos( 15., (double)(gl_screen.h-15-gl_defFont.h) );

   /* Misc graphics init */
   if (nebu_init() != 0) { /* Initializes the nebula */
      /* An error has happened */
      ERR("Unable to initialize the Nebula subsystem!");
      /* Weirdness will occur... */
   }
   gui_init(); /* initializes the GUI graphics */
   toolkit_init(); /* initializes the toolkit */
   map_init(); /* initializes the map. */
   cond_init(); /* Initialize conditional subsystem. */
   cli_init(); /* Initialize console. */

   /* Data loading */
   load_all();

   /* Generate the CSV. */
   if (conf.devcsv)
      dev_csv();

   /* Unload load screen. */
   loadscreen_unload();

   /* Start menu. */
   menu_main();

   /* Force a minimum delay with loading screen */
   if ((SDL_GetTicks() - time_ms) < NAEV_INIT_DELAY)
      SDL_Delay( NAEV_INIT_DELAY - (SDL_GetTicks() - time_ms) );
   fps_init(); /* initializes the time_ms */

#if HAS_UNIX
   /* Tell the player to migrate their configuration files out of ~/.naev */
   /* TODO get rid of this cruft ASAP. */
   if ((oldconfig) && (!conf.datapath)) {
      char path[PATH_MAX], *script, *home;
      uint32_t scriptsize;
      int ret;

      nsnprintf( path, PATH_MAX, "%s/naev-confupdate.sh", ndata_getDirname() );
      home = SDL_getenv("HOME");
      ret = dialogue_YesNo( "Warning", "Your configuration files are in a deprecated location and must be migrated:\n"
            "   \er%s/.naev/\e0\n\n"
            "The update script can likely be found in your Naev data directory:\n"
            "   \er%s\e0\n\n"
            "Would you like to run it automatically?", home, path );

      /* Try to run the script. */
      if (ret) {
         ret = -1;
         /* Running from ndata. */
         if (ndata_getPath() != NULL) {
            script = ndata_read( "naev-confupdate.sh", &scriptsize );
            if (script != NULL)
               ret = system(script);
         }

         /* Running from laid-out files or ndata_read failed. */
         if ((nfile_fileExists(path)) && (ret == -1)) {
            script = nfile_readFile( (int*)&scriptsize, path );
            if (script != NULL)
               ret = system(script);
         }

         /* We couldn't find the script. */
         if (ret == -1) {
            dialogue_alert( "The update script was not found at:\n\er%s\e0\n\n"
                  "Please locate and run it manually.", path );
         }
         /* Restart, as the script succeeded. */
         else if (!ret) {
            dialogue_msg( "Update Completed",
                  "Configuration files were successfully migrated. Naev will now restart." );
            execv(argv[0], argv);
         }
         else { /* I sincerely hope this else is never hit. */
            dialogue_alert( "The update script encountered an error. Please exit Naev and move your config and save files manually:\n\n"
                  "\er%s/%s\e0 =>\n   \eD%s\e0\n\n"
                  "\er%s/%s\e0 =>\n   \eD%s\e0\n\n"
                  "\er%s/%s\e0 =>\n   \eD%snebula/\e0\n\n",
                  home, ".naev/conf.lua", nfile_configPath(),
                  home, ".naev/{saves,screenshots}/", nfile_dataPath(),
                  home, ".naev/gen/*.png", nfile_cachePath() );
         }
      }
      else {
Exemplo n.º 10
0
int main(int argc, char** argv)
{
    bvgraph g = {0};
    //const char* name = "libbvg/data/wb-cs.stanford";
    const char* name = argv[1];
    char* method = argv[2];
    int rval = 0;

    if (method == NULL) {
        print_help();
        return 0;
    }

    //load with offsets
    rval = bvgraph_load(&g, name, strlen(name), 1);
    if (rval != 0) {
        printf("Failed to load file %s\n", name);
        return (-1);
    }

    printf("Input file: %s\n", name);
    printf("nodes = %"PRId64"\n", g.n);
    printf("edges = %"PRId64"\n", g.m);

    if (strcmp(method, "random") == 0){
        load_all(name);
        if (argv[3] == NULL){
            printf("Need node number. Stop\n");
            return 1;
        }
        int num = atoi(argv[3]);
        random_test(g, num);
    }
    else if (strcmp(method, "head-tail") == 0){
        load_all(name);
        head_tail_first_test(g);
    }
    else if (strcmp(method, "all") == 0){
        load_all(name);
        print_all(g);
    }
    else if (strcmp(method, "perform") == 0){
        // test performance
        if (argv[3] == NULL){
            printf("Need node number. Stop\n");
            return 1;
        }
        int num = atoi(argv[3]);
        test_performance(g, num);
    }
    else if (strcmp(method, "iter") == 0){
        iteration(name);
    }
    else{
        print_help();
    }

    bvgraph_close(&g);

    return 0;
}
Exemplo n.º 11
0
Arquivo: naev.c Projeto: ekrumme/naev
/**
 * @brief The entry point of NAEV.
 *
 *    @param[in] argc Number of arguments.
 *    @param[in] argv Array of argc arguments.
 *    @return EXIT_SUCCESS on success.
 */
int main( int argc, char** argv )
{
   char buf[PATH_MAX];

   /* Save the binary path. */
   binary_path = argv[0];
   
   /* Print the version */
   LOG( " "APPNAME" v%s", naev_version(0) );
#ifdef GIT_COMMIT
   DEBUG( " git HEAD at " GIT_COMMIT );
#endif /* GIT_COMMIT */

   /* Initializes SDL for possible warnings. */
   SDL_Init(0);

   /* Set up debug signal handlers. */
   debug_sigInit();

   /* Create the home directory if needed. */
   if (nfile_dirMakeExist("%s", nfile_basePath()))
      WARN("Unable to create naev directory '%s'", nfile_basePath());

   /* Must be initialized before input_init is called. */
   if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
      WARN("Unable to initialize SDL Video: %s", SDL_GetError());
      return -1;
   }

   /* Get desktop dimensions. */
#if SDL_VERSION_ATLEAST(1,2,10)
   const SDL_VideoInfo *vidinfo = SDL_GetVideoInfo();
   gl_screen.desktop_w = vidinfo->current_w;
   gl_screen.desktop_h = vidinfo->current_h;
#else /* #elif SDL_VERSION_ATLEAST(1,2,10) */
   gl_screen.desktop_w = 0;
   gl_screen.desktop_h = 0;
#endif /* #elif SDL_VERSION_ATLEAST(1,2,10) */

   /* We'll be parsing XML. */
   LIBXML_TEST_VERSION
   xmlInitParser();

   /* Input must be initialized for config to work. */
   input_init(); 

   /* Set the configuration. */
   snprintf(buf, PATH_MAX, "%s"CONF_FILE, nfile_basePath());
   conf_setDefaults(); /* set the default config values */
   conf_loadConfig(buf); /* Lua to parse the configuration file */
   conf_parseCLI( argc, argv ); /* parse CLI arguments */

   /* Enable FPU exceptions. */
#if !(HAS_WIN32) && defined(DEBUGGING)
   if (conf.fpu_except)
      feenableexcept( FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW );
#endif /* DEBUGGING */

   /* Open data. */
   if (ndata_open() != 0)
      ERR("Failed to open ndata.");

   /* Load the data basics. */
   LOG(" %s", ndata_name());
   DEBUG();

   /* Display the SDL Version. */
   print_SDLversion();
   DEBUG();

   /* random numbers */
   rng_init();


   /*
    * OpenGL
    */
   if (gl_init()) { /* initializes video output */
      ERR("Initializing video output failed, exiting...");
      SDL_Quit();
      exit(EXIT_FAILURE);
   }
   window_caption();
   gl_fontInit( NULL, NULL, FONT_SIZE ); /* initializes default font to size */
   gl_fontInit( &gl_smallFont, NULL, FONT_SIZE_SMALL ); /* small font */

   /* Display the load screen. */
   loadscreen_load();
   loadscreen_render( 0., "Initializing subsystems..." );
   time = SDL_GetTicks();


   /*
    * Input
    */
   if ((conf.joystick_ind >= 0) || (conf.joystick_nam != NULL)) {
      if (joystick_init()) WARN("Error initializing joystick input");
      if (conf.joystick_nam != NULL) { /* use the joystick name to find a joystick */
         if (joystick_use(joystick_get(conf.joystick_nam))) {
            WARN("Failure to open any joystick, falling back to default keybinds");
            input_setDefault();
         }
         free(conf.joystick_nam);
      }
      else if (conf.joystick_ind >= 0) /* use a joystick id instead */
         if (joystick_use(conf.joystick_ind)) {
            WARN("Failure to open any joystick, falling back to default keybinds");
            input_setDefault();
         }
   }


   /*
    * OpenAL - Sound
    */
   if (conf.nosound) {
      LOG("Sound is disabled!");
      sound_disabled = 1;
      music_disabled = 1;
   }
   if (sound_init()) WARN("Problem setting up sound!");
   music_choose("load");


   /* Misc graphics init */
   if (nebu_init() != 0) { /* Initializes the nebula */
      /* An error has happened */
      ERR("Unable to initialize the Nebula subsystem!");
      /* Weirdness will occur... */
   }
   gui_init(); /* initializes the GUI graphics */
   toolkit_init(); /* initializes the toolkit */
   map_init(); /* initializes the map. */
   cond_init(); /* Initialize conditional subsystem. */

   /* Data loading */
   load_all();

   /* Unload load screen. */
   loadscreen_unload();

   /* Start menu. */
   menu_main();

   /* Force a minimum delay with loading screen */
   if ((SDL_GetTicks() - time) < NAEV_INIT_DELAY)
      SDL_Delay( NAEV_INIT_DELAY - (SDL_GetTicks() - time) );
   time = SDL_GetTicks(); /* initializes the time */
   /* 
    * main loop
    */
   SDL_Event event;
   /* flushes the event loop since I noticed that when the joystick is loaded it
    * creates button events that results in the player starting out acceling */
   while (SDL_PollEvent(&event));
   /* primary loop */
   while (!quit) {
      while (SDL_PollEvent(&event)) { /* event loop */
         if (event.type == SDL_QUIT)
            quit = 1; /* quit is handled here */

         input_handle(&event); /* handles all the events and player keybinds */
      }

      main_loop();
   }


   /* Save configuration. */
   conf_saveConfig(buf);

   /* cleanup some stuff */
   player_cleanup(); /* cleans up the player stuff */
   gui_free(); /* cleans up the player's GUI */
   weapon_exit(); /* destroys all active weapons */
   pilots_free(); /* frees the pilots, they were locked up :( */
   cond_exit(); /* destroy conditional subsystem. */
   land_exit(); /* Destroys landing vbo and friends. */

   /* data unloading */
   unload_all();

   /* cleanup opengl fonts */
   gl_freeFont(NULL);
   gl_freeFont(&gl_smallFont);

   /* Close data. */
   ndata_close();

   /* Destroy conf. */
   conf_cleanup(); /* Frees some memory the configuration allocated. */

   /* exit subsystems */
   map_exit(); /* destroys the map. */
   toolkit_exit(); /* kills the toolkit */
   ai_exit(); /* stops the Lua AI magic */
   joystick_exit(); /* releases joystick */
   input_exit(); /* cleans up keybindings */
   nebu_exit(); /* destroys the nebula */
   gl_exit(); /* kills video output */
   sound_exit(); /* kills the sound */
   news_exit(); /* destroys the news. */

   /* Free the icon. */
   if (naev_icon)
      free(naev_icon);

   SDL_Quit(); /* quits SDL */

   /* all is well */
   exit(EXIT_SUCCESS);
}