1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-11 11:31:52 +02:00

Merge pull request #1772 from vcmi/fix_invalid_native_terrain

Fix the case of invalid native town type
This commit is contained in:
Andrii Danylchenko 2023-03-26 13:19:01 +03:00 committed by GitHub
commit a0de223901
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -250,8 +250,8 @@ public:
}
bool operator == (const Identifier & b) const { return num == b.num; }
bool operator <= (const Identifier & b) const { return num >= b.num; }
bool operator >= (const Identifier & b) const { return num <= b.num; }
bool operator <= (const Identifier & b) const { return num <= b.num; }
bool operator >= (const Identifier & b) const { return num >= b.num; }
bool operator != (const Identifier & b) const { return num != b.num; }
bool operator < (const Identifier & b) const { return num < b.num; }
bool operator > (const Identifier & b) const { return num > b.num; }

View File

@ -130,7 +130,17 @@ void initTerrainType(Zone & zone, CMapGenerator & gen)
{
if(zone.isMatchTerrainToTown() && zone.getTownType() != ETownType::NEUTRAL)
{
zone.setTerrainType((*VLC->townh)[zone.getTownType()]->nativeTerrain);
auto terrainType = (*VLC->townh)[zone.getTownType()]->nativeTerrain;
if (terrainType <= ETerrainId::NONE)
{
logGlobal->warn("Town %s has invalid terrain type: %d", zone.getTownType(), terrainType);
zone.setTerrainType(ETerrainId::DIRT);
}
else
{
zone.setTerrainType(terrainType);
}
}
else
{