21 void pilotfile::plr_read_flags()
45 p->player_was_multi = 0;
57 void pilotfile::plr_write_flags()
59 startSection(Section::Flags);
86 void pilotfile::plr_read_info()
88 if ( !m_have_flags ) {
89 throw "Info before Flags!";
105 void pilotfile::plr_write_info()
107 startSection(Section::Info);
124 void pilotfile::plr_read_hud()
154 for (idx = 0; idx < num_gauges; idx++) {
171 void pilotfile::plr_write_hud()
175 startSection(Section::HUD);
207 void pilotfile::plr_read_variables()
215 if (list_size <= 0) {
219 p->variables.reserve(list_size);
221 for (idx = 0; idx < list_size; idx++) {
226 p->variables.push_back( n_var );
230 void pilotfile::plr_write_variables()
235 startSection(Section::Variables);
237 list_size = (
int)
p->variables.size();
241 for (idx = 0; idx < list_size; idx++) {
250 void pilotfile::plr_read_multiplayer()
260 p->m_server_options.voice_token_wait =
cfread_int(cfp);
261 p->m_server_options.voice_record_time =
cfread_int(cfp);
267 p->m_local_options.obj_update_level =
cfread_int(cfp);
277 void pilotfile::plr_write_multiplayer()
279 startSection(Section::Multiplayer);
290 cfwrite_int(
p->m_server_options.voice_record_time, cfp);
291 cfwrite_int((
int)
p->m_server_options.mission_time_limit, cfp);
304 void pilotfile::plr_read_stats()
306 int idx, j, list_size = 0;
315 all_time_stats.kill_count_ok =
cfread_int(cfp);
316 all_time_stats.bonehead_kills =
cfread_int(cfp);
333 all_time_stats.ship_kills.reserve(list_size);
335 for (idx = 0; idx < list_size; idx++) {
338 ilist.
name = t_string;
342 all_time_stats.ship_kills.push_back(ilist);
347 all_time_stats.medals_earned.reserve(list_size);
349 for (idx = 0; idx < list_size; idx++) {
352 ilist.
name = t_string;
356 all_time_stats.medals_earned.push_back(ilist);
361 p->stats.score = all_time_stats.score;
362 p->stats.rank = all_time_stats.rank;
363 p->stats.assists = all_time_stats.assists;
364 p->stats.kill_count = all_time_stats.kill_count;
365 p->stats.kill_count_ok = all_time_stats.kill_count_ok;
366 p->stats.bonehead_kills = all_time_stats.bonehead_kills;
368 p->stats.p_shots_fired = all_time_stats.p_shots_fired;
369 p->stats.p_shots_hit = all_time_stats.p_shots_hit;
370 p->stats.p_bonehead_hits = all_time_stats.p_bonehead_hits;
372 p->stats.s_shots_fired = all_time_stats.s_shots_fired;
373 p->stats.s_shots_hit = all_time_stats.s_shots_hit;
374 p->stats.s_bonehead_hits = all_time_stats.s_bonehead_hits;
376 p->stats.flight_time = all_time_stats.flight_time;
377 p->stats.missions_flown = all_time_stats.missions_flown;
378 p->stats.last_flown = all_time_stats.last_flown;
379 p->stats.last_backup = all_time_stats.last_backup;
382 list_size = (
int)all_time_stats.ship_kills.size();
383 for (idx = 0; idx < list_size; idx++) {
384 j = all_time_stats.ship_kills[
idx].index;
387 p->stats.kills[j] = all_time_stats.ship_kills[
idx].val;
392 list_size = (
int)all_time_stats.medals_earned.size();
393 for (idx = 0; idx < list_size; idx++) {
394 j = all_time_stats.medals_earned[
idx].index;
397 p->stats.medal_counts[j] = all_time_stats.medals_earned[
idx].val;
403 void pilotfile::plr_write_stats()
405 int idx, list_size = 0;
407 startSection(Section::Scoring);
431 list_size = (
int)all_time_stats.ship_kills.size();
434 for (idx = 0; idx < list_size; idx++) {
436 cfwrite_int(all_time_stats.ship_kills[idx].val, cfp);
440 list_size = (
int)all_time_stats.medals_earned.size();
443 for (idx = 0; idx < list_size; idx++) {
445 cfwrite_int(all_time_stats.medals_earned[idx].val, cfp);
451 void pilotfile::plr_read_stats_multi()
453 int idx, j, list_size = 0;
480 multi_stats.ship_kills.reserve(list_size);
482 for (idx = 0; idx < list_size; idx++) {
485 ilist.
name = t_string;
489 multi_stats.ship_kills.push_back(ilist);
494 multi_stats.medals_earned.reserve(list_size);
496 for (idx = 0; idx < list_size; idx++) {
499 ilist.
name = t_string;
503 multi_stats.medals_earned.push_back(ilist);
508 p->stats.score = multi_stats.score;
509 p->stats.rank = multi_stats.rank;
510 p->stats.assists = multi_stats.assists;
511 p->stats.kill_count = multi_stats.kill_count;
512 p->stats.kill_count_ok = multi_stats.kill_count_ok;
513 p->stats.bonehead_kills = multi_stats.bonehead_kills;
515 p->stats.p_shots_fired = multi_stats.p_shots_fired;
516 p->stats.p_shots_hit = multi_stats.p_shots_hit;
517 p->stats.p_bonehead_hits = multi_stats.p_bonehead_hits;
519 p->stats.s_shots_fired = multi_stats.s_shots_fired;
520 p->stats.s_shots_hit = multi_stats.s_shots_hit;
521 p->stats.s_bonehead_hits = multi_stats.s_bonehead_hits;
523 p->stats.flight_time = multi_stats.flight_time;
524 p->stats.missions_flown = multi_stats.missions_flown;
525 p->stats.last_flown = multi_stats.last_flown;
526 p->stats.last_backup = multi_stats.last_backup;
529 list_size = (
int)multi_stats.ship_kills.size();
530 for (idx = 0; idx < list_size; idx++) {
531 j = multi_stats.ship_kills[
idx].index;
534 p->stats.kills[j] = multi_stats.ship_kills[
idx].val;
539 list_size = (
int)multi_stats.medals_earned.size();
540 for (idx = 0; idx < list_size; idx++) {
541 j = multi_stats.medals_earned[
idx].index;
544 p->stats.medal_counts[j] = multi_stats.medals_earned[
idx].val;
550 void pilotfile::plr_write_stats_multi()
552 int idx, list_size = 0;
554 startSection(Section::ScoringMulti);
578 list_size = (
int)multi_stats.ship_kills.size();
581 for (idx = 0; idx < list_size; idx++) {
587 list_size = (
int)multi_stats.medals_earned.size();
590 for (idx = 0; idx < list_size; idx++) {
592 cfwrite_int(multi_stats.medals_earned[idx].val, cfp);
598 void pilotfile::plr_read_controls()
600 int idx, list_size, list_axis;
605 for (idx = 0; idx < list_size; idx++) {
617 for (idx = 0; idx < list_axis; idx++) {
628 void pilotfile::plr_write_controls()
632 startSection(Section::Controls);
636 for (idx = 0; idx <
CCFG_MAX; idx++) {
653 void pilotfile::plr_read_settings()
695 void pilotfile::plr_write_settings()
697 startSection(Section::Settings);
732 void pilotfile::plr_reset_data()
735 m_have_flags =
false;
738 m_data_invalid =
false;
747 all_time_stats.ship_kills.clear();
748 all_time_stats.medals_earned.clear();
750 multi_stats.ship_kills.clear();
751 multi_stats.medals_earned.clear();
754 p->variables.clear();
760 void pilotfile::plr_close()
775 m_have_flags =
false;
802 if ( filename.size() == 4 ) {
803 mprintf((
"PLR => Invalid filename '%s'!\n", filename.c_str()));
810 mprintf((
"PLR => Unable to open '%s' for reading!\n", filename.c_str()));
816 if (plr_id != PLR_FILE_ID) {
817 mprintf((
"PLR => Invalid header id for '%s'!\n", filename.c_str()));
825 mprintf((
"PLR => Loading '%s' with version %d...\n", filename.c_str(),
version));
830 while ( !
cfeof(cfp) ) {
834 size_t start_pos =
cftell(cfp);
840 switch (section_id) {
842 mprintf((
"PLR => Parsing: Flags...\n"));
848 mprintf((
"PLR => Parsing: Info...\n"));
853 case Section::Variables:
854 mprintf((
"PLR => Parsing: Variables...\n"));
855 plr_read_variables();
859 mprintf((
"PLR => Parsing: HUD...\n"));
863 case Section::Scoring:
864 mprintf((
"PLR => Parsing: Scoring...\n"));
868 case Section::ScoringMulti:
869 mprintf((
"PLR => Parsing: ScoringMulti...\n"));
870 plr_read_stats_multi();
873 case Section::Multiplayer:
874 mprintf((
"PLR => Parsing: Multiplayer...\n"));
875 plr_read_multiplayer();
878 case Section::Controls:
879 mprintf((
"PLR => Parsing: Controls...\n"));
883 case Section::Settings:
884 mprintf((
"PLR => Parsing: Settings...\n"));
889 mprintf((
"PLR => Skipping unknown section 0x%04x!\n", section_id));
895 mprintf((
"PLR => (0x%04x) %s\n", section_id, msg.
what()));
896 }
catch (
const char *err) {
897 mprintf((
"PLR => ERROR: %s\n", err));
906 size_t offset_pos = (start_pos + section_size) -
cftell(cfp);
910 mprintf((
"PLR => WARNING: Advancing to the next section. " SIZE_T_ARG " bytes were skipped!\n", offset_pos));
927 mprintf((
"PLR => Loading complete!\n"));
950 if ( !strlen(
p->callsign) ) {
954 filename =
p->callsign;
957 if ( filename.size() == 4 ) {
958 mprintf((
"PLR => Invalid filename '%s'!\n", filename.c_str()));
966 mprintf((
"PLR => Unable to open '%s' for saving!\n", filename.c_str()));
974 mprintf((
"PLR => Saving '%s' with version %d...\n", filename.c_str(), (
int)PLR_VERSION));
977 mprintf((
"PLR => Saving: Flags...\n"));
979 mprintf((
"PLR => Saving: Info...\n"));
983 mprintf((
"PLR => Saving: Scoring...\n"));
985 mprintf((
"PLR => Saving: ScoringMulti...\n"));
986 plr_write_stats_multi();
987 mprintf((
"PLR => Saving: HUD...\n"));
989 mprintf((
"PLR => Saving: Variables...\n"));
990 plr_write_variables();
991 mprintf((
"PLR => Saving: Multiplayer...\n"));
992 plr_write_multiplayer();
993 mprintf((
"PLR => Saving: Controls...\n"));
994 plr_write_controls();
995 mprintf((
"PLR => Saving: Settings...\n"));
996 plr_write_settings();
999 mprintf((
"PLR => Saving complete!\n"));
1015 if ( filename.size() == 4 ) {
1016 mprintf((
"PLR => Invalid filename '%s'!\n", filename.c_str()));
1023 mprintf((
"PLR => Unable to open '%s'!\n", filename.c_str()));
1029 if (plr_id != PLR_FILE_ID) {
1030 mprintf((
"PLR => Invalid header id for '%s'!\n", filename.c_str()));
1038 mprintf((
"PLR => Verifying '%s' with version %d...\n", filename.c_str(), (
int)
version));
1041 while ( !(m_have_flags && m_have_info) && !
cfeof(cfp) ) {
1045 size_t start_pos =
cftell(cfp);
1051 switch (section_id) {
1052 case Section::Flags:
1053 mprintf((
"PLR => Parsing: Flags...\n"));
1054 m_have_flags =
true;
1061 mprintf((
"PLR => Parsing: Info...\n"));
1072 mprintf((
"PLR => (0x%04x) %s\n", section_id, msg.
what()));
1073 }
catch (
const char *err) {
1074 mprintf((
"PLR => ERROR: %s\n", err));
1083 size_t offset_pos = (start_pos + section_size) -
cftell(cfp);
1086 mprintf((
"PLR => Warning: (0x%04x) Short read, information may have been lost!\n", section_id));
1091 if (valid_language) {
1092 strncpy(valid_language,
p->language,
sizeof(
p->language));
1105 filename = filename.replace(filename.find_last_of(
'.')+1,filename.npos, t_plr.
current_campaign);
1106 filename.append(
".csg");
1108 if (!this->get_csg_rank(rank)) {
1118 mprintf((
"PLR => Verifying complete!\n"));
int cfwrite_ushort(ushort s, CFILE *file)
int ship_info_lookup(const char *token)
int Briefing_voice_enabled
void audiostream_set_volume_all(float volume, int type)
#define HUD_COLOR_ALPHA_DEFAULT
void player_set_squad_bitmap(player *p, char *fname, bool ismulti)
void cf_set_max_read_len(CFILE *cfile, size_t len)
short key_id
actual key bound to action
int medals_info_lookup(const char *name)
int cfwrite_ubyte(ubyte b, CFILE *file)
int cfwrite_uint(uint i, CFILE *file)
virtual const char * what() const
color clr[NUM_HUD_GAUGES]
bool verify(const char *fname, int *rank=NULL, char *valid_language=NULL)
char callsign[CALLSIGN_LEN+1]
short joy_id
joystick button bound to action
config_item Control_config[]
Stores the keyboard configuration.
player Players[MAX_PLAYERS]
void os_config_write_string(const char *section, const char *name, const char *value)
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
#define HUD_COLOR_ALPHA_USER_MIN
float Master_sound_volume
char current_campaign[MAX_FILENAME_LEN+1]
int cfwrite_float(float f, CFILE *file)
int cfwrite_string_len(const char *buf, CFILE *file)
Write a fixed length string (not including its null terminator), with the length stored in file...
void pilot_set_short_callsign(player *p, int max_width)
short cfread_short(CFILE *file, int ver, short deflt)
bool save_player(player *_p=NULL)
int cfwrite_int(int i, CFILE *file)
#define GM_STANDALONE_SERVER
ubyte cfread_ubyte(CFILE *file, int ver, ubyte deflt)
ubyte num_msg_window_lines
void control_config_clear()
bool load_player(const char *callsign, player *_p=NULL)
void hud_squadmsg_save_keys(int do_scroll)
int cfwrite_short(short s, CFILE *file)
HUD_CONFIG_TYPE HUD_config
float Master_event_music_volume
The total number of defined control actions (or last define + 1)
ushort cfread_ushort(CFILE *file, int ver, ushort deflt)
int cfread_int(CFILE *file, int ver, int deflt)
float cfread_float(CFILE *file, int ver, float deflt)
void hud_config_set_color(int in_color)
char variable_name[TOKEN_LENGTH]
int cfclose(CFILE *cfile)
GLclampf GLclampf GLclampf alpha
The total number of actions an axis may map to.
#define SHORT_CALLSIGN_PIXEL_W
multi_global_options Multi_options_g
char short_callsign[CALLSIGN_LEN+1]
float Master_voice_volume
void lcl_get_language_name(char *lang_name)
uint cfread_uint(CFILE *file, int ver, uint deflt)
void cfread_string_len(char *buf, int n, CFILE *file)
Read a fixed length string that is not null-terminated, with the length stored in file...
int cfseek(CFILE *fp, int offset, int where)