Check if the save_version is sane before comparing with it

This commit is contained in:
Alexander van Gessel 2013-12-05 19:43:38 +01:00
parent 62b17ea33f
commit 416ab3c281

View file

@ -657,6 +657,16 @@ void loadgame::check_version_compatibility()
const version_info save_version = gamestate_.classification().version;
const version_info &wesnoth_version = game_config::wesnoth_version;
// If the version isn't good, it probably isn't a compatible stable one,
// and the following comparisons would throw.
if (!save_version.good()) {
const std::string message = _("The save has corrupt version information ($version_number|) and cannot be loaded.");
utils::string_map symbols;
symbols["version_number"] = gamestate_.classification().version;
gui2::show_error_message(gui_.video(), utils::interpolate_variables_into_string(message, &symbols));
throw load_game_cancelled_exception();
}
// Even minor version numbers indicate stable releases which are
// compatible with each other.
if (wesnoth_version.minor_version() % 2 == 0 &&