1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Fix crash on exporting maps for translation

This commit is contained in:
Ivan Savenko
2024-10-25 21:23:11 +00:00
parent c43844706e
commit 638bc174c3
5 changed files with 21 additions and 8 deletions

View File

@@ -410,9 +410,11 @@ bool MapReaderH3M::readBool()
int8_t MapReaderH3M::readInt8Checked(int8_t lowerLimit, int8_t upperLimit)
{
int8_t result = readInt8();
assert(result >= lowerLimit);
assert(result <= upperLimit);
return std::clamp(result, lowerLimit, upperLimit);
int8_t resultClamped = std::clamp(result, lowerLimit, upperLimit);
if (result != resultClamped)
logGlobal->warn("Map contains out of range value %d! Expected %d-%d", static_cast<int>(result), static_cast<int>(lowerLimit), static_cast<int>(upperLimit));
return resultClamped;
}
uint8_t MapReaderH3M::readUInt8()