1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

vcmi: add getNativeTerrain method to factions

This commit is contained in:
Konstantin 2023-04-02 03:07:39 +03:00
parent e0715a76c8
commit b7d6270272
4 changed files with 10 additions and 2 deletions

View File

@ -15,12 +15,14 @@
VCMI_LIB_NAMESPACE_BEGIN
class FactionID;
enum class ETerrainId;
template<typename T> class Identifier;
class DLL_LINKAGE Faction : public EntityT<FactionID>
{
public:
virtual bool hasTown() const = 0;
virtual Identifier<ETerrainId> getNativeTerrain() const = 0;
};
VCMI_LIB_NAMESPACE_END

View File

@ -335,7 +335,7 @@ TerrainId CCreature::getNativeTerrain() const
//and in the CGHeroInstance::getNativeTerrain() to setup movement bonuses or/and penalties.
return hasBonus(selectorNoTerrainPenalty, cachingStringNoTerrainPenalty)
? TerrainId(ETerrainId::ANY_TERRAIN)
: (*VLC->townh)[faction]->nativeTerrain;
: VLC->factions()->getByIndex(faction)->getNativeTerrain();
}
void CCreature::updateFrom(const JsonNode & data)

View File

@ -161,6 +161,11 @@ bool CFaction::hasTown() const
return town != nullptr;
}
TerrainId CFaction::getNativeTerrain() const
{
return nativeTerrain;
}
void CFaction::updateFrom(const JsonNode & data)
{

View File

@ -217,6 +217,7 @@ public:
std::string getNameTextID() const override;
bool hasTown() const override;
TerrainId getNativeTerrain() const override;
void updateFrom(const JsonNode & data);
void serializeJson(JsonSerializeFormat & handler);