summaryrefslogtreecommitdiff
path: root/src/tunnelbridge_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tunnelbridge_cmd.cpp')
-rw-r--r--src/tunnelbridge_cmd.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 297a01d30..3a5ae05ad 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -15,6 +15,7 @@
#include "stdafx.h"
#include "newgrf_object.h"
+#include "layer_func.h"
#include "viewport_func.h"
#include "cmd_helper.h"
#include "command_func.h"
@@ -277,6 +278,10 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
return_cmd_error(STR_ERROR_CAN_T_START_AND_END_ON);
}
+ if (IsUnderground(tile_start) || IsUnderground(tile_end)) {
+ return_cmd_error(STR_ERROR_UNDERGROUND_CAN_T_BUILD_UNDER_GROUND);
+ }
+
Axis direction;
if (TileX(tile_start) == TileX(tile_end)) {
direction = AXIS_Y;
@@ -641,6 +646,12 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
for (;;) {
end_tile += delta;
if (!IsValidTile(end_tile)) return_cmd_error(STR_ERROR_TUNNEL_THROUGH_MAP_BORDER);
+
+
+ if (IsUnderground(start_tile) || IsUnderground(end_tile)) {
+ return_cmd_error(STR_ERROR_UNDERGROUND_CAN_T_BUILD_UNDER_GROUND);
+ }
+
end_tileh = GetTileSlope(end_tile, &end_z);
if (start_z == end_z) break;