mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-10 15:52:55 +00:00
display: Remove a use of 0-index team numbers from the API
This commit is contained in:
parent
51c6559d3a
commit
96a8d7d282
@ -287,14 +287,9 @@ void display::init_flags() {
|
|||||||
image::set_team_colors(&side_colors);
|
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()) {
|
init_flags_for_side_internal(t.side() - 1, t.color());
|
||||||
ERR_DP << "Cannot rebuild flags for inexistent or unconfigured side " << side << '\n';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
init_flags_for_side_internal(side, dc_->teams()[side].color());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void display::init_flags_for_side_internal(std::size_t n, const std::string& side_color)
|
void display::init_flags_for_side_internal(std::size_t n, const std::string& side_color)
|
||||||
|
@ -641,7 +641,7 @@ public:
|
|||||||
void init_flags();
|
void init_flags();
|
||||||
|
|
||||||
/** Rebuild the flag list (not team colors) for a single side. */
|
/** 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)
|
void reset_reports(reports& reports_object)
|
||||||
{
|
{
|
||||||
reports_object_ = &reports_object;
|
reports_object_ = &reports_object;
|
||||||
|
@ -3098,7 +3098,7 @@ int game_lua_kernel::intf_set_side_id(lua_State *L)
|
|||||||
side.set_flag(flag);
|
side.set_flag(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
game_display_->reinit_flags_for_side(team_i);
|
game_display_->reinit_flags_for_team(side);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ static int impl_side_set(lua_State *L)
|
|||||||
const auto& reinit_flag_for_team = [&L] (const team& t) -> void {
|
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();
|
auto* disp = lua_kernel_base::get_lua_kernel<game_lua_kernel>(L).get_display();
|
||||||
if(disp) {
|
if(disp) {
|
||||||
disp->reinit_flags_for_side(t.side() - 1);
|
disp->reinit_flags_for_team(t);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Find the corresponding attribute.
|
// Find the corresponding attribute.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user