(svn r21470) -Codechange: add method to get the distance from the edge in a given direction
This commit is contained in:
17
src/map.cpp
17
src/map.cpp
@@ -224,6 +224,23 @@ uint DistanceFromEdge(TileIndex tile)
|
||||
return min(minl, minh);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Gets the distance to the edge of the map in given direction.
|
||||
* @param tile the tile to get the distance from
|
||||
* @param diagdir the direction of interest
|
||||
* @return the distance from the edge in tiles
|
||||
*/
|
||||
uint DistanceFromEdgeDir(TileIndex tile, DiagDirection dir)
|
||||
{
|
||||
switch (dir) {
|
||||
case DIAGDIR_NE: return TileX(tile) - (_settings_game.construction.freeform_edges ? 1 : 0);
|
||||
case DIAGDIR_NW: return TileY(tile) - (_settings_game.construction.freeform_edges ? 1 : 0);
|
||||
case DIAGDIR_SW: return MapMaxX() - TileX(tile) - 1;
|
||||
case DIAGDIR_SE: return MapMaxY() - TileY(tile) - 1;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Function performing a search around a center tile and going outward, thus in circle.
|
||||
* Although it really is a square search...
|
||||
|
Reference in New Issue
Block a user