(svn r7648) [cbh] - Feature: Allow removal of tracks from bridge heads. However, trains on the bridge must still be able to access the bridge head custombridgeheads
authorcelestar
Sat, 30 Dec 2006 13:15:15 +0000
branchcustombridgeheads
changeset 5603 f3aa14b91b0a
parent 5602 de5228fb1871
child 5604 729d54e97b94
(svn r7648) [cbh] - Feature: Allow removal of tracks from bridge heads. However, trains on the bridge must still be able to access the bridge head
rail_cmd.c
--- a/rail_cmd.c	Sat Dec 30 12:59:17 2006 +0000
+++ b/rail_cmd.c	Sat Dec 30 13:15:15 2006 +0000
@@ -364,6 +364,32 @@
 			break;
 		}
 
+		case MP_RAILWAY_BRIDGE: {
+			TrackBits trackbits = GetTrackBits(tile);
+
+			/* The track the user is seeking to remove is not there */
+			if ((trackbits & trackbit) == 0) return CMD_ERROR;
+
+			trackbits ^= trackbit; /* configuration after removal */
+			/* For the time being, we make sure that the bridge has some kind of exit */
+			switch (GetBridgeRampDirection(tile)) {
+				case DIAGDIR_NE:
+					if ((trackbits & TRACK_BIT_3WAY_NE) == 0) return CMD_ERROR;
+					break;
+				case DIAGDIR_SE:
+					if ((trackbits & TRACK_BIT_3WAY_SE) == 0) return CMD_ERROR;
+					break;
+				case DIAGDIR_SW:
+					if ((trackbits & TRACK_BIT_3WAY_SW) == 0) return CMD_ERROR;
+					break;
+				case DIAGDIR_NW:
+					if ((trackbits & TRACK_BIT_3WAY_NW) == 0) return CMD_ERROR;
+					break;
+				default:
+					NOT_REACHED();
+			}
+		} /* Fall through */
+
 		case MP_RAILWAY: {
 			TrackBits present;