From 68a2bb78a5d221dd278d809399666fe595149e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zieli=C5=84ski?= Date: Sat, 25 Mar 2023 18:07:44 +0100 Subject: [PATCH] Fix the case of invalid native town type :? --- lib/rmg/Functions.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/rmg/Functions.cpp b/lib/rmg/Functions.cpp index 904052995..f1600ec68 100644 --- a/lib/rmg/Functions.cpp +++ b/lib/rmg/Functions.cpp @@ -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: %s", zone.getTownType(), terrainType); + zone.setTerrainType(ETerrainId::DIRT); + } + else + { + zone.setTerrainType(terrainType); + } } else {