diff --git a/src/actions/move.cpp b/src/actions/move.cpp index a4f0f9b420d..da7ab65d420 100644 --- a/src/actions/move.cpp +++ b/src/actions/move.cpp @@ -358,7 +358,7 @@ namespace { // Private helpers for move_unit() : spectator_(move_spectator) , skip_sighting_(skip_sightings) , skip_ally_sighting_(skip_ally_sightings) - , playing_team_is_viewing_(display::get_singleton()->playing_team_index() == display::get_singleton()->viewing_team_index() || display::get_singleton()->show_everything()) + , playing_team_is_viewing_(display::get_singleton()->viewing_team_is_playing() || display::get_singleton()->show_everything()) , route_(route) , begin_(route.begin()) , full_end_(route.end()) diff --git a/src/display.hpp b/src/display.hpp index 339b4f8eeea..0af0de84e41 100644 --- a/src/display.hpp +++ b/src/display.hpp @@ -124,6 +124,11 @@ public: const team& playing_team() const; const team& viewing_team() const; + bool viewing_team_is_playing() const + { + return viewing_team_index() == playing_team_index(); + } + /** * Sets the team controlled by the player using the computer. * Data from this team will be displayed in the game status. diff --git a/src/hotkey/hotkey_handler.cpp b/src/hotkey/hotkey_handler.cpp index d6ff7876544..f85cf8a618d 100644 --- a/src/hotkey/hotkey_handler.cpp +++ b/src/hotkey/hotkey_handler.cpp @@ -72,8 +72,6 @@ const game_state & play_controller::hotkey_handler::gamestate() const { bool play_controller::hotkey_handler::browse() const { return play_controller_.is_browsing(); } bool play_controller::hotkey_handler::linger() const { return play_controller_.is_linger_mode(); } -bool play_controller::hotkey_handler::viewing_team_is_playing() const { return gui()->viewing_team_index() == gui()->playing_team_index(); } - void play_controller::hotkey_handler::objectives(){ menu_handler_.objectives(); } diff --git a/src/hotkey/hotkey_handler.hpp b/src/hotkey/hotkey_handler.hpp index 66fa54fbefd..9307f3fe9f5 100644 --- a/src/hotkey/hotkey_handler.hpp +++ b/src/hotkey/hotkey_handler.hpp @@ -70,8 +70,6 @@ protected: bool browse() const; bool linger() const; - bool viewing_team_is_playing() const; - public: hotkey_handler(play_controller &, saved_game &); ~hotkey_handler(); diff --git a/src/hotkey/hotkey_handler_sp.cpp b/src/hotkey/hotkey_handler_sp.cpp index 54bb4abfd61..0e4937a878a 100644 --- a/src/hotkey/hotkey_handler_sp.cpp +++ b/src/hotkey/hotkey_handler_sp.cpp @@ -238,12 +238,12 @@ bool playsingle_controller::hotkey_handler::can_execute_command(const hotkey::ui case hotkey::HOTKEY_DELAY_SHROUD: return !linger() && (gui()->viewing_team().uses_fog() || gui()->viewing_team().uses_shroud()) - && viewing_team_is_playing() + && gui()->viewing_team_is_playing() && gui()->viewing_team().is_local_human() && !events::commands_disabled; case hotkey::HOTKEY_UPDATE_SHROUD: return !linger() - && viewing_team_is_playing() + && gui()->viewing_team_is_playing() && gui()->viewing_team().is_local_human() && !events::commands_disabled && gui()->viewing_team().auto_shroud_updates() == false; diff --git a/src/play_controller.cpp b/src/play_controller.cpp index d5b813694af..cd202251c46 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -1238,7 +1238,7 @@ void play_controller::check_next_scenario_is_known() { bool play_controller::can_use_synced_wml_menu() const { const team& viewing_team = gui_->viewing_team(); - return gui_->viewing_team_index() == gui_->playing_team_index() && !events::commands_disabled && viewing_team.is_local_human() + return gui_->viewing_team_is_playing() && !events::commands_disabled && viewing_team.is_local_human() && !is_browsing(); } diff --git a/src/reports.cpp b/src/reports.cpp index 55cef350e8c..8fbd8d83957 100644 --- a/src/reports.cpp +++ b/src/reports.cpp @@ -148,7 +148,7 @@ static unit_const_ptr get_selected_unit_ptr(const reports::context& rc) static config gray_inactive(const reports::context& rc, const std::string &str, const std::string& tooltip = "") { - if ( rc.screen().viewing_team().side() == rc.screen().playing_team().side() ) + if ( rc.screen().viewing_team_is_playing() ) return text_report(str, tooltip); return text_report(span_color(font::GRAY_COLOR) + str + naps, tooltip); @@ -1453,7 +1453,7 @@ REPORT_GENERATOR(gold, rc) if (rc.wb()) fake_gold -= rc.wb()->get_spent_gold_for(viewing_team.side()); char const *end = naps; - if (viewing_team.side() != rc.screen().playing_team().side()) { + if (!rc.screen().viewing_team_is_playing()) { str << span_color(font::GRAY_COLOR); } else if (fake_gold < 0) { @@ -1511,7 +1511,7 @@ REPORT_GENERATOR(income, rc) const team& viewing_team = rc.screen().viewing_team(); team_data td(rc.dc(), viewing_team); char const *end = naps; - if (viewing_team.side() != rc.screen().playing_team().side()) { + if (!rc.screen().viewing_team_is_playing()) { if (td.net_income < 0) { td.net_income = - td.net_income; str << span_color(font::GRAY_COLOR); @@ -1773,7 +1773,7 @@ REPORT_GENERATOR(report_countdown, rc) std::ostringstream str; sec = viewing_team.countdown_time() / 1000; char const *end = naps; - if (viewing_team.side() != rc.screen().playing_team().side()) + if (!rc.screen().viewing_team_is_playing()) str << span_color(font::GRAY_COLOR); else if (sec < 60) str << "";