Skip to content

Commit

Permalink
Catch exception when reading map label colors to enable loading old s…
Browse files Browse the repository at this point in the history
…aves again

Prior to the color_t conversion, labels were written to savefiles with an alpha key, despite alpha not
being accepted in color=. Because of this, this enables the loading of older saves without an exception
throwing.
  • Loading branch information
Vultraz committed Dec 10, 2016
1 parent 5b3e3a7 commit 7777766
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/map/label.cpp
Expand Up @@ -397,7 +397,14 @@ void terrain_label::read(const config &cfg)
tmp_color = utils::interpolate_variables_into_string(tmp_color, vs);

if(!tmp_color.empty()) {
color = color_t::from_rgb_string(tmp_color);
try {
color = color_t::from_rgb_string(tmp_color);
} catch(std::invalid_argument&) {
// Prior to the color_t conversion, labels were written to savefiles with an alpha key, despite alpha not
// being accepted in color=. Because of this, this enables the loading of older saves without an exception
// throwing.
color = color_t::from_rgba_string(tmp_color);
}
}

color_ = color;
Expand Down

0 comments on commit 7777766

Please sign in to comment.