From 7fa4fe483c755da3aea731da9667cb03f7598fb9 Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Sat, 31 Aug 2024 16:44:22 -0400 Subject: [PATCH] Remove display::team_valid It's already checked when it's set --- src/display.cpp | 5 ----- src/display.hpp | 2 -- src/game_display.cpp | 9 +-------- src/menu_events.cpp | 2 +- src/units/drawer.cpp | 5 ----- 5 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index 5f3e9df7437..0186c75e53b 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -661,11 +661,6 @@ const display::rect_of_hexes display::hexes_under_rect(const SDL_Rect& r) const return res; } -bool display::team_valid() const -{ - return currentTeam_ < dc_->teams().size(); -} - bool display::shrouded(const map_location& loc) const { return is_blindfolded() || (dont_show_all_ && dc_->teams()[currentTeam_].shrouded(loc)); diff --git a/src/display.hpp b/src/display.hpp index 616075db36d..705a9d572f9 100644 --- a/src/display.hpp +++ b/src/display.hpp @@ -111,8 +111,6 @@ public: /** The playing team is the team whose turn it is. */ std::size_t playing_team() const { return activeTeam_; } - bool team_valid() const; - /** * The viewing team is the team currently viewing the game. It's the team whose gold and income * is shown in the top bar of the default theme. diff --git a/src/game_display.cpp b/src/game_display.cpp index f3727410636..dab50df0f22 100644 --- a/src/game_display.cpp +++ b/src/game_display.cpp @@ -347,9 +347,6 @@ void game_display::layout() { display::layout(); - if ( !team_valid() ) - return; - refresh_report("report_clock"); refresh_report("report_battery"); refresh_report("report_countdown"); @@ -629,11 +626,7 @@ void game_display::clear_attack_indicator() std::string game_display::current_team_name() const { - if (team_valid()) - { - return dc_->teams()[currentTeam_].team_name(); - } - return std::string(); + return dc_->teams()[currentTeam_].team_name(); } void game_display::begin_game() diff --git a/src/menu_events.cpp b/src/menu_events.cpp index 57240147fc4..db5ffe2ec84 100644 --- a/src/menu_events.cpp +++ b/src/menu_events.cpp @@ -829,7 +829,7 @@ void menu_handler::label_terrain(mouse_handler& mousehandler, bool team_only) void menu_handler::clear_labels() { - if(gui_->team_valid() && !board().is_observer()) { + if(!board().is_observer()) { const int res = gui2::show_message( _("Clear Labels"), _("Are you sure you want to clear map labels?"), diff --git a/src/units/drawer.cpp b/src/units/drawer.cpp index d45f69358fb..d3e0554f3ac 100644 --- a/src/units/drawer.cpp +++ b/src/units/drawer.cpp @@ -156,11 +156,6 @@ unit_drawer::unit_drawer(display& thedisp) if(const game_display* game_display = dynamic_cast(&disp)) { units_that_can_reach_goal = game_display->units_that_can_reach_goal(); } - - // This used to be checked in the drawing code, where it simply triggered skipping some logic. - // However, I think it's obsolete, and that the initialization of viewing_team_ref would already - // be undefined behavior in the situation where this assert fails. - assert(disp.team_valid()); } void unit_drawer::redraw_unit(const unit& u) const