mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
CPathfinder: get rid of curPos and pass on initializeGraph
This commit is contained in:
parent
68bd37aa45
commit
01257efc02
@ -3273,20 +3273,20 @@ TeamState::TeamState()
|
||||
|
||||
void CPathfinder::initializeGraph()
|
||||
{
|
||||
int3 pos;
|
||||
CGPathNode ***graph = out.nodes;
|
||||
for(size_t i=0; i < out.sizes.x; ++i)
|
||||
for(pos.x=0; pos.x < out.sizes.x; ++pos.x)
|
||||
{
|
||||
for(size_t j=0; j < out.sizes.y; ++j)
|
||||
for(pos.y=0; pos.y < out.sizes.y; ++pos.y)
|
||||
{
|
||||
for(size_t k=0; k < out.sizes.z; ++k)
|
||||
for(pos.z=0; pos.z < out.sizes.z; ++pos.z)
|
||||
{
|
||||
curPos = int3(i,j,k);
|
||||
const TerrainTile *tinfo = &gs->map->getTile(curPos);
|
||||
CGPathNode &node = graph[i][j][k];
|
||||
node.accessible = evaluateAccessibility(tinfo);
|
||||
const TerrainTile *tinfo = &gs->map->getTile(pos);
|
||||
CGPathNode &node = graph[pos.x][pos.y][pos.z];
|
||||
node.accessible = evaluateAccessibility(pos, tinfo);
|
||||
node.turns = 0xff;
|
||||
node.moveRemains = 0;
|
||||
node.coord = curPos;
|
||||
node.coord = pos;
|
||||
node.land = tinfo->terType != ETerrainType::WATER;
|
||||
node.theNodeBefore = nullptr;
|
||||
}
|
||||
@ -3518,12 +3518,12 @@ bool CPathfinder::canMoveBetween(const int3 &a, const int3 &b) const
|
||||
return gs->checkForVisitableDir(a, b);
|
||||
}
|
||||
|
||||
CGPathNode::EAccessibility CPathfinder::evaluateAccessibility(const TerrainTile *tinfo) const
|
||||
CGPathNode::EAccessibility CPathfinder::evaluateAccessibility(const int3 &pos, const TerrainTile *tinfo) const
|
||||
{
|
||||
CGPathNode::EAccessibility ret = (tinfo->blocked ? CGPathNode::BLOCKED : CGPathNode::ACCESSIBLE);
|
||||
|
||||
|
||||
if(tinfo->terType == ETerrainType::ROCK || !FoW[curPos.x][curPos.y][curPos.z])
|
||||
if(tinfo->terType == ETerrainType::ROCK || !FoW[pos.x][pos.y][pos.z])
|
||||
return CGPathNode::BLOCKED;
|
||||
|
||||
if(tinfo->visitable)
|
||||
@ -3551,7 +3551,7 @@ CGPathNode::EAccessibility CPathfinder::evaluateAccessibility(const TerrainTile
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(gs->map->guardingCreaturePositions[curPos.x][curPos.y][curPos.z].valid()
|
||||
else if(gs->map->guardingCreaturePositions[pos.x][pos.y][pos.z].valid()
|
||||
&& !tinfo->blocked)
|
||||
{
|
||||
// Monster close by; blocked visit for battle.
|
||||
|
@ -301,7 +301,6 @@ private:
|
||||
|
||||
std::vector<int3> neighbours;
|
||||
|
||||
int3 curPos;
|
||||
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
|
||||
@ -322,7 +321,7 @@ private:
|
||||
|
||||
bool checkDestinationTile();
|
||||
|
||||
CGPathNode::EAccessibility evaluateAccessibility(const TerrainTile *tinfo) const;
|
||||
CGPathNode::EAccessibility evaluateAccessibility(const int3 &pos, 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;
|
||||
|
Loading…
Reference in New Issue
Block a user