1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

Added check for validness of native terrain

This commit is contained in:
Ivan Savenko 2023-05-15 22:22:42 +03:00
parent c45d4f8d22
commit 4f739d426d

View File

@ -19,6 +19,7 @@
#include "CHeroHandler.h" #include "CHeroHandler.h"
#include "CArtHandler.h" #include "CArtHandler.h"
#include "GameSettings.h" #include "GameSettings.h"
#include "TerrainHandler.h"
#include "spells/CSpellHandler.h" #include "spells/CSpellHandler.h"
#include "filesystem/Filesystem.h" #include "filesystem/Filesystem.h"
#include "mapObjects/CObjectClassesHandler.h" #include "mapObjects/CObjectClassesHandler.h"
@ -1035,6 +1036,11 @@ CFaction * CTownHandler::loadFromJson(const std::string & scope, const JsonNode
{ {
VLC->modh->identifiers.requestIdentifier("terrain", source["nativeTerrain"], [=](int32_t index){ VLC->modh->identifiers.requestIdentifier("terrain", source["nativeTerrain"], [=](int32_t index){
faction->nativeTerrain = TerrainId(index); faction->nativeTerrain = TerrainId(index);
auto const & terrain = VLC->terrainTypeHandler->getById(faction->nativeTerrain);
if (!terrain->isSurface() && !terrain->isUnderground())
logMod->warn("Faction %s has terrain %s as native, but terrain is not suitable for either surface or subterranean layers!", faction->getJsonKey(), terrain->getJsonKey());
}); });
} }