mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r21290) -Codechange: Add HasTileWaterGround() to deduplicate some tests.
This commit is contained in:
parent
0fff26db97
commit
612516ff76
@ -187,7 +187,7 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||
bool allow_water = (spec->flags & (OBJECT_FLAG_BUILT_ON_WATER | OBJECT_FLAG_NOT_ON_LAND)) != 0;
|
||||
bool allow_ground = (spec->flags & OBJECT_FLAG_NOT_ON_LAND) == 0;
|
||||
TILE_AREA_LOOP(t, ta) {
|
||||
if (HasTileWaterClass(t) && IsTileOnWater(t) && !IsCoastTile(t)) {
|
||||
if (HasTileWaterGround(t)) {
|
||||
if (!allow_water) return_cmd_error(STR_ERROR_CAN_T_BUILD_ON_WATER);
|
||||
if (!IsWaterTile(t)) {
|
||||
/* Normal water tiles don't have to be cleared. For all other tile types clear
|
||||
|
@ -100,7 +100,7 @@ CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
|
||||
|
||||
TileIndex tile2 = tile + (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||
|
||||
if (!HasTileWaterClass(tile) || !IsTileOnWater(tile) || !HasTileWaterClass(tile2) || !IsTileOnWater(tile2)) {
|
||||
if (!HasTileWaterGround(tile) || !HasTileWaterGround(tile2)) {
|
||||
return_cmd_error(STR_ERROR_MUST_BE_BUILT_ON_WATER);
|
||||
}
|
||||
|
||||
|
@ -284,6 +284,17 @@ static inline byte GetWaterTileRandomBits(TileIndex t)
|
||||
return _m[t].m4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the tile has water at the ground.
|
||||
* That is, it is either some plain water tile, or a object/industry/station/... with water under it.
|
||||
* @return true iff the tile has water at the ground.
|
||||
* @note Coast tiles are not considered waterish, even if there is water on a halftile.
|
||||
*/
|
||||
static inline bool HasTileWaterGround(TileIndex t)
|
||||
{
|
||||
return HasTileWaterClass(t) && IsTileOnWater(t) && !IsCoastTile(t);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to make a coast tile.
|
||||
|
@ -282,7 +282,7 @@ CommandCost CmdBuildRailWaypoint(TileIndex start_tile, DoCommandFlag flags, uint
|
||||
*/
|
||||
CommandCost CmdBuildBuoy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
if (!HasTileWaterClass(tile) || !IsTileOnWater(tile) || tile == 0) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
|
||||
if (tile == 0 || !HasTileWaterGround(tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
|
||||
if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
|
||||
|
||||
if (GetTileSlope(tile, NULL) != SLOPE_FLAT) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
|
||||
|
Loading…
Reference in New Issue
Block a user