void pilotfile_convert::csg_export_loadout() { startSection(Section::Loadout); // base info cfwrite_string_len(csg->loadout.filename.c_str(), cfp); cfwrite_string_len(csg->loadout.last_modified.c_str(), cfp); // ship pool size_t list_size = csg->loadout.ship_pool.size(); for (size_t idx = 0; idx < list_size; idx++) { cfwrite_int(csg->loadout.ship_pool[idx], cfp); } // weapon pool list_size = csg->loadout.weapon_pool.size(); for (size_t idx = 0; idx < list_size; idx++) { cfwrite_int(csg->loadout.weapon_pool[idx], cfp); } // play ship loadout cfwrite_ushort(12, cfp); for (size_t idx = 0; idx < 12; idx++) { // ship cfwrite_int(csg->loadout.slot[idx].ship_index, cfp); // primary weapons cfwrite_int(3, cfp); for (size_t j = 0; j < 3; j++) { cfwrite_int(csg->loadout.slot[idx].wep[j], cfp); cfwrite_int(csg->loadout.slot[idx].wep_count[j], cfp); } // secondary weapons cfwrite_int(4, cfp); for (size_t j = 0; j < 4; j++) { cfwrite_int(csg->loadout.slot[idx].wep[j+3], cfp); cfwrite_int(csg->loadout.slot[idx].wep_count[j+3], cfp); } } endSection(); }
void pilotfile::csg_write_loadout() { int idx, j; startSection(Section::Loadout); // base info cfwrite_string_len(Player_loadout.filename, cfp); cfwrite_string_len(Player_loadout.last_modified, cfp); // ship pool for (idx = 0; idx < static_cast<int>(Ship_info.size()); idx++) { cfwrite_int(Player_loadout.ship_pool[idx], cfp); } // weapon pool for (idx = 0; idx < Num_weapon_types; idx++) { cfwrite_int(Player_loadout.weapon_pool[idx], cfp); } // play ship loadout cfwrite_ushort(MAX_WSS_SLOTS, cfp); for (idx = 0; idx < MAX_WSS_SLOTS; idx++) { wss_unit *slot = &Player_loadout.unit_data[idx]; // ship cfwrite_int(slot->ship_class, cfp); // primary weapons cfwrite_int(MAX_SHIP_PRIMARY_BANKS, cfp); for (j = 0; j < MAX_SHIP_PRIMARY_BANKS; j++) { cfwrite_int(slot->wep[j], cfp); cfwrite_int(slot->wep_count[j], cfp); } // secondary weapons cfwrite_int(MAX_SHIP_SECONDARY_BANKS, cfp); for (j = 0; j < MAX_SHIP_SECONDARY_BANKS; j++) { cfwrite_int(slot->wep[j+MAX_SHIP_PRIMARY_BANKS], cfp); cfwrite_int(slot->wep_count[j+MAX_SHIP_PRIMARY_BANKS], cfp); } } endSection(); }
void pilotfile::plr_write_flags() { startSection(Section::Flags); // tips cfwrite_ubyte((unsigned char)p->tips, cfp); // saved flags cfwrite_int(p->save_flags, cfp); // listing mode (single or campaign missions) cfwrite_int(p->readyroom_listing_mode, cfp); // briefing auto-play cfwrite_int(p->auto_advance, cfp); // special rank setting (to avoid having to read all stats on verify) // should be multi only from now on cfwrite_int(multi_stats.rank, cfp); // What game mode we were in last on this pilot cfwrite_int(p->player_was_multi, cfp); // which language was this pilot created with cfwrite_string_len(p->language, cfp); endSection(); }
void pilotfile_convert::csg_export_cutscenes() { SCP_vector<cutscene_info>::iterator cut; startSection(Section::Cutscenes); // convert the old int bitfield to the new vector // the 32 is the size-in-bits of the old int on all platforms // supported by FSO prior to 3.7.0 size_t size = Cutscenes.size(); size_t viewableScenes = 0; for (size_t j=0; j<size && j<32; ++j) { if ( csg->cutscenes & (1<<j) ) { Cutscenes.at(j).viewable = true; viewableScenes++; } } // Check for possible overflow because we can only write 32 bit integers Assertion(viewableScenes <= std::numeric_limits<uint>::max(), "Too many viewable cutscenes! Maximum is %ud!", std::numeric_limits<uint>::max()); // output cutscene data in new format cfwrite_uint((uint)viewableScenes, cfp); for(cut = Cutscenes.begin(); cut != Cutscenes.end(); ++cut) { if(cut->viewable) cfwrite_string_len(cut->filename, cfp); } endSection(); }
void pilotfile::plr_write_stats_multi() { int idx, list_size = 0; startSection(Section::ScoringMulti); // global, all-time stats cfwrite_int(multi_stats.score, cfp); cfwrite_int(multi_stats.rank, cfp); cfwrite_int(multi_stats.assists, cfp); cfwrite_int(multi_stats.kill_count, cfp); cfwrite_int(multi_stats.kill_count_ok, cfp); cfwrite_int(multi_stats.bonehead_kills, cfp); cfwrite_uint(multi_stats.p_shots_fired, cfp); cfwrite_uint(multi_stats.p_shots_hit, cfp); cfwrite_uint(multi_stats.p_bonehead_hits, cfp); cfwrite_uint(multi_stats.s_shots_fired, cfp); cfwrite_uint(multi_stats.s_shots_hit, cfp); cfwrite_uint(multi_stats.s_bonehead_hits, cfp); cfwrite_uint(multi_stats.flight_time, cfp); cfwrite_uint(multi_stats.missions_flown, cfp); cfwrite_int((int)multi_stats.last_flown, cfp); cfwrite_int((int)multi_stats.last_backup, cfp); // ship kills (contains medals across all mods, not just current) list_size = (int)multi_stats.ship_kills.size(); cfwrite_int(list_size, cfp); for (idx = 0; idx < list_size; idx++) { cfwrite_string_len(multi_stats.ship_kills[idx].name.c_str(), cfp); cfwrite_int(multi_stats.ship_kills[idx].val, cfp); } // medals earned (contains medals across all mods, not just current) list_size = (int)multi_stats.medals_earned.size(); cfwrite_int(list_size, cfp); for (idx = 0; idx < list_size; idx++) { cfwrite_string_len(multi_stats.medals_earned[idx].name.c_str(), cfp); cfwrite_int(multi_stats.medals_earned[idx].val, cfp); } endSection(); }
void pilotfile_convert::plr_export_info() { startSection(Section::Info); // pilot image cfwrite_string_len(plr->image_filename, cfp); // squad name cfwrite_string_len(plr->squad_name, cfp); // squad image cfwrite_string_len(plr->squad_filename, cfp); // active campaign cfwrite_string_len(plr->current_campaign, cfp); endSection(); }
void pilotfile::plr_write_info() { startSection(Section::Info); // pilot image cfwrite_string_len(p->image_filename, cfp); // multi squad name cfwrite_string_len(p->m_squad_name, cfp); // squad image cfwrite_string_len(p->m_squad_filename, cfp); // active campaign cfwrite_string_len(p->current_campaign, cfp); endSection(); }
void pilotfile_convert::csg_export_variables() { int list_size = 0; int idx; startSection(Section::Variables); list_size = (int)csg->variables.size(); cfwrite_int(list_size, cfp); for (idx = 0; idx < list_size; idx++) { cfwrite_int(csg->variables[idx].type, cfp); cfwrite_string_len(csg->variables[idx].text, cfp); cfwrite_string_len(csg->variables[idx].variable_name, cfp); } endSection(); }
void pilotfile::plr_write_variables() { int list_size = 0; int idx; startSection(Section::Variables); list_size = (int)p->variables.size(); cfwrite_int(list_size, cfp); for (idx = 0; idx < list_size; idx++) { cfwrite_int(p->variables[idx].type, cfp); cfwrite_string_len(p->variables[idx].text, cfp); cfwrite_string_len(p->variables[idx].variable_name, cfp); } endSection(); }
void pilotfile::csg_write_lastmissions() { int i; startSection(Section::LastMissions); // store list of most recently played missions cfwrite_int(Num_recent_missions, cfp); for (i=0; i<Num_recent_missions; i++) { cfwrite_string_len(Recent_missions[i], cfp); } endSection(); }
void pilotfile::csg_write_variables() { int idx; startSection(Section::Variables); cfwrite_int(Campaign.num_variables, cfp); for (idx = 0; idx < Campaign.num_variables; idx++) { cfwrite_int(Campaign.variables[idx].type, cfp); cfwrite_string_len(Campaign.variables[idx].text, cfp); cfwrite_string_len(Campaign.variables[idx].variable_name, cfp); } cfwrite_int(Campaign.redalert_num_variables, cfp); for (idx = 0; idx < Campaign.redalert_num_variables; idx++) { cfwrite_int(Campaign.redalert_variables[idx].type, cfp); cfwrite_string_len(Campaign.redalert_variables[idx].text, cfp); cfwrite_string_len(Campaign.redalert_variables[idx].variable_name, cfp); } endSection(); }
void pilotfile::csg_write_cutscenes() { SCP_vector<cutscene_info>::iterator cut; startSection(Section::Cutscenes); size_t viewableScenes = 0; for(cut = Cutscenes.begin(); cut != Cutscenes.end(); ++cut) { if(cut->viewable) viewableScenes ++; } cfwrite_uint(viewableScenes, cfp); for(cut = Cutscenes.begin(); cut != Cutscenes.end(); ++cut) { if(cut->viewable) cfwrite_string_len(cut->filename, cfp); } endSection(); }
void pilotfile::csg_write_cutscenes() { SCP_vector<cutscene_info>::iterator cut; startSection(Section::Cutscenes); size_t viewableScenes = 0; for(cut = Cutscenes.begin(); cut != Cutscenes.end(); ++cut) { if(cut->viewable) viewableScenes ++; } // Check for possible overflow because we can only write 32 bit integers Assertion(viewableScenes <= std::numeric_limits<uint>::max(), "Too many viewable cutscenes! Maximum is %ud!", std::numeric_limits<uint>::max()); cfwrite_uint((uint)viewableScenes, cfp); for(cut = Cutscenes.begin(); cut != Cutscenes.end(); ++cut) { if(cut->viewable) cfwrite_string_len(cut->filename, cfp); } endSection(); }
void pilotfile_convert::csg_export_info() { int list_size = 0; int idx; ubyte visible; startSection(Section::Info); // ship list list_size = (int)csg->ship_list.size(); cfwrite_int(list_size, cfp); for (idx = 0; idx < list_size; idx++) { cfwrite_string_len(csg->ship_list[idx].name.c_str(), cfp); } // weapon list list_size = (int)csg->weapon_list.size(); cfwrite_int(list_size, cfp); for (idx = 0; idx < list_size; idx++) { cfwrite_string_len(csg->weapon_list[idx].name.c_str(), cfp); } // intel list list_size = (int)csg->intel_list.size(); cfwrite_int(list_size, cfp); for (idx = 0; idx < list_size; idx++) { cfwrite_string_len(csg->intel_list[idx].name.c_str(), cfp); } // medals list list_size = (int)csg->stats.medals_earned.size(); cfwrite_int(list_size, cfp); for (idx = 0; idx < list_size; idx++) { cfwrite_string_len(csg->stats.medals_earned[idx].name.c_str(), cfp); } // last ship flown cfwrite_int(csg->last_ship_flown_index, cfp); // progression state cfwrite_int(csg->prev_mission, cfp); cfwrite_int(csg->next_mission, cfp); // loop state cfwrite_int(csg->loop_enabled, cfp); cfwrite_int(csg->loop_reentry, cfp); // missions completed list_size = (int)csg->missions.size(); cfwrite_int(list_size, cfp); // allowed ships list_size = (int)csg->ships_allowed.size(); for (idx = 0; idx < list_size; idx++) { visible = csg->ships_allowed[idx] ? 1 : 0; cfwrite_ubyte(visible, cfp); } // allowed weapons list_size = (int)csg->weapons_allowed.size(); for (idx = 0; idx < list_size; idx++) { visible = csg->weapons_allowed[idx] ? 1 : 0; cfwrite_ubyte(visible, cfp); } // single/campaign squad name & image, make it the same as multi cfwrite_string_len(plr->squad_name, cfp); cfwrite_string_len(plr->squad_filename, cfp); endSection(); }
void pilotfile::csg_write_redalert() { int idx, j, list_size = 0; int count; red_alert_ship_status *ras; startSection(Section::RedAlert); list_size = (int)Red_alert_wingman_status.size(); cfwrite_int(list_size, cfp); if (list_size) { cfwrite_string_len(Red_alert_precursor_mission.c_str(), cfp); for (idx = 0; idx < list_size; idx++) { ras = &Red_alert_wingman_status[idx]; cfwrite_string_len(ras->name.c_str(), cfp); cfwrite_float(ras->hull, cfp); // ship class, should be index into ship_list[] on load cfwrite_int(ras->ship_class, cfp); // subsystem hits count = (int)ras->subsys_current_hits.size(); cfwrite_int(count, cfp); for (j = 0; j < count; j++) { cfwrite_float(ras->subsys_current_hits[j], cfp); } // subsystem aggregate hits count = (int)ras->subsys_aggregate_current_hits.size(); cfwrite_int(count, cfp); for (j = 0; j < count; j++) { cfwrite_float(ras->subsys_aggregate_current_hits[j], cfp); } // primary weapon loadout and status count = (int)ras->primary_weapons.size(); cfwrite_int(count, cfp); for (j = 0; j < count; j++) { cfwrite_int(ras->primary_weapons[j].index, cfp); cfwrite_int(ras->primary_weapons[j].count, cfp); } // secondary weapon loadout and status count = (int)ras->secondary_weapons.size(); cfwrite_int(count, cfp); for (j = 0; j < count; j++) { cfwrite_int(ras->secondary_weapons[j].index, cfp); cfwrite_int(ras->secondary_weapons[j].count, cfp); } } } endSection(); }
void pilotfile_convert::csg_export_missions() { startSection(Section::Missions); size_t list_size = csg->missions.size(); for (size_t idx = 0; idx < list_size; idx++) { cfwrite_int(csg->missions[idx].index, cfp); // flags cfwrite_int(csg->missions[idx].flags, cfp); // goals size_t count = csg->missions[idx].goals.size(); cfwrite_int((int)count, cfp); for (size_t j = 0; j < count; j++) { cfwrite_string_len(csg->missions[idx].goals[j].name, cfp); cfwrite_char(csg->missions[idx].goals[j].status, cfp); } // events count = csg->missions[idx].events.size(); cfwrite_int((int)count, cfp); for (size_t j = 0; j < count; j++) { cfwrite_string_len(csg->missions[idx].events[j].name, cfp); cfwrite_char(csg->missions[idx].events[j].status, cfp); } // variables count = csg->missions[idx].variables.size(); cfwrite_int((int)count, cfp); for (size_t j = 0; j < count; j++) { cfwrite_int(csg->missions[idx].variables[j].type, cfp); cfwrite_string_len(csg->missions[idx].variables[j].text, cfp); cfwrite_string_len(csg->missions[idx].variables[j].variable_name, cfp); } // scoring stats cfwrite_int(csg->missions[idx].stats.score, cfp); cfwrite_int(csg->missions[idx].stats.rank, cfp); cfwrite_int(csg->missions[idx].stats.assists, cfp); cfwrite_int(csg->missions[idx].stats.kill_count, cfp); cfwrite_int(csg->missions[idx].stats.kill_count_ok, cfp); cfwrite_int(csg->missions[idx].stats.bonehead_kills, cfp); cfwrite_uint(csg->missions[idx].stats.p_shots_fired, cfp); cfwrite_uint(csg->missions[idx].stats.p_shots_hit, cfp); cfwrite_uint(csg->missions[idx].stats.p_bonehead_hits, cfp); cfwrite_uint(csg->missions[idx].stats.s_shots_fired, cfp); cfwrite_uint(csg->missions[idx].stats.s_shots_hit, cfp); cfwrite_uint(csg->missions[idx].stats.s_bonehead_hits, cfp); // ship kills (scoring) count = csg->missions[idx].stats.ship_kills.size(); for (size_t j = 0; j < count; j++) { cfwrite_int(csg->missions[idx].stats.ship_kills[j].val, cfp); } // medals earned (scoring) count = csg->missions[idx].stats.medals_earned.size(); for (size_t j = 0; j < count; j++) { cfwrite_int(csg->missions[idx].stats.medals_earned[j].val, cfp); } } endSection(); }
void pilotfile::csg_write_missions() { int idx, j; cmission *missionp; startSection(Section::Missions); for (idx = 0; idx < MAX_CAMPAIGN_MISSIONS; idx++) { if (Campaign.missions[idx].completed) { missionp = &Campaign.missions[idx]; cfwrite_int(idx, cfp); // flags cfwrite_int(missionp->flags, cfp); // goals cfwrite_int(missionp->num_goals, cfp); for (j = 0; j < missionp->num_goals; j++) { cfwrite_string_len(missionp->goals[j].name, cfp); cfwrite_char(missionp->goals[j].status, cfp); } // events cfwrite_int(missionp->num_events, cfp); for (j = 0; j < missionp->num_events; j++) { cfwrite_string_len(missionp->events[j].name, cfp); cfwrite_char(missionp->events[j].status, cfp); } // variables cfwrite_int(missionp->num_variables, cfp); for (j = 0; j < missionp->num_variables; j++) { cfwrite_int(missionp->variables[j].type, cfp); cfwrite_string_len(missionp->variables[j].text, cfp); cfwrite_string_len(missionp->variables[j].variable_name, cfp); } // scoring stats cfwrite_int(missionp->stats.score, cfp); cfwrite_int(missionp->stats.rank, cfp); cfwrite_int(missionp->stats.assists, cfp); cfwrite_int(missionp->stats.kill_count, cfp); cfwrite_int(missionp->stats.kill_count_ok, cfp); cfwrite_int(missionp->stats.bonehead_kills, cfp); cfwrite_uint(missionp->stats.p_shots_fired, cfp); cfwrite_uint(missionp->stats.p_shots_hit, cfp); cfwrite_uint(missionp->stats.p_bonehead_hits, cfp); cfwrite_uint(missionp->stats.s_shots_fired, cfp); cfwrite_uint(missionp->stats.s_shots_hit, cfp); cfwrite_uint(missionp->stats.s_bonehead_hits, cfp); // ship kills (scoring) for (j = 0; j < static_cast<int>(Ship_info.size()); j++) { cfwrite_int(missionp->stats.kills[j], cfp); } // medals earned (scoring) for (j = 0; j < Num_medals; j++) { cfwrite_int(missionp->stats.medal_counts[j], cfp); } } } endSection(); }
void pilotfile::csg_write_info() { int idx; startSection(Section::Info); // ship list cfwrite_int(static_cast<int>(Ship_info.size()), cfp); for (auto it = Ship_info.cbegin(); it != Ship_info.cend(); ++it) { cfwrite_string_len(it->name, cfp); } // weapon list cfwrite_int(Num_weapon_types, cfp); for (idx = 0; idx < Num_weapon_types; idx++) { cfwrite_string_len(Weapon_info[idx].name, cfp); } // intel list cfwrite_int(Intel_info_size, cfp); for (idx = 0; idx < Intel_info_size; idx++) { cfwrite_string_len(Intel_info[idx].name, cfp); } // medals list cfwrite_int(Num_medals, cfp); for (idx = 0; idx < Num_medals; idx++) { cfwrite_string_len(Medals[idx].name, cfp); } // last ship flown cfwrite_int(p->last_ship_flown_si_index, cfp); // progression state cfwrite_int(Campaign.prev_mission, cfp); cfwrite_int(Campaign.next_mission, cfp); // loop state cfwrite_int(Campaign.loop_reentry, cfp); cfwrite_int(Campaign.loop_enabled, cfp); // missions completed cfwrite_int(Campaign.num_missions_completed, cfp); // allowed ships for (idx = 0; idx < static_cast<int>(Ship_info.size()); idx++) { cfwrite_ubyte(Campaign.ships_allowed[idx], cfp); } // allowed weapons for (idx = 0; idx < Num_weapon_types; idx++) { cfwrite_ubyte(Campaign.weapons_allowed[idx], cfp); } // single/campaign squad name & image cfwrite_string_len(p->s_squad_name, cfp); cfwrite_string_len(p->s_squad_filename, cfp); endSection(); }
void pilot::BinaryFileHandler::writeString(const char*, const char* str) { cfwrite_string_len(str, _cfp); }