1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

CPathfinder: add all new code for pathfinding via teleporters

Each kind of teleporter have own function that determine if it's should or shouldn't be used.
For now Monolith with bidirectional channels and Subterranean Gate are united.
This commit is contained in:
ArseniyShestakov
2015-03-08 17:13:26 +03:00
parent 3773859e9d
commit 530b63f7c4
2 changed files with 105 additions and 39 deletions

View File

@@ -279,8 +279,11 @@ struct DLL_EXPORT DuelParameters
class CPathfinder : private CGameInfoCallback
{
private:
bool useSubterraneanGates;
bool allowEmbarkAndDisembark;
bool allowTeleportTwoWay; // Two-way monoliths and Subterranean Gate
bool allowTeleportOneWay; // One-way monoliths with one known exit only
bool allowTeleportOneWayRandom; // One-way monoliths with more than one known exit
bool allowTeleportWhirlpool; // Force enabled if hero protected or unaffected (have one stack of one creature)
CPathsInfo &out;
const CGHeroInstance *hero;
const std::vector<std::vector<std::vector<ui8> > > &FoW;
@@ -293,7 +296,7 @@ private:
CGPathNode *dp; //destination node -> it's a neighbour of cp that we consider
const TerrainTile *ct, *dt; //tile info for both nodes
ui8 useEmbarkCost; //0 - usual movement; 1 - embark; 2 - disembark
int destTopVisObjID;
Obj destTopVisObjID;
CGPathNode *getNode(const int3 &coord);
@@ -303,6 +306,11 @@ private:
CGPathNode::EAccessibility evaluateAccessibility(const TerrainTile *tinfo) const;
bool canMoveBetween(const int3 &a, const int3 &b) const; //checks only for visitable objects that may make moving between tiles impossible, not other conditions (like tiles itself accessibility)
bool addTeleportTwoWay(const CGTeleport * obj) const;
bool addTeleportOneWay(const CGTeleport * obj) const;
bool addTeleportOneWayRandom(const CGTeleport * obj) const;
bool addTeleportWhirlpool(const CGWhirlpool * obj) const;
public:
CPathfinder(CPathsInfo &_out, CGameState *_gs, const CGHeroInstance *_hero);
void calculatePaths(); //calculates possible paths for hero, uses current hero position and movement left; returns pointer to newly allocated CPath or nullptr if path does not exists