mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 18:40:29 +00:00
(svn r25848) -Codechange: Refactor check for if a tile is not an edge tile to new IsInnerTile method (cirdan, LordAro)
This commit is contained in:
parent
d908897918
commit
b35b8aa5bb
@ -364,8 +364,7 @@ static void GrayscaleToMapHeights(uint img_width, uint img_height, byte *map)
|
|||||||
SetTileHeight(tile, map[img_row * img_width + img_col] / 16);
|
SetTileHeight(tile, map[img_row * img_width + img_col] / 16);
|
||||||
}
|
}
|
||||||
/* Only clear the tiles within the map area. */
|
/* Only clear the tiles within the map area. */
|
||||||
if (TileX(tile) != MapMaxX() && TileY(tile) != MapMaxY() &&
|
if (IsInnerTile(tile)) {
|
||||||
(!_settings_game.construction.freeform_edges || (TileX(tile) != 0 && TileY(tile) != 0))) {
|
|
||||||
MakeClear(tile, CLEAR_GRASS, 3);
|
MakeClear(tile, CLEAR_GRASS, 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -950,8 +950,7 @@ static void TgenSetTileHeight(TileIndex tile, int height)
|
|||||||
SetTileHeight(tile, height);
|
SetTileHeight(tile, height);
|
||||||
|
|
||||||
/* Only clear the tiles within the map area. */
|
/* Only clear the tiles within the map area. */
|
||||||
if (TileX(tile) != MapMaxX() && TileY(tile) != MapMaxY() &&
|
if (IsInnerTile(tile)) {
|
||||||
(!_settings_game.construction.freeform_edges || (TileX(tile) != 0 && TileY(tile) != 0))) {
|
|
||||||
MakeClear(tile, CLEAR_GRASS, 3);
|
MakeClear(tile, CLEAR_GRASS, 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,7 @@ Slope GetTileSlope(TileIndex tile, int *h)
|
|||||||
{
|
{
|
||||||
assert(tile < MapSize());
|
assert(tile < MapSize());
|
||||||
|
|
||||||
uint x = TileX(tile);
|
if (!IsInnerTile(tile)) {
|
||||||
uint y = TileY(tile);
|
|
||||||
|
|
||||||
if (x == MapMaxX() || y == MapMaxY() ||
|
|
||||||
((x == 0 || y == 0) && _settings_game.construction.freeform_edges)) {
|
|
||||||
if (h != NULL) *h = TileHeight(tile);
|
if (h != NULL) *h = TileHeight(tile);
|
||||||
return SLOPE_FLAT;
|
return SLOPE_FLAT;
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,23 @@ static inline TileType GetTileType(TileIndex tile)
|
|||||||
return (TileType)GB(_m[tile].type_height, 4, 4);
|
return (TileType)GB(_m[tile].type_height, 4, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a tile is within the map (not a border)
|
||||||
|
*
|
||||||
|
* @param tile The tile to check
|
||||||
|
* @return Whether the tile is in the interior of the map
|
||||||
|
* @pre tile < MapSize()
|
||||||
|
*/
|
||||||
|
static inline bool IsInnerTile(TileIndex tile)
|
||||||
|
{
|
||||||
|
assert(tile < MapSize());
|
||||||
|
|
||||||
|
uint x = TileX(tile);
|
||||||
|
uint y = TileY(tile);
|
||||||
|
|
||||||
|
return x < MapMaxX() && y < MapMaxY() && ((x > 0 && y > 0) || !_settings_game.construction.freeform_edges);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the type of a tile
|
* Set the type of a tile
|
||||||
*
|
*
|
||||||
@ -95,7 +112,7 @@ static inline void SetTileType(TileIndex tile, TileType type)
|
|||||||
/* VOID tiles (and no others) are exactly allowed at the lower left and right
|
/* VOID tiles (and no others) are exactly allowed at the lower left and right
|
||||||
* edges of the map. If _settings_game.construction.freeform_edges is true,
|
* edges of the map. If _settings_game.construction.freeform_edges is true,
|
||||||
* the upper edges of the map are also VOID tiles. */
|
* the upper edges of the map are also VOID tiles. */
|
||||||
assert((TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY() || (_settings_game.construction.freeform_edges && (TileX(tile) == 0 || TileY(tile) == 0))) == (type == MP_VOID));
|
assert(IsInnerTile(tile) == (type != MP_VOID));
|
||||||
SB(_m[tile].type_height, 4, 4, type);
|
SB(_m[tile].type_height, 4, 4, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user