Skip to content

Commit

Permalink
CPathfinder: add lightweightFlyingMode option suggested by @alexvins
Browse files Browse the repository at this point in the history
  • Loading branch information
ArseniyShestakov committed Nov 4, 2015
1 parent 330c166 commit 1bc3353
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/CPathfinder.cpp
Expand Up @@ -27,6 +27,8 @@ CPathfinder::PathfinderOptions::PathfinderOptions()
useTeleportOneWay = true;
useTeleportOneWayRandom = false;
useTeleportWhirlpool = false;

lightweightFlyingMode = false;
}

CPathfinder::CPathfinder(CPathsInfo &_out, CGameState *_gs, const CGHeroInstance *_hero) : CGameInfoCallback(_gs, boost::optional<PlayerColor>()), out(_out), hero(_hero), FoW(getPlayerTeam(hero->tempOwner)->fogOfWarMap)
Expand Down Expand Up @@ -232,6 +234,11 @@ bool CPathfinder::isLayerTransitionPossible()
{
return false;
}
else if(cp->layer == EPathfindingLayer::LAND && dp->layer == EPathfindingLayer::AIR)
{
if(options.lightweightFlyingMode && cp->coord != hero->getPosition(false))
return false;
}
else if(cp->layer == EPathfindingLayer::SAIL && dp->layer != EPathfindingLayer::LAND)
return false;
else if(cp->layer == EPathfindingLayer::SAIL && dp->layer == EPathfindingLayer::LAND)
Expand Down
5 changes: 5 additions & 0 deletions lib/CPathfinder.h
Expand Up @@ -85,6 +85,11 @@ class CPathfinder : private CGameInfoCallback
bool useTeleportOneWayRandom; // One-way monoliths with more than one known exit
bool useTeleportWhirlpool; // Force enabled if hero protected or unaffected (have one stack of one creature)

/// If true transition into air layer only possible from initial node.
/// This is drastically decrease path calculation complexity (and time).
/// Downside is less MP effective paths calculation.
bool lightweightFlyingMode;

PathfinderOptions();
} options;

Expand Down

0 comments on commit 1bc3353

Please sign in to comment.