Fixed animation-wide text_color and blend_color keys being overwritten

Regression from a0199c73f9. This should fix
an issue where levein/levelout fading was sometimes black instead of white.

(cherry-picked from commit 27d0a6f6fe)
This commit is contained in:
Charles Dang 2018-05-24 13:35:25 +11:00
parent b67fd6d96d
commit 94d28391a6
2 changed files with 19 additions and 12 deletions

View file

@ -198,6 +198,7 @@
* Added deprecation notices for several macros that had them missing before.
* [message] no longer scrolls to units through fog or shroud so it matches
1.12's behavior.
* Fixed animation-wide text_color and blend_color keys being overwritten
## Version 1.13.12
### Security fixes

View file

@ -90,12 +90,15 @@ frame_builder::frame_builder(const config& cfg,const std::string& frame_string)
primary_frame_ = cfg[frame_string + "primary"].to_bool();
}
try {
text_color_ = color_t::from_rgb_string(cfg[frame_string + "text_color"]);
} catch(const std::invalid_argument& e) {
// Might be thrown either due to an incorrect number of elements or std::stoul failure.
ERR_NG << "Invalid RBG text color in unit animation: " << cfg[frame_string + "text_color"].str()
<< "\n" << e.what() << "\n;";
const auto& text_color_key = cfg[frame_string + "text_color"];
if(!text_color_key.empty()) {
try {
text_color_ = color_t::from_rgb_string(text_color_key);
} catch(const std::invalid_argument& e) {
// Might be thrown either due to an incorrect number of elements or std::stoul failure.
ERR_NG << "Invalid RBG text color in unit animation: " << text_color_key.str()
<< "\n" << e.what() << "\n;";
}
}
if(const config::attribute_value* v = cfg.get(frame_string + "duration")) {
@ -112,12 +115,15 @@ frame_builder::frame_builder(const config& cfg,const std::string& frame_string)
duration_ = std::max(duration_, 1);
try {
blend_with_ = color_t::from_rgb_string(cfg[frame_string + "blend_color"]);
} catch(const std::invalid_argument& e) {
// Might be thrown either due to an incorrect number of elements or std::stoul failure.
ERR_NG << "Invalid RBG blend color in unit animation: " << cfg[frame_string + "blend_color"].str()
<< "\n" << e.what() << "\n;";
const auto& blend_color_key = cfg[frame_string + "blend_color"];
if(!blend_color_key.empty()) {
try {
blend_with_ = color_t::from_rgb_string(blend_color_key);
} catch(const std::invalid_argument& e) {
// Might be thrown either due to an incorrect number of elements or std::stoul failure.
ERR_NG << "Invalid RBG blend color in unit animation: " << blend_color_key.str()
<< "\n" << e.what() << "\n;";
}
}
}