(svn r7739) [cbh] - Feature: Allow the construction and removal of signals on bridge heads. Warning: the signals are only displayed, they do not work yet custombridgeheads
authorcelestar
Tue, 02 Jan 2007 09:54:03 +0000
branchcustombridgeheads
changeset 5632 025c3b25f1fd
parent 5631 932c1a268feb
child 5633 c61d481dbd0b
(svn r7739) [cbh] - Feature: Allow the construction and removal of signals on bridge heads. Warning: the signals are only displayed, they do not work yet
bridge_cmd.c
bridge_map.h
openttd.c
rail.h
rail_cmd.c
--- a/bridge_cmd.c	Tue Jan 02 02:06:48 2007 +0000
+++ b/bridge_cmd.c	Tue Jan 02 09:54:03 2007 +0000
@@ -642,6 +642,8 @@
 		image, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 1 : 8, ti->z
 	);
 
+	if (HasSignals(ti->tile)) DrawSignals(ti->tile, GetTrackBits(ti->tile));
+
 	DrawBridgeMiddle(ti);
 }
 
@@ -803,7 +805,7 @@
 	pos = (DiagDirToAxis(dir) == AXIS_X ? y : x);
 
 	// On the bridge ramp or flat bridge head?
-	if ( (5 <= pos && pos <= 10) || IsCustomBridgeHead(tile)) {
+	if ( (2 <= pos && pos <= 13) || IsCustomBridgeHead(tile)) {
 		uint delta;
 
 		if (IsSteepSlope(tileh)) return z + TILE_HEIGHT * 2;
--- a/bridge_map.h	Tue Jan 02 02:06:48 2007 +0000
+++ b/bridge_map.h	Tue Jan 02 09:54:03 2007 +0000
@@ -60,7 +60,7 @@
 static inline uint GetBridgeType(TileIndex t)
 {
 	assert(IsBridgeTile(t));
-	return GB(_m[t].m2, 4, 4);
+	return GB(_m[t].m2, 12, 4);
 }
 
 
@@ -150,7 +150,7 @@
 static inline void MakeBridgeRamp(TileIndex t, Owner o, uint bridgetype, DiagDirection d, TransportType tt)
 {
 	SetTileOwner(t, o);
-	_m[t].m2 = bridgetype << 4;
+	_m[t].m2 = bridgetype << 12;
 	_m[t].m4 = d << 5;
 	_m[t].m5 = 0;
 }
--- a/openttd.c	Tue Jan 02 02:06:48 2007 +0000
+++ b/openttd.c	Tue Jan 02 09:54:03 2007 +0000
@@ -1371,6 +1371,9 @@
 					CLRBIT(_m[tile].m5, 7);
 					SB(_m[tile].m5, 2, 2, 0);
 					SB(_m[tile].m4, 5, 2, dd);
+					/* Move the bridge type around */
+					SB(_m[tile].m2, 12, 4, GB(_m[tile].m2, 4, 4));
+					SB(_m[tile].m2, 4, 4, 0);
 				} else { /* Tunnel */
 					SetTileType(tile, MP_TUNNEL);
 				}
--- a/rail.h	Tue Jan 02 02:06:48 2007 +0000
+++ b/rail.h	Tue Jan 02 09:54:03 2007 +0000
@@ -467,6 +467,7 @@
 uint GetRailFoundation(Slope tileh, TrackBits bits);
 void DrawTile_Track(TileInfo *ti);
 uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode);
+void DrawSignals(TileIndex tile, TrackBits rails);
 
 int32 SettingsDisableElrail(int32 p1); ///< _patches.disable_elrail callback
 
--- a/rail_cmd.c	Tue Jan 02 02:06:48 2007 +0000
+++ b/rail_cmd.c	Tue Jan 02 09:54:03 2007 +0000
@@ -652,8 +652,11 @@
 	sigvar = HASBIT(p1, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC;
 	pre_signal = HASBIT(p1, 3);
 
-	if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoVehicle(tile))
+	if (!ValParamTrackOrientation(track) ||
+			!(IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_RAILWAY_BRIDGE)) ||
+			!EnsureNoVehicle(tile)) {
 		return CMD_ERROR;
+	}
 
 	/* Protect against invalid signal copying */
 	if (p2 != 0 && (p2 & SignalOnTrack(track)) == 0) return CMD_ERROR;
@@ -830,7 +833,7 @@
 	Track track = (Track)(p1 & 0x7);
 
 	if (!ValParamTrackOrientation(track) ||
-			!IsTileType(tile, MP_RAILWAY) ||
+			!(IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_RAILWAY_BRIDGE)) ||
 			!EnsureNoVehicle(tile) ||
 			!HasSignalOnTrack(tile, track)) {
 		return CMD_ERROR;
@@ -1254,7 +1257,7 @@
 
 }
 
-static void DrawSignals(TileIndex tile, TrackBits rails)
+void DrawSignals(TileIndex tile, TrackBits rails)
 {
 #define MAYBE_DRAW_SIGNAL(x,y,z) if (IsSignalPresent(tile, x)) DrawSingleSignal(tile, GetSingleSignalState(tile, x), y - 0x4FB, z)