diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 6df9e1ae3..f915aa7aa 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -73,6 +73,7 @@ Engine fixes: * Fixed books not closing properly when trying to load another book with an invalid filename. * Fixed combat text being shown for zero damage reflect. * Added validation to player XP table parsing to ensure that XP thresholds are not less than those for previous levels. +* Errors in saved fog-of-war data no longer causes a forced exit & mod reset. * Android: Fix 'Flare' directory not being automatically created. * Android: Added a dialog to direct the player to the wiki page for installing if no game data is found. diff --git a/src/Map.cpp b/src/Map.cpp index 1333c3d18..53fecb566 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -159,7 +159,19 @@ int Map::load(const std::string& fname) { if (infile.open(ss.str(), !FileParser::MOD_FILE, FileParser::ERROR_NORMAL)) { while (infile.next()) { if (infile.section == "layer") { - loadLayer(infile); + if (!loadLayer(infile, !EXIT_ON_FAIL)) { + for (size_t i = layers.size(); i > 0; i--) { + if (layernames[i] == "fow_fog") { + layernames.erase(layernames.begin() + i); + layers.erase(layers.begin() + i); + } + else if (layernames[i] == "fow_dark") { + layernames.erase(layernames.begin() + i); + layers.erase(layers.begin() + i); + } + } + break; + } } } infile.close(); @@ -248,7 +260,7 @@ void Map::loadHeader(FileParser &infile) { } } -void Map::loadLayer(FileParser &infile) { +bool Map::loadLayer(FileParser &infile, bool exit_on_fail) { if (infile.key == "type") { // @ATTR layer.type|string|Map layer type. layers.resize(layers.size()+1); @@ -262,9 +274,12 @@ void Map::loadLayer(FileParser &infile) { // @ATTR layer.format|string|Format for map layer, must be 'dec' if (infile.val != "dec") { infile.error("Map: The format of a layer must be 'dec'!"); - Utils::logErrorDialog("Map: The format of a layer must be 'dec'!"); - mods->resetModConfig(); - Utils::Exit(1); + if (exit_on_fail) { + Utils::logErrorDialog("Map: The format of a layer must be 'dec'!"); + mods->resetModConfig(); + Utils::Exit(1); + } + return false; } } else if (infile.key == "data") { @@ -285,8 +300,11 @@ void Map::loadLayer(FileParser &infile) { } if (comma_count != w) { infile.error("Map: A row of layer data has a width not equal to %d.", w); - mods->resetModConfig(); - Utils::Exit(1); + if (exit_on_fail) { + mods->resetModConfig(); + Utils::Exit(1); + } + return false; } for (int i=0; i -Version VersionInfo::ENGINE(1, 14, 91); +Version VersionInfo::ENGINE(1, 14, 92); Version VersionInfo::MIN(0, 0, 0); Version VersionInfo::MAX(USHRT_MAX, USHRT_MAX, USHRT_MAX);