1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Correctly show results of CreatureTerrainLimiter outside of combat

This commit is contained in:
Ivan Savenko
2025-04-13 22:23:12 +03:00
parent 975d9aedc9
commit 2b812be9cd
7 changed files with 59 additions and 14 deletions

View File

@@ -76,7 +76,6 @@ void CStack::localInit(BattleInfo * battleInfo)
attachTo(*army);
attachToSource(*typeID.toCreature());
}
nativeTerrain = getNativeTerrain(); //save nativeTerrain in the variable on the battle start to avoid dead lock
CUnitState::localInit(this); //it causes execution of the CStack::isOnNativeTerrain where nativeTerrain will be considered
position = initialPosition;
}
@@ -316,14 +315,13 @@ bool CStack::canBeHealed() const
bool CStack::isOnNativeTerrain() const
{
//this code is called from CreatureTerrainLimiter::limit on battle start
auto res = nativeTerrain == ETerrainId::ANY_TERRAIN || nativeTerrain == battle->getTerrainType();
return res;
auto nativeTerrain = getNativeTerrain();
return nativeTerrain == ETerrainId::ANY_TERRAIN || getCurrentTerrain() == nativeTerrain;
}
bool CStack::isOnTerrain(TerrainId terrain) const
TerrainId CStack::getCurrentTerrain() const
{
return battle->getTerrainType() == terrain;
return battle->getTerrainType();
}
const CCreature * CStack::unitType() const