From 87dade4698f1dfdd40fc172977521afac8fe9bda Mon Sep 17 00:00:00 2001 From: terkhen Date: Fri, 14 Jan 2011 12:00:07 +0000 Subject: (svn r21777) -Add: After building a road or tram bridge, connect it to any existing road or tram. --- src/bridge_gui.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index c62da1036..5dd8ea847 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -23,6 +23,9 @@ #include "widgets/dropdown_func.h" #include "core/geometry_func.hpp" #include "openttd.h" +#include "cmd_helper.h" +#include "tunnelbridge_map.h" +#include "road_gui.h" #include "table/strings.h" @@ -46,13 +49,27 @@ typedef GUIList GUIBridgeList; ///< List of bridges, used in #B * Callback executed after a build Bridge CMD has been called * * @param result Whether the build succeeded - * @param tile The tile where the command has been executed - * @param p1 not used - * @param p2 not used + * @param end_tile End tile of the bridge. + * @param p1 packed start tile coords (~ dx) + * @param p2 various bitstuffed elements + * - p2 = (bit 0- 7) - bridge type (hi bh) + * - p2 = (bit 8-11) - rail type or road types. + * - p2 = (bit 15-16) - transport type. */ -void CcBuildBridge(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) +void CcBuildBridge(const CommandCost &result, TileIndex end_tile, uint32 p1, uint32 p2) { - if (result.Succeeded()) SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, tile); + if (result.Failed()) return; + SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, end_tile); + + TransportType transport_type = Extract(p2); + + if (transport_type == TRANSPORT_ROAD) { + DiagDirection end_direction = ReverseDiagDir(GetTunnelBridgeDirection(end_tile)); + ConnectRoadToStructure(end_tile, end_direction); + + DiagDirection start_direction = ReverseDiagDir(GetTunnelBridgeDirection(p1)); + ConnectRoadToStructure(p1, start_direction); + } } /** Names of the widgets of the build-bridge selection window. */ -- cgit v1.2.3-70-g09d2