Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion code/cmdline/cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ int Cmdline_cd_check = 1;
int Cmdline_closed_game = 0;
int Cmdline_freespace_no_music = 0;
int Cmdline_freespace_no_sound = 0;
int Cmdline_gimme_all_medals = 0;
int Cmdline_mouse_coords = 0;
int Cmdline_multi_log = 0;
int Cmdline_multi_stream_chat_to_file = 0;
Expand Down
1 change: 0 additions & 1 deletion code/cmdline/cmdline.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ extern int Cmdline_cd_check;
extern int Cmdline_closed_game;
extern int Cmdline_freespace_no_music;
extern int Cmdline_freespace_no_sound;
extern int Cmdline_gimme_all_medals;
extern int Cmdline_mouse_coords;
extern int Cmdline_multi_log;
extern int Cmdline_multi_stream_chat_to_file;
Expand Down
18 changes: 10 additions & 8 deletions code/menuui/barracks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,14 @@ void barracks_init_stats(scoring_struct *stats)
Assert(Num_stat_lines < Max_stat_lines);

// Goober5000 - in case above Assert isn't triggered (such as in non-debug builds)
if (Num_stat_lines >= Max_stat_lines)
if (Num_stat_lines < Max_stat_lines)
{
break;
Assert(strlen(it->name) + 1 < STAT_COLUMN1_W);
sprintf(Stat_labels[Num_stat_lines], NOX("%s:"), it->name);
sprintf(Stats[Num_stat_lines], "%d", stats->kills[i]);
Num_stat_lines++;
}

Assert(strlen(it->name) + 1 < STAT_COLUMN1_W);
sprintf(Stat_labels[Num_stat_lines], NOX("%s:"), it->name);
sprintf(Stats[Num_stat_lines], "%d", stats->kills[i]);
Num_stat_lines++;

// work out the total score from ship kills
score_from_kills += stats->kills[i] * it->score;
}
Expand Down Expand Up @@ -564,7 +562,11 @@ int barracks_new_pilot_selected()

// init stuff to reflect new pilot
int i;
barracks_init_stats(&Cur_pilot->stats);
scoring_struct pstats;

Pilot.export_stats(&pstats);
barracks_init_stats(&pstats);

strcpy_s(stripped, Cur_pilot->image_filename);
barracks_strip_pcx(stripped);
for (i=0; i<Num_pilot_images; i++) {
Expand Down
40 changes: 9 additions & 31 deletions code/missionui/missiondebrief.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ UI_XSTR Debrief_strings[GR_NUM_RESOLUTIONS][NUM_DEBRIEF_TEXT] = {


char Debrief_current_callsign[CALLSIGN_LEN+10];
player *Debrief_player;

static UI_WINDOW Debrief_ui_window;
static UI_BUTTON List_region;
Expand Down Expand Up @@ -1119,7 +1118,6 @@ void debrief_multi_list_init()
// switch stats display to this newly selected player
set_player_stats(Multi_list[0].net_player_index);
strcpy_s(Debrief_current_callsign, Multi_list[0].callsign);
Debrief_player = Player;
}

void debrief_multi_list_scroll_up()
Expand Down Expand Up @@ -1172,7 +1170,6 @@ void debrief_multi_list_draw()
// switch stats display to this newly selected player
set_player_stats(Multi_list[idx].net_player_index);
strcpy_s(Debrief_current_callsign, Multi_list[idx].callsign);
Debrief_player = Net_players[Multi_list[idx].net_player_index].m_player;
break;
}
}
Expand Down Expand Up @@ -1510,24 +1507,16 @@ void debrief_stats_render()

switch ( Current_stage ) {
case DEBRIEF_MISSION_STATS:
i = Current_stage - 1;
if ( i < 0 )
i = 0;

// display mission completion time
debrief_render_mission_time(y);

y += 2*font_height;
show_stats_label(i, 0, y, font_height);
show_stats_numbers(i, Debrief_text_x2[gr_screen.res], y, font_height);

show_stats_label(StatsType::MISSION_STATS, 0, y, font_height);
show_stats_numbers(StatsType::MISSION_STATS, Debrief_text_x2[gr_screen.res], y, font_height);
break;
case DEBRIEF_ALLTIME_STATS:
i = Current_stage - 1;
if ( i < 0 )
i = 0;

show_stats_label(i, 0, y, font_height);
show_stats_numbers(i, Debrief_text_x2[gr_screen.res], y, font_height);
show_stats_label(StatsType::ALL_TIME_EVER_STATS, 0, y, font_height);
show_stats_numbers(StatsType::ALL_TIME_EVER_STATS, Debrief_text_x2[gr_screen.res], y, font_height);
break;

case DEBRIEF_ALLTIME_KILLS:
Expand Down Expand Up @@ -1719,8 +1708,6 @@ void debrief_button_pressed(int num)
void debrief_setup_ship_kill_stats(int /*stage_num*/)
{
int i;
//ushort *kill_arr;
int *kill_arr; //DTP max ships
debrief_stats_kill_info *kill_info;

Assert(Current_stage < DEBRIEF_NUM_STATS_PAGES);
Expand All @@ -1732,29 +1719,23 @@ void debrief_setup_ship_kill_stats(int /*stage_num*/)
Debrief_stats_kills = new debrief_stats_kill_info[Ship_info.size()];
}

Assert(Debrief_player != NULL);

// kill_ar points to an array of MAX_SHIP_TYPE ints
if ( Current_stage == DEBRIEF_MISSION_KILLS ) {
kill_arr = Debrief_player->stats.m_okKills;
} else {
kill_arr = Debrief_player->stats.kills;
}
auto stats_type = ( Current_stage == DEBRIEF_MISSION_KILLS ) ? StatsType::MISSION_STATS : StatsType::ALL_TIME_EVER_STATS;

Num_text_lines = 0;
i = 0;
for ( auto it = Ship_info.begin(); it != Ship_info.end(); i++, ++it ) {
int num_kills = stats_get_kills(stats_type, i);

// code used to add in mission kills, but the new system assumes that the player will accept, so
// all time stats already have mission stats added in.
if ( kill_arr[i] <= 0 ){
if ( num_kills <= 0 ){
continue;
}


kill_info = &Debrief_stats_kills[Num_text_lines++];

kill_info->num = kill_arr[i];
kill_info->num = num_kills;

strcpy_s(kill_info->text, it->name);
strcat_s(kill_info->text, NOX(":"));
Expand Down Expand Up @@ -1786,7 +1767,6 @@ void debrief_check_buttons()
// switch stats display to this newly selected player
set_player_stats(Multi_list[z].net_player_index);
strcpy_s(Debrief_current_callsign, Multi_list[z].callsign);
Debrief_player = Net_players[Multi_list[z].net_player_index].m_player;
Multi_list_select = z;
debrief_setup_ship_kill_stats(Current_stage);
gamesnd_play_iface(InterfaceSounds::USER_SELECT);
Expand Down Expand Up @@ -1976,8 +1956,6 @@ void debrief_init(bool API_Access)
// rank_bitmaps_load();

strcpy_s(Debrief_current_callsign, Player->callsign);
Debrief_player = Player;
// Debrief_current_net_player_index = debrief_multi_list[0].net_player_index;

// Only setup Debrief_stages and Recommendations if not running through API access.
if (!API_Access) {
Expand Down
64 changes: 61 additions & 3 deletions code/pilotfile/pilotfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ void pilotfile::set_multi_stats(const scoring_struct *stats)
size_t idx;
index_list_t ilist;


multi_stats.score = stats->score;
multi_stats.rank = stats->rank;
multi_stats.assists = stats->assists;
Expand All @@ -325,12 +324,11 @@ void pilotfile::set_multi_stats(const scoring_struct *stats)
multi_stats.s_shots_hit = stats->s_shots_hit;
multi_stats.s_bonehead_hits = stats->s_bonehead_hits;

multi_stats.flight_time = stats->flight_time;
multi_stats.missions_flown = stats->missions_flown;
multi_stats.flight_time = stats->flight_time;
multi_stats.last_flown = stats->last_flown;
multi_stats.last_backup = stats->last_backup;


// ship kills
multi_stats.ship_kills.clear();
multi_stats.ship_kills.shrink_to_fit();
Expand Down Expand Up @@ -401,4 +399,64 @@ void pilotfile::reset_stats()
ss_stats[i]->ship_kills.clear();
ss_stats[i]->medals_earned.clear();
}
}

/**
* @brief Export stats to given scoring struct, sanitized for current mod data
*
* @param[out] stats Scoring struct for exported data
*
* @returns true if stats were exported successfully
*/
bool pilotfile::export_stats(scoring_struct *stats)
{
scoring_special_t *p_stats = nullptr;

if ( !stats ) {
return false;
}

stats->init();

if (Game_mode & GM_MULTIPLAYER) {
p_stats = &multi_stats;
} else {
p_stats = &all_time_stats;
}

stats->score = p_stats->score;
stats->rank = p_stats->rank;
stats->assists = p_stats->assists;
stats->kill_count = p_stats->kill_count;
stats->kill_count_ok = p_stats->kill_count_ok;
stats->bonehead_kills = p_stats->bonehead_kills;

stats->p_shots_fired = p_stats->p_shots_fired;
stats->p_shots_hit = p_stats->p_shots_hit;
stats->p_bonehead_hits = p_stats->p_bonehead_hits;

stats->s_shots_fired = p_stats->s_shots_fired;
stats->s_shots_hit = p_stats->s_shots_hit;
stats->s_bonehead_hits = p_stats->s_bonehead_hits;

stats->missions_flown = p_stats->missions_flown;
stats->flight_time = p_stats->flight_time;
stats->last_flown = p_stats->last_flown;
stats->last_backup = p_stats->last_backup;

// only export ships that this mod knows about (should already be index)
for (auto &item : p_stats->ship_kills) {
if ( (item.index >= 0) && (item.index < MAX_SHIP_CLASSES) ) {
stats->kills[item.index] = item.val;
}
}

// same for medals
for (auto &item : p_stats->medals_earned) {
if ( SCP_vector_inbounds(stats->medal_counts, item.index) ) {
stats->medal_counts[item.index] = item.val;
}
}

return true;
}
9 changes: 9 additions & 0 deletions code/pilotfile/pilotfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ class pilotfile {
void set_multi_stats(const scoring_struct *stats);
void reset_stats();

/**
* @brief Export stats to given scoring struct, sanitized for current mod data
*
* @param[out] stats Scoring struct for exported data
*
* @returns true if stats were exported successfully
*/
bool export_stats(scoring_struct *stats);

/**
* Verifies a pilot file with the given filename
*
Expand Down
Loading