mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Inlined methods commonly used by pathfinder for better optimization
This commit is contained in:
@@ -89,15 +89,7 @@ public:
|
||||
TerrainTile & getTile(const int3 & tile);
|
||||
const TerrainTile & getTile(const int3 & tile) const;
|
||||
bool isCoastalTile(const int3 & pos) const;
|
||||
bool isWaterTile(const int3 & pos) const;
|
||||
inline bool isInTheMap(const int3 & pos) const
|
||||
{
|
||||
// Check whether coord < 0 is done implicitly. Negative signed int overflows to unsigned number larger than all signed ints.
|
||||
return
|
||||
static_cast<uint32_t>(pos.x) < static_cast<uint32_t>(width) &&
|
||||
static_cast<uint32_t>(pos.y) < static_cast<uint32_t>(height) &&
|
||||
static_cast<uint32_t>(pos.z) <= (twoLevel ? 1 : 0);
|
||||
}
|
||||
bool isInTheMap(const int3 & pos) const;
|
||||
|
||||
bool canMoveBetween(const int3 &src, const int3 &dst) const;
|
||||
bool checkForVisitableDir(const int3 & src, const TerrainTile * pom, const int3 & dst) const;
|
||||
@@ -250,4 +242,25 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
inline bool CMap::isInTheMap(const int3 & pos) const
|
||||
{
|
||||
// Check whether coord < 0 is done implicitly. Negative signed int overflows to unsigned number larger than all signed ints.
|
||||
return
|
||||
static_cast<uint32_t>(pos.x) < static_cast<uint32_t>(width) &&
|
||||
static_cast<uint32_t>(pos.y) < static_cast<uint32_t>(height) &&
|
||||
static_cast<uint32_t>(pos.z) <= (twoLevel ? 1 : 0);
|
||||
}
|
||||
|
||||
inline TerrainTile & CMap::getTile(const int3 & tile)
|
||||
{
|
||||
assert(isInTheMap(tile));
|
||||
return terrain[tile.z][tile.x][tile.y];
|
||||
}
|
||||
|
||||
inline const TerrainTile & CMap::getTile(const int3 & tile) const
|
||||
{
|
||||
assert(isInTheMap(tile));
|
||||
return terrain[tile.z][tile.x][tile.y];
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
Reference in New Issue
Block a user