summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/object_cmd.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp
index eab4ac075..8958a714a 100644
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -202,18 +202,20 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
}
/* So, now the surface is checked... check the slope of said surface. */
- if (HasBit(spec->callback_mask, CBM_OBJ_SLOPE_CHECK)) {
- TILE_AREA_LOOP(t, ta) {
+ int allowed_z;
+ if (GetTileSlope(tile, (uint*)&allowed_z) != SLOPE_FLAT) allowed_z += TILE_HEIGHT;
+
+ TILE_AREA_LOOP(t, ta) {
+ uint16 callback = CALLBACK_FAILED;
+ if (HasBit(spec->callback_mask, CBM_OBJ_SLOPE_CHECK)) {
TileIndex diff = t - tile;
- uint16 callback = GetObjectCallback(CBID_OBJECT_LAND_SLOPE_CHECK, GetTileSlope(t, NULL), TileY(diff) << 4 | TileX(diff), spec, NULL, t);
- if (callback != 0) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
+ callback = GetObjectCallback(CBID_OBJECT_LAND_SLOPE_CHECK, GetTileSlope(t, NULL), TileY(diff) << 4 | TileX(diff), spec, NULL, t);
}
- } else {
- /* Check whether the ground is flat enough. */
- int allowed_z = -1;
- TILE_AREA_LOOP(t, ta) {
- /* We'll do the bridge test later; it's quite custom. */
+
+ if (callback == CALLBACK_FAILED) {
cost.AddCost(CheckBuildableTile(t, 0, allowed_z, false));
+ } else if (callback != 0) {
+ return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
}
}
}