From 77777666de97b53b0251e79b7caf20a1cae8210a Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Sat, 10 Dec 2016 12:20:34 +1100 Subject: [PATCH] Catch exception when reading map label colors to enable loading old saves 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. --- src/map/label.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/map/label.cpp b/src/map/label.cpp index e4cde9d4a6be..6b2c8a44d454 100644 --- a/src/map/label.cpp +++ b/src/map/label.cpp @@ -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;