From 2724a67a273efbb95d0625266b14d3e4762b9fec Mon Sep 17 00:00:00 2001 From: ArseniyShestakov Date: Mon, 14 Dec 2015 14:33:50 +0300 Subject: [PATCH] CPathfinder: add border gate support and use passableFor --- lib/CPathfinder.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/CPathfinder.cpp b/lib/CPathfinder.cpp index 8120adfaa..86ebe942c 100644 --- a/lib/CPathfinder.cpp +++ b/lib/CPathfinder.cpp @@ -453,7 +453,7 @@ bool CPathfinder::isMovementAfterDestPossible() const /// Transit over whirlpools only allowed when hero protected return true; } - else if(dtObj->ID == Obj::GARRISON || dtObj->ID == Obj::GARRISON2) + else if(dtObj->ID == Obj::GARRISON || dtObj->ID == Obj::GARRISON2 || dtObj->ID == Obj::BORDER_GATE) { /// Transit via unguarded garrisons is always possible return true; @@ -517,18 +517,33 @@ CGPathNode::ENodeAction CPathfinder::getDestAction() const else action = CGPathNode::BLOCKING_VISIT; } - else if(dtObj->ID == Obj::TOWN && objRel == PlayerRelations::ENEMIES) + else if(dtObj->ID == Obj::TOWN) { - const CGTownInstance * townObj = dynamic_cast(dtObj); - if(townObj->armedGarrison()) + if(dtObj->passableFor(hero->tempOwner)) + action = CGPathNode::VISIT; + else if(objRel == PlayerRelations::ENEMIES) action = CGPathNode::BATTLE; } else if(dtObj->ID == Obj::GARRISON || dtObj->ID == Obj::GARRISON2) { - const CGGarrison * garrisonObj = dynamic_cast(dtObj); - if((garrisonObj->stacksCount() && objRel == PlayerRelations::ENEMIES) || isDestinationGuarded(true)) + if(dtObj->passableFor(hero->tempOwner)) + { + if(isDestinationGuarded(true)) + action = CGPathNode::BATTLE; + } + else if(objRel == PlayerRelations::ENEMIES) action = CGPathNode::BATTLE; } + else if(dtObj->ID == Obj::BORDER_GATE) + { + if(dtObj->passableFor(hero->tempOwner)) + { + if(isDestinationGuarded(true)) + action = CGPathNode::BATTLE; + } + else + action = CGPathNode::BLOCKING_VISIT; + } else if(isDestinationGuardian()) action = CGPathNode::BATTLE; else if(dtObj->blockVisit && !(options.useCastleGate && dtObj->ID == Obj::TOWN))