From 707cbd728f362ef80afe5a95f713908796743cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Hinrichs?= Date: Fri, 13 Oct 2006 19:33:45 +0000 Subject: [PATCH] [[Fixes for bug #7245 and bug #6937]] fixes bug #7245 (stats in replay counted not from 0) and #6937 (at replay end shows the scenario objectives). Also prevents to be thrown back to the title screen if replay ends with victory or defeat. --- src/menu_events.cpp | 4 ++-- src/menu_events.hpp | 2 +- src/play_controller.cpp | 2 +- src/replay_controller.cpp | 11 +++++++++++ src/replay_controller.hpp | 1 + 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/menu_events.cpp b/src/menu_events.cpp index e8bfbfaa972..cb152469c5f 100644 --- a/src/menu_events.cpp +++ b/src/menu_events.cpp @@ -153,9 +153,9 @@ namespace events{ teams_[team_num - 1].reset_objectives_changed(); } - void menu_handler::show_statistics() + void menu_handler::show_statistics(const unsigned int team_num) { - const statistics::stats& stats = statistics::calculate_stats(0,gui_->viewing_team()+1); + const statistics::stats& stats = statistics::calculate_stats(0, team_num); std::vector items; { diff --git a/src/menu_events.hpp b/src/menu_events.hpp index 88a3908d3de..ef257efa038 100644 --- a/src/menu_events.hpp +++ b/src/menu_events.hpp @@ -68,7 +68,7 @@ public: void set_gui(display* gui) { gui_ = gui; } void objectives(const unsigned int team_num); - void show_statistics(); + void show_statistics(const unsigned int team_num); void unit_list(); void status_table(); void save_game(const std::string& message, gui::DIALOG_TYPE dialog_type, const bool has_exit_button=false); diff --git a/src/play_controller.cpp b/src/play_controller.cpp index 50e87afea75..9a97ffc1c3d 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -186,7 +186,7 @@ void play_controller::objectives(){ } void play_controller::show_statistics(){ - menu_handler_.show_statistics(); + menu_handler_.show_statistics(gui_->viewing_team()+1); } void play_controller::unit_list(){ diff --git a/src/replay_controller.cpp b/src/replay_controller.cpp index f7e7d5f370d..1b6408e8d58 100644 --- a/src/replay_controller.cpp +++ b/src/replay_controller.cpp @@ -84,6 +84,7 @@ void replay_controller::init(){ fire_prestart(true); init_gui(); + statistics::fresh_stats(); LOG_NG << "first_time..." << (recorder.is_skipping() ? "skipping" : "no skip") << "\n"; @@ -103,6 +104,7 @@ void replay_controller::init_gui(){ for(std::vector::iterator t = teams_.begin(); t != teams_.end(); ++t) { t->set_fog(false); t->set_shroud(false); + t->reset_objectives_changed(); } } @@ -153,6 +155,7 @@ void replay_controller::reset_replay(){ status_ = status_start_; gamestate_ = gamestate_start_; teams_ = team_manager_.clone(teams_start_); + statistics::fresh_stats(); if (events_manager_ != NULL){ delete events_manager_; events_manager_ = new game_events::manager(level_,*gui_,map_,units_,teams_, @@ -275,6 +278,10 @@ void replay_controller::play_side(const unsigned int team_index, bool){ { is_playing_ = false; } + catch(end_level_exception& e){ + //VICTORY/DEFEAT end_level_exception shall not return to title screen + if ((e.result != VICTORY) && (e.result != DEFEAT)) { throw e; } + } player_number_++; @@ -315,6 +322,10 @@ void replay_controller::preferences(){ update_gui(); } +void replay_controller::show_statistics(){ + menu_handler_.show_statistics(gui_->playing_team()+1); +} + bool replay_controller::can_execute_command(hotkey::HOTKEY_COMMAND command) const { bool result = play_controller::can_execute_command(command); diff --git a/src/replay_controller.hpp b/src/replay_controller.hpp index bc30b3eae2d..3759d959cce 100644 --- a/src/replay_controller.hpp +++ b/src/replay_controller.hpp @@ -50,6 +50,7 @@ public: //event handlers virtual void preferences(); + virtual void show_statistics(); void play_replay(); void reset_replay(); void stop_replay();