From 934c68273392be2cce2943b15a0c80e78c934b1e Mon Sep 17 00:00:00 2001 From: ArseniyShestakov Date: Wed, 4 Nov 2015 11:53:52 +0300 Subject: [PATCH] CPathfinder: always add air and water layer nodes to queue It's should be possible to go into air layer from visitable object (but opposite isn't allowed). And when walking on water player can't really interact with any object at all so future movement always possible. --- lib/CPathfinder.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/lib/CPathfinder.cpp b/lib/CPathfinder.cpp index 95cd4c615..0647981d1 100644 --- a/lib/CPathfinder.cpp +++ b/lib/CPathfinder.cpp @@ -265,16 +265,28 @@ bool CPathfinder::isMovementToDestPossible() bool CPathfinder::isMovementAfterDestPossible() { - 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 always allow transit for teleporters - if(useEmbarkCost && options.useEmbarkAndDisembark) - return true; - if(isDestinationGuarded() && !isSourceGuarded()) - return true; // Can step into a hostile tile once + switch (dp->layer) + { + case EPathfindingLayer::LAND: + case EPathfindingLayer::SAIL: + 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 always allow transit for teleporters + if(useEmbarkCost && options.useEmbarkAndDisembark) + return true; + if(isDestinationGuarded() && !isSourceGuarded()) + return true; // Can step into a hostile tile once + break; + + case EPathfindingLayer::AIR: + case EPathfindingLayer::WATER: + return true; + + break; + } return false; }