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)
|
||||
{
|
||||
const TerrainTile * tile = &gs->map->getTile(pos);
|
||||
if(!tile->terType->isPassable())
|
||||
const TerrainTile & tile = gs->map->getTile(pos);
|
||||
if(!tile.terType->isPassable())
|
||||
continue;
|
||||
|
||||
if(tile->terType->isWater())
|
||||
if(tile.terType->isWater())
|
||||
{
|
||||
resetTile(pos, ELayer::SAIL, PathfinderUtil::evaluateAccessibility<ELayer::SAIL>(pos, tile, fow, player, gs));
|
||||
if(useFlying)
|
||||
|
@@ -45,8 +45,8 @@ void NodeStorage::initialize(const PathfinderOptions & options, const CGameState
|
||||
{
|
||||
for(pos.y=0; pos.y < sizes.y; ++pos.y)
|
||||
{
|
||||
const TerrainTile * tile = &gs->map->getTile(pos);
|
||||
if(tile->terType->isWater())
|
||||
const TerrainTile tile = gs->map->getTile(pos);
|
||||
if(tile.terType->isWater())
|
||||
{
|
||||
resetTile(pos, ELayer::SAIL, PathfinderUtil::evaluateAccessibility<ELayer::SAIL>(pos, tile, fow, player, gs));
|
||||
if(useFlying)
|
||||
@@ -54,7 +54,7 @@ void NodeStorage::initialize(const PathfinderOptions & options, const CGameState
|
||||
if(useWaterWalking)
|
||||
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));
|
||||
if(useFlying)
|
||||
|
@@ -18,7 +18,7 @@ namespace PathfinderUtil
|
||||
using ELayer = EPathfindingLayer;
|
||||
|
||||
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])
|
||||
return CGPathNode::BLOCKED;
|
||||
@@ -27,15 +27,15 @@ namespace PathfinderUtil
|
||||
{
|
||||
case ELayer::LAND:
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(const CGObjectInstance * obj : tinfo->visitableObjects)
|
||||
for(const CGObjectInstance * obj : tinfo.visitableObjects)
|
||||
{
|
||||
if(obj->blockVisit)
|
||||
return CGPathNode::BLOCKVIS;
|
||||
@@ -46,7 +46,7 @@ namespace PathfinderUtil
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(tinfo->blocked)
|
||||
else if(tinfo.blocked)
|
||||
{
|
||||
return CGPathNode::BLOCKED;
|
||||
}
|
||||
@@ -59,13 +59,13 @@ namespace PathfinderUtil
|
||||
break;
|
||||
|
||||
case ELayer::WATER:
|
||||
if(tinfo->blocked || tinfo->terType->isLand())
|
||||
if(tinfo.blocked || tinfo.terType->isLand())
|
||||
return CGPathNode::BLOCKED;
|
||||
|
||||
break;
|
||||
|
||||
case ELayer::AIR:
|
||||
if(tinfo->blocked || tinfo->terType->isLand())
|
||||
if(tinfo.blocked || tinfo.terType->isLand())
|
||||
return CGPathNode::FLYABLE;
|
||||
|
||||
break;
|
||||
|
Reference in New Issue
Block a user