コード例 #1
0
ファイル: save.c プロジェクト: isfos/naev
/**
 * @brief Actually loads a new game based on file.
 *
 *    @param file File that contains the new game.
 *    @return 0 on success.
 */
static int load_game( const char* file )
{
   xmlNodePtr node;
   xmlDocPtr doc;

   /* Make sure it exists. */
   if (!nfile_fileExists(file)) {
      dialogue_alert("Savegame file seems to have been deleted.");
      return -1;
   }

   /* Load the XML. */
   doc   = xmlParseFile(file);
   if (doc == NULL)
      goto err;
   node  = doc->xmlChildrenNode; /* base node */
   if (node == NULL)
      goto err_doc;

   /* Clean up possible stuff that should be cleaned. */
   player_cleanup();
   diff_clear();
   var_cleanup();
   missions_cleanup();
   events_cleanup();

   /* Welcome message - must be before space_init. */
   player_message( "\egWelcome to "APPNAME"!" );
   player_message( "\eg v%d.%d.%d", VMAJOR, VMINOR, VREV );

   /* Now begin to load. */
   diff_load(node); /* Must load first to work properly. */
   pfaction_load(node); /* Must be loaded before player so the messages show up properly. */
   player_load(node);
   var_load(node);
   missions_loadActive(node);
   hook_load(node);
   space_sysLoad(node);

   /* Initialize the economy. */
   economy_init();

   /* Need to run takeoff hooks since player just "took off" */
   hooks_run("takeoff");
   player_addEscorts();
   hooks_run("enter");
   events_trigger( EVENT_TRIGGER_ENTER );

   xmlFreeDoc(doc);
   xmlCleanupParser();
   
   return 0;

err_doc:
   xmlFreeDoc(doc);
   xmlCleanupParser();
err:
   WARN("Savegame '%s' invalid!", file);
   return -1;
}
コード例 #2
0
union TrainerPokemonPtr battle_trainer_get_rival_or_null(u8 tid) {
    for(u16 i = 0; i < RIVAL_ENCOUNTER_COUNT; ++i) {
        if(rival_encounters[i].trainerId == tid) {
            return battle_trainer_get_rival(var_load(VAR_STARTER_PLAYER_POKEMON), i, trainer_data[tid].flags);
        }
    }
    union TrainerPokemonPtr nullPokemon = {.undefinedStructure = NULL};
    return nullPokemon;
}
コード例 #3
0
ファイル: all_test.cpp プロジェクト: koudis/robot
int init_systems() {
  var_load(CONFIG_FILE); // Nacti vsechny promenne
  led_init();
  input_event_init(); // Klavesnice
  enc_init(); // Nastav encodery
//  motor_init(); // PID -> zapinat az po encoderech
  i2c_init(); // Priprav i2c komunikaci

  pthread_attr_t *thAttr = NULL;
  pthread_create(&bumpers_loop_tid, thAttr, bumpers_loop, NULL);
  return 0;
}
コード例 #4
0
ファイル: calc.test.c プロジェクト: jcarrano/expr
void uiloop(data_t a, data_t b, int nsteps, char *s)
{
	int done = 0;
	struct input inp;
	struct parse_options po;
	struct expr_environ *env = new_env();
	struct expr_var ans;
	data_t ans_data = 45;
	
	Genv = env;
	
	/* setup global vars */
	ans.name = "ans";
	ans.location = &ans_data;
	var_load(env, &ans);
	
	/*setup C funcions & constants*/
	load_builtins(env);
	func_multiload(env, local_funcs, ARSIZE(local_funcs));

	/*Parser options*/
	po.auto_clear = 0;
	po.n_args = (nsteps != 0);
	po.n_rets = CALC_N_RETS;
	
	if (s == NULL) {
		mk_lineinput(&inp, stdin);
		
		while(!done && !linput_done(inp) && !Gdone) {
			fputs("> ", stderr);
			if (linput_prefetch(inp)) {
				eval_print(a, b, nsteps, po, env, inp, &ans_data);
			}
		}
		
		destroy_lineinput(&inp);
	} else {
		mk_strinput(&inp, s, STRINP_NOCOPY);
		eval_print(a, b, nsteps, po, env, inp, &ans_data);
		destroy_strinput(&inp);
	}
	
	destroy_env(env);
}