Fix #2852: Reset statistics when rewinding a replay to the beginning.
Currently, while watching a replay of Scenario N, the statistics dialog has the following options: - All scenarios - S1 - S2 - ... - SN - SN The last option shows the statistics of Scenario N from the beginning through the current point in the replay. The other options show end-of-scenario stats of each scenario and the cumulative stats of all scenarios through the end of SN. This patch causes the stats shown by the the second SN option to reset to zero when the "reset replay" ("stop") button is selected.
This commit is contained in:
parent
5502f7abe0
commit
d3c1cc43e7
3 changed files with 14 additions and 0 deletions
|
@ -203,6 +203,10 @@ void playsingle_controller::play_scenario_main_loop()
|
|||
for(std::size_t i = 0; i < local_players.size(); ++i) {
|
||||
local_players[i] = gamestate().board_.teams()[i].is_local();
|
||||
}
|
||||
if(!ex.start_replay) {
|
||||
// TODO: is this also needed when start_replay is true?
|
||||
statistics::reset_current_scenario();
|
||||
}
|
||||
reset_gamestate(*ex.level, (*ex.level)["replay_pos"]);
|
||||
for(std::size_t i = 0; i < local_players.size(); ++i) {
|
||||
resources::gameboard->teams()[i].set_local(local_players[i]);
|
||||
|
|
|
@ -651,6 +651,13 @@ void clear_current_scenario()
|
|||
}
|
||||
}
|
||||
|
||||
void reset_current_scenario()
|
||||
{
|
||||
assert(!master_stats.empty());
|
||||
master_stats.back().team_stats = {};
|
||||
mid_scenario = false;
|
||||
}
|
||||
|
||||
int sum_str_int_map(const stats::str_int_map& m)
|
||||
{
|
||||
int res = 0;
|
||||
|
|
|
@ -106,7 +106,10 @@ namespace statistics
|
|||
void write_stats(config_writer &out);
|
||||
void read_stats(const config& cfg);
|
||||
void fresh_stats();
|
||||
/// Delete the current scenario from the stats.
|
||||
void clear_current_scenario();
|
||||
/// Reset the stats of the current scenario to the beginning.
|
||||
void reset_current_scenario();
|
||||
|
||||
void reset_turn_stats(const std::string & save_id);
|
||||
stats calculate_stats(const std::string & save_id);
|
||||
|
|
Loading…
Add table
Reference in a new issue