summaryrefslogtreecommitdiff
path: root/src/bridge_gui.cpp
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2011-01-14 12:00:07 +0000
committerterkhen <terkhen@openttd.org>2011-01-14 12:00:07 +0000
commit87dade4698f1dfdd40fc172977521afac8fe9bda (patch)
tree0694d4c6933d31980d79defc99b861b77d8d04eb /src/bridge_gui.cpp
parent998246430aec028eb78b30c187bf872ea521c0f5 (diff)
downloadopenttd-87dade4698f1dfdd40fc172977521afac8fe9bda.tar.xz
(svn r21777) -Add: After building a road or tram bridge, connect it to any existing road or tram.
Diffstat (limited to 'src/bridge_gui.cpp')
-rw-r--r--src/bridge_gui.cpp27
1 files 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<BuildBridgeData> 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<TransportType, 15, 2>(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. */