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

doMoveHero: only allow to stop at accessible or land/sail nodes

This commit is contained in:
ArseniyShestakov 2015-11-17 17:46:26 +03:00
parent ab9680a7d9
commit 511bb54644

View File

@ -2642,7 +2642,18 @@ void CPlayerInterface::doMoveHero(const CGHeroInstance * h, CGPath path)
ETerrainType newTerrain;
int sh = -1;
for(i=path.nodes.size()-1; i>0 && (stillMoveHero.data == CONTINUE_MOVE); i--)
auto canStop = [&](CGPathNode * node) -> bool
{
if(node->layer == EPathfindingLayer::LAND || node->layer == EPathfindingLayer::SAIL)
return true;
if(node->accessible == CGPathNode::ACCESSIBLE)
return true;
return false;
};
for(i=path.nodes.size()-1; i>0 && (stillMoveHero.data == CONTINUE_MOVE || !canStop(&path.nodes[i])); i--)
{
int3 currentCoord = path.nodes[i].coord;
int3 nextCoord = path.nodes[i-1].coord;