diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index f84c51fad..6df9e1ae3 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -72,6 +72,7 @@ Engine fixes: * The text for dialog options now respects the 'font_dialog' property in menus/talker.txt. * 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. * 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/EngineSettings.cpp b/src/EngineSettings.cpp index 8e53a37d8..4b9551731 100644 --- a/src/EngineSettings.cpp +++ b/src/EngineSettings.cpp @@ -1081,11 +1081,28 @@ void EngineSettings::XPTable::load() { xp_table.resize(lvl_id); xp_table[lvl_id - 1] = lvl_xp; + + // validate that XP is greater than previous levels + // corrections are done after then entire table is loaded + for (size_t i = 0; i < lvl_id - 1; ++i) { + if (xp_table[lvl_id - 1] <= xp_table[i]) { + infile.error("EngineSettings: XP for level %u is less than previous levels.", lvl_id); + break; + } + } } } infile.close(); } + // set invalid XP thresolds to valid values + for (size_t i = 1; i < xp_table.size(); ++i) { + if (xp_table[i] <= xp_table[i-1]) { + xp_table[i] = xp_table[i-1] + 1; + Utils::logInfo("EngineSettings: Setting XP for level %u to %lu.", i+1, xp_table[i]); + } + } + if (xp_table.empty()) { Utils::logError("EngineSettings: No XP table defined."); xp_table.push_back(0); diff --git a/src/Version.cpp b/src/Version.cpp index 242a73b25..5d1ca5d75 100644 --- a/src/Version.cpp +++ b/src/Version.cpp @@ -30,7 +30,7 @@ FLARE. If not, see http://www.gnu.org/licenses/ #include -Version VersionInfo::ENGINE(1, 14, 90); +Version VersionInfo::ENGINE(1, 14, 91); Version VersionInfo::MIN(0, 0, 0); Version VersionInfo::MAX(USHRT_MAX, USHRT_MAX, USHRT_MAX);