mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-10 13:38:41 +00:00
graceful error handling for invalid color ranges
(note: this means you must check stdout.txt for error message)
This commit is contained in:
parent
be0c4df7d0
commit
faf815ae72
@ -24,6 +24,7 @@
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
#define LOG_NG LOG_STREAM(info, engine)
|
||||
#define ERR_NG LOG_STREAM(err, engine)
|
||||
|
||||
namespace game_config
|
||||
{
|
||||
@ -225,6 +226,7 @@ namespace game_config
|
||||
team_rgb_colors.insert(std::make_pair(rgb_it->first,string2rgb(rgb_it->second)));
|
||||
} catch(bad_lexical_cast&) {
|
||||
//throw config::error(_("Invalid team color: ") + rgb_it->second);
|
||||
ERR_NG << "Invalid team color: " << rgb_it->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -238,6 +240,8 @@ namespace game_config
|
||||
team_rgb_range.insert(std::make_pair(name,color_range(string2rgb(name))));
|
||||
return color_info(name);
|
||||
} catch(bad_lexical_cast&) {
|
||||
//ERR_NG << "Invalid color range: " << name;
|
||||
//return color_info();
|
||||
throw config::error(_("Invalid color range: ") + name);
|
||||
}
|
||||
}
|
||||
@ -254,6 +258,7 @@ namespace game_config
|
||||
} catch(bad_lexical_cast&) {
|
||||
static std::vector<Uint32> stv;
|
||||
//throw config::error(_("Invalid team color: ") + name);
|
||||
ERR_NG << "Invalid team color: " << name;
|
||||
return stv;
|
||||
}
|
||||
}
|
||||
|
@ -341,9 +341,14 @@ surface locator::load_image_sub_file() const
|
||||
if("RC" == function){ //re-color function
|
||||
std::vector<std::string> recolor=utils::split(field,'>');
|
||||
if(recolor.size()>1){
|
||||
color_range const& new_color = game_config::color_info(recolor[1]);
|
||||
std::vector<Uint32> const& old_color = game_config::tc_info(recolor[0]);
|
||||
std::map<Uint32, Uint32> tmp_map = recolor_range(new_color,old_color);
|
||||
std::map<Uint32, Uint32> tmp_map;
|
||||
try {
|
||||
color_range const& new_color = game_config::color_info(recolor[1]);
|
||||
std::vector<Uint32> const& old_color = game_config::tc_info(recolor[0]);
|
||||
tmp_map = recolor_range(new_color,old_color);
|
||||
} catch (config::error& e) {
|
||||
ERR_DP << "caught config::error... " << e.message << std::endl;
|
||||
}
|
||||
for(std::map<Uint32, Uint32>::const_iterator tmp = tmp_map.begin(); tmp!= tmp_map.end(); tmp++){
|
||||
recolor_map[tmp->first] = tmp->second;
|
||||
}
|
||||
|
@ -389,6 +389,10 @@ LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config& game_
|
||||
} catch(gamemap::incorrect_format_exception& e) {
|
||||
gui::show_error_message(disp, std::string(_("The game map could not be loaded: ")) + e.msg_);
|
||||
return QUIT;
|
||||
} catch(config::error& e) {
|
||||
std::cerr << "caught config::error...\n";
|
||||
gui::show_error_message(disp, _("Error while reading the WML: ") + e.message);
|
||||
return QUIT;
|
||||
}
|
||||
|
||||
//if the scenario hasn't been set in-level, set it now.
|
||||
|
Loading…
x
Reference in New Issue
Block a user