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

CPathfinder: use node action in isMovementAfterDestPossible checks

This commit is contained in:
ArseniyShestakov 2015-11-08 04:41:06 +03:00
parent 4973a1ec90
commit 2fb73c55e1

View File

@ -363,15 +363,12 @@ bool CPathfinder::isMovementToDestPossible()
bool CPathfinder::isMovementAfterDestPossible() bool CPathfinder::isMovementAfterDestPossible()
{ {
switch(dp->layer) switch(destAction)
{ {
case EPathfindingLayer::LAND: /// TODO: Investigate what kind of limitation is possible to apply on movement from visitable tiles
case EPathfindingLayer::SAIL: /// Likely in many cases we don't need to add visitable tile to queue when hero don't fly
if(dp->accessible == CGPathNode::ACCESSIBLE) case CGPathNode::VISIT:
return true; if(CGTeleport::isTeleport(dt->topVisitableObj()))
if(dp->coord == out.hpos)
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()))
{ {
/// For now we'll always allow transit over teleporters /// For now we'll always allow transit over teleporters
/// Transit over whirlpools only allowed when hero protected /// Transit over whirlpools only allowed when hero protected
@ -379,15 +376,18 @@ bool CPathfinder::isMovementAfterDestPossible()
if(!whirlpool || options.useTeleportWhirlpool) if(!whirlpool || options.useTeleportWhirlpool)
return true; return true;
} }
if((destAction == CGPathNode::EMBARK || destAction == CGPathNode::DISEMBARK) && options.useEmbarkAndDisembark) else
return true; return true;
break; case CGPathNode::NORMAL:
case EPathfindingLayer::AIR:
case EPathfindingLayer::WATER:
return true; return true;
break; case CGPathNode::EMBARK:
if(options.useEmbarkAndDisembark)
return true;
case CGPathNode::DISEMBARK:
if(options.useEmbarkAndDisembark && !isDestinationGuarded())
return true;
} }
return false; return false;