mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Handle Tile by reference instead of pointer
This commit is contained in:
@@ -43,11 +43,11 @@ void AINodeStorage::initialize(const PathfinderOptions & options, const CGameSta
|
|||||||
{
|
{
|
||||||
for(pos.y=0; pos.y < sizes.y; ++pos.y)
|
for(pos.y=0; pos.y < sizes.y; ++pos.y)
|
||||||
{
|
{
|
||||||
const TerrainTile * tile = &gs->map->getTile(pos);
|
const TerrainTile & tile = gs->map->getTile(pos);
|
||||||
if(!tile->terType->isPassable())
|
if(!tile.terType->isPassable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(tile->terType->isWater())
|
if(tile.terType->isWater())
|
||||||
{
|
{
|
||||||
resetTile(pos, ELayer::SAIL, PathfinderUtil::evaluateAccessibility<ELayer::SAIL>(pos, tile, fow, player, gs));
|
resetTile(pos, ELayer::SAIL, PathfinderUtil::evaluateAccessibility<ELayer::SAIL>(pos, tile, fow, player, gs));
|
||||||
if(useFlying)
|
if(useFlying)
|
||||||
|
@@ -45,8 +45,8 @@ void NodeStorage::initialize(const PathfinderOptions & options, const CGameState
|
|||||||
{
|
{
|
||||||
for(pos.y=0; pos.y < sizes.y; ++pos.y)
|
for(pos.y=0; pos.y < sizes.y; ++pos.y)
|
||||||
{
|
{
|
||||||
const TerrainTile * tile = &gs->map->getTile(pos);
|
const TerrainTile tile = gs->map->getTile(pos);
|
||||||
if(tile->terType->isWater())
|
if(tile.terType->isWater())
|
||||||
{
|
{
|
||||||
resetTile(pos, ELayer::SAIL, PathfinderUtil::evaluateAccessibility<ELayer::SAIL>(pos, tile, fow, player, gs));
|
resetTile(pos, ELayer::SAIL, PathfinderUtil::evaluateAccessibility<ELayer::SAIL>(pos, tile, fow, player, gs));
|
||||||
if(useFlying)
|
if(useFlying)
|
||||||
@@ -54,7 +54,7 @@ void NodeStorage::initialize(const PathfinderOptions & options, const CGameState
|
|||||||
if(useWaterWalking)
|
if(useWaterWalking)
|
||||||
resetTile(pos, ELayer::WATER, PathfinderUtil::evaluateAccessibility<ELayer::WATER>(pos, tile, fow, player, gs));
|
resetTile(pos, ELayer::WATER, PathfinderUtil::evaluateAccessibility<ELayer::WATER>(pos, tile, fow, player, gs));
|
||||||
}
|
}
|
||||||
if(tile->terType->isLand())
|
if(tile.terType->isLand())
|
||||||
{
|
{
|
||||||
resetTile(pos, ELayer::LAND, PathfinderUtil::evaluateAccessibility<ELayer::LAND>(pos, tile, fow, player, gs));
|
resetTile(pos, ELayer::LAND, PathfinderUtil::evaluateAccessibility<ELayer::LAND>(pos, tile, fow, player, gs));
|
||||||
if(useFlying)
|
if(useFlying)
|
||||||
|
@@ -18,7 +18,7 @@ namespace PathfinderUtil
|
|||||||
using ELayer = EPathfindingLayer;
|
using ELayer = EPathfindingLayer;
|
||||||
|
|
||||||
template<EPathfindingLayer::EEPathfindingLayer layer>
|
template<EPathfindingLayer::EEPathfindingLayer layer>
|
||||||
CGPathNode::EAccessibility evaluateAccessibility(const int3 & pos, const TerrainTile * tinfo, FoW fow, const PlayerColor player, const CGameState * gs)
|
CGPathNode::EAccessibility evaluateAccessibility(const int3 & pos, const TerrainTile & tinfo, FoW fow, const PlayerColor player, const CGameState * gs)
|
||||||
{
|
{
|
||||||
if(!(*fow)[pos.z][pos.x][pos.y])
|
if(!(*fow)[pos.z][pos.x][pos.y])
|
||||||
return CGPathNode::BLOCKED;
|
return CGPathNode::BLOCKED;
|
||||||
@@ -27,15 +27,15 @@ namespace PathfinderUtil
|
|||||||
{
|
{
|
||||||
case ELayer::LAND:
|
case ELayer::LAND:
|
||||||
case ELayer::SAIL:
|
case ELayer::SAIL:
|
||||||
if(tinfo->visitable)
|
if(tinfo.visitable)
|
||||||
{
|
{
|
||||||
if(tinfo->visitableObjects.front()->ID == Obj::SANCTUARY && tinfo->visitableObjects.back()->ID == Obj::HERO && tinfo->visitableObjects.back()->tempOwner != player) //non-owned hero stands on Sanctuary
|
if(tinfo.visitableObjects.front()->ID == Obj::SANCTUARY && tinfo.visitableObjects.back()->ID == Obj::HERO && tinfo.visitableObjects.back()->tempOwner != player) //non-owned hero stands on Sanctuary
|
||||||
{
|
{
|
||||||
return CGPathNode::BLOCKED;
|
return CGPathNode::BLOCKED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(const CGObjectInstance * obj : tinfo->visitableObjects)
|
for(const CGObjectInstance * obj : tinfo.visitableObjects)
|
||||||
{
|
{
|
||||||
if(obj->blockVisit)
|
if(obj->blockVisit)
|
||||||
return CGPathNode::BLOCKVIS;
|
return CGPathNode::BLOCKVIS;
|
||||||
@@ -46,7 +46,7 @@ namespace PathfinderUtil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(tinfo->blocked)
|
else if(tinfo.blocked)
|
||||||
{
|
{
|
||||||
return CGPathNode::BLOCKED;
|
return CGPathNode::BLOCKED;
|
||||||
}
|
}
|
||||||
@@ -59,13 +59,13 @@ namespace PathfinderUtil
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ELayer::WATER:
|
case ELayer::WATER:
|
||||||
if(tinfo->blocked || tinfo->terType->isLand())
|
if(tinfo.blocked || tinfo.terType->isLand())
|
||||||
return CGPathNode::BLOCKED;
|
return CGPathNode::BLOCKED;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ELayer::AIR:
|
case ELayer::AIR:
|
||||||
if(tinfo->blocked || tinfo->terType->isLand())
|
if(tinfo.blocked || tinfo.terType->isLand())
|
||||||
return CGPathNode::FLYABLE;
|
return CGPathNode::FLYABLE;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user