summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2011-01-14 12:01:07 +0000
committerterkhen <terkhen@openttd.org>2011-01-14 12:01:07 +0000
commiteb2b510e019f7524061c132ee4dc92cee8140ce2 (patch)
treef527564bfd2aaef6bc570653e238f3b8ec67a157
parent87dade4698f1dfdd40fc172977521afac8fe9bda (diff)
downloadopenttd-eb2b510e019f7524061c132ee4dc92cee8140ce2.tar.xz
(svn r21778) -Add: After building a road or tram tunnel, connect it to any existing road or tram.
-rw-r--r--src/road_gui.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 520da319e..c0e966062 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -28,6 +28,7 @@
#include "tilehighlight_func.h"
#include "company_base.h"
#include "hotkeys.h"
+#include "road_gui.h"
#include "table/strings.h"
@@ -79,11 +80,27 @@ static void PlaceRoad_Bridge(TileIndex tile, Window *w)
}
}
-void CcBuildRoadTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
+/**
+ * Callback executed after a build road tunnel command has been called.
+ *
+ * @param result Whether the build succeeded.
+ * @param start_tile Starting tile of the tunnel.
+ * @param p1 bit 0-3 railtype or roadtypes
+ * bit 8-9 transport type
+ * @param p2 unused
+ */
+ void CcBuildRoadTunnel(const CommandCost &result, TileIndex start_tile, uint32 p1, uint32 p2)
{
if (result.Succeeded()) {
- SndPlayTileFx(SND_20_SPLAT_2, tile);
+ SndPlayTileFx(SND_20_SPLAT_2, start_tile);
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
+
+ DiagDirection start_direction = ReverseDiagDir(GetTunnelBridgeDirection(start_tile));
+ ConnectRoadToStructure(start_tile, start_direction);
+
+ TileIndex end_tile = GetOtherTunnelBridgeEnd(start_tile);
+ DiagDirection end_direction = ReverseDiagDir(GetTunnelBridgeDirection(end_tile));
+ ConnectRoadToStructure(end_tile, end_direction);
} else {
SetRedErrorSquare(_build_tunnel_endtile);
}