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.
This commit is contained in:
Charles Dang 2018-05-24 13:35:25 +11:00
parent c48a8e7edd
commit 27d0a6f6fe
2 changed files with 19 additions and 12 deletions

View file

@ -199,6 +199,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

@ -92,12 +92,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")) {
@ -114,12 +117,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;";
}
}
}