1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

CPathfinder: fix typos and more code cleanups

This commit is contained in:
ArseniyShestakov 2015-10-25 17:01:28 +03:00
parent 4f7c3ec60f
commit a536691781
2 changed files with 7 additions and 14 deletions

View File

@ -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<const CGTeleport *>(sTileObj);
const CGTeleport *sTileTeleport = dynamic_cast<const CGTeleport *>(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

View File

@ -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