void pilotfile::plr_read_flags() { // tips? p->tips = (int)cfread_ubyte(cfp); // saved flags p->save_flags = cfread_int(cfp); // listing mode (single or campaign missions p->readyroom_listing_mode = cfread_int(cfp); // briefing auto-play p->auto_advance = cfread_int(cfp); // special rank setting (to avoid having to read all stats on verify) // will be the multi rank // if there's a valid CSG, this will be overwritten p->stats.rank = cfread_int(cfp); if (version > 0) { p->player_was_multi = cfread_int(cfp); } else { p->player_was_multi = 0; // Default to single player } // which language was this pilot created with if (version > 1) { cfread_string_len(p->language, sizeof(p->language), cfp); } else { // if we don't know, default to the current language setting lcl_get_language_name(p->language); } }
/* * validate that a pilot/player was created with the same language FSO is currently using * * @param pilots callsign * @note not longer needed if intel entry "primary keys" change to a non-translated value */ bool valid_pilot_lang(char *callsign) { char pilot_lang[LCL_LANG_NAME_LEN+1], current_lang[LCL_LANG_NAME_LEN+1]; SCP_string filename = callsign; filename += ".plr"; lcl_get_language_name(current_lang); if (Pilot.verify(filename.c_str(), NULL, pilot_lang)) { if (!strcmp(current_lang, pilot_lang)) { return true; } } return false; }
// this works on barracks and player_select interface screens void init_new_pilot(player *p, int reset) { int cur_speed; if (reset) { hud_set_default_hud_config(p); // use a default hud config control_config_reset_defaults(); // get a default keyboard config player_set_pilot_defaults(p); // set up any player struct defaults // set the default detail level based on tabling rather than the above method cur_speed = Default_detail_level; #if NUM_DEFAULT_DETAIL_LEVELS != 4 #error Code in ManagePilot assumes NUM_DEFAULT_DETAIL_LEVELS = 4 #endif detail_level_set(cur_speed); Game_skill_level = game_get_default_skill_level(); mprintf(( "Setting detail level to %d because of new pilot\n", cur_speed )); Use_mouse_to_fly = 1; Mouse_sensitivity = 4; Joy_sensitivity = 9; Dead_zone_size = 10; } // unassigned squadron strcpy_s(p->s_squad_name, XSTR("Unassigned", 1255)); strcpy_s(p->s_squad_filename, ""); strcpy_s(p->m_squad_name, XSTR("Unassigned", 1255)); strcpy_s(p->m_squad_filename, ""); // set him to be a single player pilot by default (the actual creation routines will change this if necessary) p->flags &= ~PLAYER_FLAGS_IS_MULTI; // effectively sets the length return by strlen() to 0 Campaign.filename[0] = 0; // pick a random pilot image for this guy if (reset){ pilot_set_random_pic(p); p->insignia_texture = -1; pilot_set_random_squad_pic(p); } p->stats.init(); Pilot.reset_stats(); p->stats.score = 0; p->stats.rank = RANK_ENSIGN; p->tips = 1; // set pilot language to the current language lcl_get_language_name(p->language); Multi_options_g.protocol = NET_TCP; // initialize default multiplayer options multi_options_set_netgame_defaults(&p->m_server_options); multi_options_set_local_defaults(&p->m_local_options); Player_loadout.filename[0] = 0; // reset the cutscenes which can be viewed if ( reset ){ cutscene_init(); } pilot_set_start_campaign(p); }