1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

#2689 - fix approaching guards when closest tile is double-guarded

This commit is contained in:
Andrii Danylchenko 2023-09-16 12:29:35 +03:00 committed by Andrii Danylchenko
parent 717a765123
commit 903be33bf3
3 changed files with 9 additions and 2 deletions

View File

@ -455,6 +455,11 @@ bool CPathfinderHelper::passOneTurnLimitCheck(const PathNodeInfo & source) const
return true;
}
int CPathfinderHelper::getGuardiansCount(int3 tile) const
{
return getGuardingCreatures(tile).size();
}
CPathfinderHelper::CPathfinderHelper(CGameState * gs, const CGHeroInstance * Hero, const PathfinderOptions & Options):
CGameInfoCallback(gs),
turn(-1),

View File

@ -121,6 +121,8 @@ public:
int movementPointsAfterEmbark(int movement, int basicCost, bool disembark) const;
bool passOneTurnLimitCheck(const PathNodeInfo & source) const;
int getGuardiansCount(int3 tile) const;
};
VCMI_LIB_NAMESPACE_END

View File

@ -298,8 +298,8 @@ PathfinderBlockingRule::BlockingReason MovementToDestinationRule::getBlockingRea
if(source.guarded)
{
if(!(pathfinderConfig->options.originalMovementRules && source.node->layer == EPathfindingLayer::AIR) &&
!destination.isGuardianTile) // Can step into tile of guard
if(!(pathfinderConfig->options.originalMovementRules && source.node->layer == EPathfindingLayer::AIR)
&& (!destination.isGuardianTile || pathfinderHelper->getGuardiansCount(source.coord) > 1)) // Can step into tile of guard
{
return BlockingReason::SOURCE_GUARDED;
}