From a536691781febf68a1555eeac4cd069c818155c7 Mon Sep 17 00:00:00 2001 From: ArseniyShestakov Date: Sun, 25 Oct 2015 17:01:28 +0300 Subject: [PATCH] CPathfinder: fix typos and more code cleanups --- lib/CGameState.cpp | 13 +++++-------- lib/CGameState.h | 8 ++------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index 08aa97fbe..f0c33d19f 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -3287,15 +3287,12 @@ void CPathfinder::initializeGraph() for(size_t k=0; k < out.sizes.z; ++k) { curPos = int3(i,j,k); - const TerrainTile *tinfo = &gs->map->getTile(int3(i, j, k)); + const TerrainTile *tinfo = &gs->map->getTile(curPos); CGPathNode &node = graph[i][j][k]; - node.accessible = evaluateAccessibility(tinfo); node.turns = 0xff; node.moveRemains = 0; - node.coord.x = i; - node.coord.y = j; - node.coord.z = k; + node.coord = curPos; node.land = tinfo->terType != ETerrainType::WATER; node.theNodeBefore = nullptr; } @@ -3348,7 +3345,7 @@ void CPathfinder::getTeleportExits(bool noTeleportExcludes) return false; }; - sTileTeleport = dynamic_cast(sTileObj); + const CGTeleport *sTileTeleport = dynamic_cast(sTileObj); if(isAllowedTeleportEntrance(sTileTeleport)) { for(auto objId : gs->getTeleportChannelExits(sTileTeleport->channel, hero->tempOwner)) @@ -3613,7 +3610,7 @@ CPathfinder::PathfinderOptions::PathfinderOptions() useFlying = false; useWaterWalking = false; useEmbarkAndDisembark = true; - useTeleportTWoWay = true; + useTeleportTwoWay = true; useTeleportOneWay = true; useTeleportOneWayRandom = false; useTeleportWhirlpool = false; @@ -3652,7 +3649,7 @@ CRandomGenerator & CGameState::getRandomGenerator() bool CPathfinder::addTeleportTwoWay(const CGTeleport * obj) const { - return options.useTeleportTWoWay && gs->isTeleportChannelBidirectional(obj->channel, hero->tempOwner); + return options.useTeleportTwoWay && gs->isTeleportChannelBidirectional(obj->channel, hero->tempOwner); } bool CPathfinder::addTeleportOneWay(const CGTeleport * obj) const diff --git a/lib/CGameState.h b/lib/CGameState.h index 7a4bae191..34593e397 100644 --- a/lib/CGameState.h +++ b/lib/CGameState.h @@ -284,7 +284,7 @@ private: bool useFlying; bool useWaterWalking; bool useEmbarkAndDisembark; - bool useTeleportTWoWay; // Two-way monoliths and Subterranean Gate + bool useTeleportTwoWay; // Two-way monoliths and Subterranean Gate bool useTeleportOneWay; // One-way monoliths with one known exit only 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) @@ -305,13 +305,9 @@ private: CGPathNode *cp; //current (source) path node -> we took it from the queue CGPathNode *dp; //destination node -> it's a neighbour of cp that we consider const TerrainTile *ct, *dt; //tile info for both nodes + const CGObjectInstance *sTileObj; ui8 useEmbarkCost; //0 - usual movement; 1 - embark; 2 - disembark - CGObjectInstance *sTileObj; - CGObjectInstance *dTileObj; - const CGTeleport *sTileTeleport; - const CGTeleport *dTileTeleport; - CGPathNode *getNode(const int3 &coord); void initializeGraph(); bool isMovementPossible(); //checks if current move will be between sea<->land. If so, checks it legality (returns false if movement is not possible) and sets useEmbarkCost