mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
doMoveHero: only allow to stop at accessible or land/sail nodes
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user