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

Merge pull request #1835 from rilian-la-te/fix-native-type

CCreatureHandler: fix native terrain for any
This commit is contained in:
Ivan Savenko 2023-04-02 20:08:18 +03:00 committed by GitHub
commit a3074e2741
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -327,12 +327,12 @@ bool CCreature::isItNativeTerrain(TerrainId terrain) const
TerrainId CCreature::getNativeTerrain() const
{
const std::string cachingStringNoTerrainPenalty = "type_NO_TERRAIN_PENALTY";
static const auto selectorNoTerrainPenalty = Selector::type()(Bonus::NO_TERRAIN_PENALTY);
const std::string cachingStringNoTerrainPenalty = "type_NO_TERRAIN_PENALTY_sANY";
static const auto selectorNoTerrainPenalty = Selector::typeSubtype(Bonus::NO_TERRAIN_PENALTY, static_cast<int>(ETerrainId::ANY_TERRAIN));
//this code is used in the CreatureTerrainLimiter::limit to setup battle bonuses
//and in the CGHeroInstance::getNativeTerrain() to setup movement bonuses or/and penalties.
return hasBonus(selectorNoTerrainPenalty, selectorNoTerrainPenalty)
return hasBonus(selectorNoTerrainPenalty, cachingStringNoTerrainPenalty)
? TerrainId(ETerrainId::ANY_TERRAIN)
: (*VLC->townh)[faction]->nativeTerrain;
}