Skip to content

Commit

Permalink
display: Remove a use of 0-index team numbers from the API
Browse files Browse the repository at this point in the history
  • Loading branch information
jostephd committed Oct 14, 2019
1 parent 51c6559 commit 96a8d7d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
9 changes: 2 additions & 7 deletions src/display.cpp
Expand Up @@ -287,14 +287,9 @@ void display::init_flags() {
image::set_team_colors(&side_colors);
}

void display::reinit_flags_for_side(std::size_t side)
void display::reinit_flags_for_team(const team& t)
{
if (!dc_ || side >= dc_->teams().size()) {
ERR_DP << "Cannot rebuild flags for inexistent or unconfigured side " << side << '\n';
return;
}

init_flags_for_side_internal(side, dc_->teams()[side].color());
init_flags_for_side_internal(t.side() - 1, t.color());
}

void display::init_flags_for_side_internal(std::size_t n, const std::string& side_color)
Expand Down
2 changes: 1 addition & 1 deletion src/display.hpp
Expand Up @@ -641,7 +641,7 @@ class display : public video2::draw_layering
void init_flags();

/** Rebuild the flag list (not team colors) for a single side. */
void reinit_flags_for_side(std::size_t side);
void reinit_flags_for_team(const team&);
void reset_reports(reports& reports_object)
{
reports_object_ = &reports_object;
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/game_lua_kernel.cpp
Expand Up @@ -3098,7 +3098,7 @@ int game_lua_kernel::intf_set_side_id(lua_State *L)
side.set_flag(flag);
}

game_display_->reinit_flags_for_side(team_i);
game_display_->reinit_flags_for_team(side);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/scripting/lua_team.cpp
Expand Up @@ -133,7 +133,7 @@ static int impl_side_set(lua_State *L)
const auto& reinit_flag_for_team = [&L] (const team& t) -> void {
auto* disp = lua_kernel_base::get_lua_kernel<game_lua_kernel>(L).get_display();
if(disp) {
disp->reinit_flags_for_side(t.side() - 1);
disp->reinit_flags_for_team(t);
}
};
// Find the corresponding attribute.
Expand Down

0 comments on commit 96a8d7d

Please sign in to comment.