From 1bc335323d8a4618eea31341bdf61474e7127816 Mon Sep 17 00:00:00 2001 From: ArseniyShestakov Date: Wed, 4 Nov 2015 15:05:22 +0300 Subject: [PATCH] CPathfinder: add lightweightFlyingMode option suggested by @alexvins --- lib/CPathfinder.cpp | 7 +++++++ lib/CPathfinder.h | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/lib/CPathfinder.cpp b/lib/CPathfinder.cpp index 9f4911d912..da35e6e0b8 100644 --- a/lib/CPathfinder.cpp +++ b/lib/CPathfinder.cpp @@ -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()), out(_out), hero(_hero), FoW(getPlayerTeam(hero->tempOwner)->fogOfWarMap) @@ -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) diff --git a/lib/CPathfinder.h b/lib/CPathfinder.h index 660e472cc1..e6b1f6791a 100644 --- a/lib/CPathfinder.h +++ b/lib/CPathfinder.h @@ -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;