1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Fix performance issue related to TurnInfo construction

This commit is contained in:
Andrii Danylchenko
2022-05-15 11:39:06 +03:00
committed by Andrii Danylchenko
parent b061c4988c
commit 31c9d6e28d
4 changed files with 21 additions and 4 deletions

View File

@@ -290,10 +290,13 @@ bool CCreature::isItNativeTerrain(ETerrainType::EETerrainType terrain) const
ETerrainType::EETerrainType CCreature::getNativeTerrain() const
{
const std::string cachingStringBlocksRetaliation = "type_NO_TERRAIN_PENALTY";
static const auto selectorBlocksRetaliation = Selector::type()(Bonus::NO_TERRAIN_PENALTY);
//this code is used in the CreatureTerrainLimiter::limit to setup battle bonuses
//and in the CGHeroInstance::getNativeTerrain() to setup mevement bonuses or/and penalties.
return hasBonusOfType(Bonus::NO_TERRAIN_PENALTY) ?
ETerrainType::ANY_TERRAIN
return hasBonus(selectorBlocksRetaliation, selectorBlocksRetaliation)
? ETerrainType::ANY_TERRAIN
: (ETerrainType::EETerrainType)(*VLC->townh)[faction]->nativeTerrain;
}