diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index 3279a5db6..62159e70b 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -3399,6 +3399,22 @@ bool CPathfinder::isDestinationGuardian() return getSourceGuardPosition() == dp->coord; } +bool CPathfinder::checkDestinationTile() +{ + if(dp->accessible == CGPathNode::ACCESSIBLE) + return true; + if(dp->coord == CGHeroInstance::convertPosition(hero->pos, false)) + return true; // This one is tricky, we can ignore fact that tile is not ACCESSIBLE in case if it's our hero block it. Though this need investigation + if(dp->accessible == CGPathNode::VISITABLE && CGTeleport::isTeleport(dt->topVisitableObj())) + return true; // For now we'll walways allos transit for teleports + if(useEmbarkCost && allowEmbarkAndDisembark) + return true; + if(isDestinationGuarded() && !isSourceGuarded()) + return true; // Can step into a hostile tile once + + return false; +} + void CPathfinder::calculatePaths() { bool flying = hero->hasBonusOfType(Bonus::FLYING_MOVEMENT); @@ -3479,22 +3495,6 @@ void CPathfinder::calculatePaths() dp->turns = turnAtNextTile; dp->theNodeBefore = cp; - auto checkDestinationTile = [&]() -> bool - { - if(dp->accessible == CGPathNode::ACCESSIBLE) - return true; - if(dp->coord == CGHeroInstance::convertPosition(hero->pos, false)) - return true; // This one is tricky, we can ignore fact that tile is not ACCESSIBLE in case if it's our hero block it. Though this need investigation - if(dp->accessible == CGPathNode::VISITABLE && CGTeleport::isTeleport(dt->topVisitableObj())) - return true; // For now we'll walways allos transit for teleports - if(useEmbarkCost && allowEmbarkAndDisembark) - return true; - if(isDestinationGuarded() && !isSourceGuarded()) - return true; // Can step into a hostile tile once - - return false; - }; - if(checkDestinationTile()) mq.push_back(dp); } diff --git a/lib/CGameState.h b/lib/CGameState.h index 0ca0e9ef6..e0c2be6a8 100644 --- a/lib/CGameState.h +++ b/lib/CGameState.h @@ -315,6 +315,8 @@ private: void getNeighbours(const int3 &coord); void getTeleportExits(bool noTeleportExcludes = false); + bool checkDestinationTile(); + CGPathNode::EAccessibility evaluateAccessibility(const TerrainTile *tinfo) const; bool canMoveBetween(const int3 &a, const int3 &b) const; //checks only for visitable objects that may make moving between tiles impossible, not other conditions (like tiles itself accessibility)