(svn r7646) [cbh] - Feature: Allow building additional tracks on a (horizontal) bridge ramp using normal building tools custombridgeheads
authorcelestar
Sat, 30 Dec 2006 12:55:45 +0000
branchcustombridgeheads
changeset 5601 51f241d43769
parent 5600 bac9ab186cab
child 5602 de5228fb1871
(svn r7646) [cbh] - Feature: Allow building additional tracks on a (horizontal) bridge ramp using normal building tools
ai/trolly/pathfinder.c
bridge_cmd.c
bridge_map.h
rail_cmd.c
--- a/ai/trolly/pathfinder.c	Sat Dec 30 12:49:54 2006 +0000
+++ b/ai/trolly/pathfinder.c	Sat Dec 30 12:55:45 2006 +0000
@@ -2,7 +2,6 @@
 
 #include "../../stdafx.h"
 #include "../../openttd.h"
-#include "../../bridge_map.h"
 #include "../../debug.h"
 #include "../../functions.h"
 #include "../../map.h"
--- a/bridge_cmd.c	Sat Dec 30 12:49:54 2006 +0000
+++ b/bridge_cmd.c	Sat Dec 30 12:55:45 2006 +0000
@@ -76,18 +76,6 @@
 	}
 }
 
-#define M(x) (1 << (x))
-enum {
-	// foundation, whole tile is leveled up --> 3 corners raised
-	BRIDGE_FULL_LEVELED_FOUNDATION = M(SLOPE_WSE) | M(SLOPE_NWS) | M(SLOPE_ENW) | M(SLOPE_SEN),
-	// foundation, tile is partly leveled up --> 1 corner raised
-	BRIDGE_PARTLY_LEVELED_FOUNDATION = M(SLOPE_W) | M(SLOPE_S) | M(SLOPE_E) | M(SLOPE_N),
-	// no foundations (X,Y direction)
-	BRIDGE_NO_FOUNDATION = M(SLOPE_FLAT) | M(SLOPE_SW) | M(SLOPE_SE) | M(SLOPE_NW) | M(SLOPE_NE),
-	BRIDGE_HORZ_RAMP = (BRIDGE_PARTLY_LEVELED_FOUNDATION | BRIDGE_NO_FOUNDATION) & ~M(SLOPE_FLAT)
-};
-#undef M
-
 static inline const PalSpriteID *GetBridgeSpriteTable(int index, byte table)
 {
 	const Bridge *bridge = &_bridge[index];
--- a/bridge_map.h	Sat Dec 30 12:49:54 2006 +0000
+++ b/bridge_map.h	Sat Dec 30 12:55:45 2006 +0000
@@ -13,6 +13,18 @@
 
 void DrawBridgeMiddle(const TileInfo* ti); // XXX
 
+#define M(x) (1 << (x))
+enum {
+	// foundation, whole tile is leveled up --> 3 corners raised
+	BRIDGE_FULL_LEVELED_FOUNDATION = M(SLOPE_WSE) | M(SLOPE_NWS) | M(SLOPE_ENW) | M(SLOPE_SEN),
+	// foundation, tile is partly leveled up --> 1 corner raised
+	BRIDGE_PARTLY_LEVELED_FOUNDATION = M(SLOPE_W) | M(SLOPE_S) | M(SLOPE_E) | M(SLOPE_N),
+	// no foundations (X,Y direction)
+	BRIDGE_NO_FOUNDATION = M(SLOPE_FLAT) | M(SLOPE_SW) | M(SLOPE_SE) | M(SLOPE_NW) | M(SLOPE_NE),
+	BRIDGE_HORZ_RAMP = (BRIDGE_PARTLY_LEVELED_FOUNDATION | BRIDGE_NO_FOUNDATION) & ~M(SLOPE_FLAT)
+};
+#undef M
+
 
 static inline bool IsBridgeTile(TileIndex t)
 {
--- a/rail_cmd.c	Sat Dec 30 12:49:54 2006 +0000
+++ b/rail_cmd.c	Sat Dec 30 12:55:45 2006 +0000
@@ -247,6 +247,13 @@
 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 
 	switch (GetTileType(tile)) {
+		case MP_RAILWAY_BRIDGE:
+			/* We can build custombridgeheads only if we have a horizontal ramp ... */
+			if (!HASBIT(BRIDGE_HORZ_RAMP, tileh)) return CMD_ERROR;
+
+			/* In which case we can assume the tile to be flat */
+			tileh = 0;
+			/* FALL THROUGH */
 		case MP_RAILWAY:
 			if (!CheckTrackCombination(tile, trackbit, flags) ||
 					!EnsureNoVehicle(tile)) {