Fix editor crash when adding a new side
This commit is contained in:
parent
44219de141
commit
d1604e56a1
4 changed files with 8 additions and 8 deletions
|
@ -273,7 +273,7 @@ void display::init_flags() {
|
|||
side_colors.reserve(dc_->teams().size());
|
||||
|
||||
for(size_t i = 0; i != dc_->teams().size(); ++i) {
|
||||
std::string side_color = team::get_side_color_index(i+1);
|
||||
std::string side_color = dc_->teams()[i].color();
|
||||
side_colors.push_back(side_color);
|
||||
init_flags_for_side_internal(i, side_color);
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ void display::reinit_flags_for_side(size_t side)
|
|||
return;
|
||||
}
|
||||
|
||||
init_flags_for_side_internal(side, team::get_side_color_index(side + 1));
|
||||
init_flags_for_side_internal(side, dc_->teams()[side].color());
|
||||
}
|
||||
|
||||
void display::init_flags_for_side_internal(size_t n, const std::string& side_color)
|
||||
|
|
|
@ -85,7 +85,7 @@ void tunit_recruit::pre_show(twindow& window)
|
|||
string_map column;
|
||||
|
||||
std::string image_string = recruit->image() + "~RC(" + recruit->flag_rgb() + ">"
|
||||
+ team::get_side_color_index(team_.side()) + ")";
|
||||
+ team_.color() + ")";
|
||||
|
||||
int wb_gold = 0;
|
||||
if(resources::controller) {
|
||||
|
|
|
@ -204,7 +204,7 @@ static config unit_side(reports::context & rc, const unit* u)
|
|||
const team &u_team = rc.teams()[u->side() - 1];
|
||||
std::string flag_icon = u_team.flag_icon();
|
||||
std::string old_rgb = game_config::flag_rgb;
|
||||
std::string new_rgb = team::get_side_color_index(u->side());
|
||||
std::string new_rgb = u_team.color();
|
||||
std::string mods = "~RC(" + old_rgb + ">" + new_rgb + ")";
|
||||
if (flag_icon.empty())
|
||||
flag_icon = game_config::images::flag_icon;
|
||||
|
|
|
@ -545,7 +545,7 @@ void team::change_team(const std::string &name, const t_string &user_name)
|
|||
|
||||
void team::clear_caches(){
|
||||
// Reset the cache of allies for all teams
|
||||
if(!resources::gameboard->teams().empty()) {
|
||||
if(resources::gameboard) {
|
||||
for(auto& t : resources::gameboard->teams()) {
|
||||
t.enemies_.clear();
|
||||
t.ally_shroud_.clear();
|
||||
|
@ -563,7 +563,7 @@ void team::set_objectives(const t_string& new_objectives, bool silently)
|
|||
|
||||
bool team::shrouded(const map_location& loc) const
|
||||
{
|
||||
if(resources::gameboard->teams().empty())
|
||||
if(!resources::gameboard)
|
||||
return shroud_.value(loc.x+1,loc.y+1);
|
||||
|
||||
return shroud_.shared_value(ally_shroud(resources::gameboard->teams()),loc.x+1,loc.y+1);
|
||||
|
@ -577,7 +577,7 @@ bool team::fogged(const map_location& loc) const
|
|||
if ( fog_clearer_.count(loc) > 0 )
|
||||
return false;
|
||||
|
||||
if(resources::gameboard->teams().empty())
|
||||
if(!resources::gameboard)
|
||||
return fog_.value(loc.x+1,loc.y+1);
|
||||
|
||||
return fog_.shared_value(ally_fog(resources::gameboard->teams()),loc.x+1,loc.y+1);
|
||||
|
@ -838,7 +838,7 @@ std::string team::get_side_color_index(int side)
|
|||
{
|
||||
size_t index = size_t(side-1);
|
||||
|
||||
if(!resources::gameboard->teams().empty() && index < resources::gameboard->teams().size()) {
|
||||
if(resources::gameboard && index < resources::gameboard->teams().size()) {
|
||||
const std::string side_map = resources::gameboard->teams()[index].color();
|
||||
if(!side_map.empty()) {
|
||||
return side_map;
|
||||
|
|
Loading…
Add table
Reference in a new issue