(svn r3037) Don't deduce the sprites for tunnels and level crossings from magic numbers, but fetch them from the central rail info array. This is a preparation step for electrified rails
authortron
Thu, 13 Oct 2005 16:00:14 +0000
changeset 2511 0a81d9ca79bc
parent 2510 8a959a130698
child 2512 fa66ff5ebf88
(svn r3037) Don't deduce the sprites for tunnels and level crossings from magic numbers, but fetch them from the central rail info array. This is a preparation step for electrified rails
rail.h
railtypes.h
road_cmd.c
table/sprites.h
table/tunnel_land.h
tunnelbridge_cmd.c
--- a/rail.h	Thu Oct 13 14:44:03 2005 +0000
+++ b/rail.h	Thu Oct 13 16:00:14 2005 +0000
@@ -154,6 +154,8 @@
 		SpriteID single_s;     ///< single piece of rail in the southern corner
 		SpriteID single_e;     ///< single piece of rail in the eastern corner
 		SpriteID single_w;     ///< single piece of rail in the western corner
+		SpriteID crossing;     ///< level crossing, rail in X direction
+		SpriteID tunnel;       ///< tunnel sprites base
 	} base_sprites;
 
 	/** struct containing the sprites for the rail GUI. @note only sprites referred to
--- a/railtypes.h	Thu Oct 13 14:44:03 2005 +0000
+++ b/railtypes.h	Thu Oct 13 16:00:14 2005 +0000
@@ -10,7 +10,10 @@
 	/** Railway */
 	{ /* Main Sprites */
 		{ SPR_RAIL_TRACK_Y, SPR_RAIL_TRACK_N_S, SPR_RAIL_TRACK_BASE, SPR_RAIL_SINGLE_Y, SPR_RAIL_SINGLE_X,
-			SPR_RAIL_SINGLE_NORTH, SPR_RAIL_SINGLE_SOUTH, SPR_RAIL_SINGLE_EAST, SPR_RAIL_SINGLE_WEST },
+			SPR_RAIL_SINGLE_NORTH, SPR_RAIL_SINGLE_SOUTH, SPR_RAIL_SINGLE_EAST, SPR_RAIL_SINGLE_WEST,
+			SPR_CROSSING_OFF_X_RAIL,
+			SPR_TUNNEL_ENTRY_REAR_RAIL
+		},
 
 		/* GUI sprites */
 		{ 0x4E3, 0x4E4, 0x4E5, 0x4E6,
@@ -32,7 +35,10 @@
 	/** Monorail */
 	{ /* Main Sprites */
 		{ SPR_MONO_TRACK_Y, SPR_MONO_TRACK_N_S, SPR_MONO_TRACK_BASE, SPR_MONO_SINGLE_Y, SPR_MONO_SINGLE_X,
-			SPR_MONO_SINGLE_NORTH, SPR_MONO_SINGLE_SOUTH, SPR_MONO_SINGLE_EAST, SPR_MONO_SINGLE_WEST },
+			SPR_MONO_SINGLE_NORTH, SPR_MONO_SINGLE_SOUTH, SPR_MONO_SINGLE_EAST, SPR_MONO_SINGLE_WEST,
+			SPR_CROSSING_OFF_X_MONO,
+			SPR_TUNNEL_ENTRY_REAR_MONO
+		},
 
 		/* GUI sprites */
 		{ 0x4E7, 0x4E8, 0x4E9, 0x4EA,
@@ -54,7 +60,10 @@
 	/** Maglev */
 	{ /* Main sprites */
 		{ SPR_MGLV_TRACK_Y, SPR_MGLV_TRACK_N_S, SPR_MGLV_TRACK_BASE, SPR_MGLV_SINGLE_Y, SPR_MGLV_SINGLE_X,
-			SPR_MGLV_SINGLE_NORTH, SPR_MGLV_SINGLE_SOUTH, SPR_MGLV_SINGLE_EAST, SPR_MGLV_SINGLE_WEST },
+			SPR_MGLV_SINGLE_NORTH, SPR_MGLV_SINGLE_SOUTH, SPR_MGLV_SINGLE_EAST, SPR_MGLV_SINGLE_WEST,
+			SPR_CROSSING_OFF_X_MAGLEV,
+			SPR_TUNNEL_ENTRY_REAR_MAGLEV
+		},
 
 		/* GUI sprites */
 		{ 0x4EB, 0x4EC, 0x4EE, 0x4ED,
--- a/road_cmd.c	Thu Oct 13 14:44:03 2005 +0000
+++ b/road_cmd.c	Thu Oct 13 16:00:14 2005 +0000
@@ -850,10 +850,9 @@
 		int f = GetRoadFoundation(ti->tileh, ti->map5 & 0xF);
 		if (f) DrawFoundation(ti, f);
 
-		image = 0x55B;
+		image = GetRailTypeInfo(GB(_m[ti->tile].m4, 0, 4))->base_sprites.crossing;
 
-		if ( (ti->map5 & 8) != 0)
-			image--;
+		if (GB(ti->map5, 3, 1) == 0) image++; /* direction */
 
 		if ( (ti->map5 & 4) != 0)
 			image += 2;
@@ -866,7 +865,7 @@
 			if (m2 > 1) image += 4;
 		}
 
-		DrawGroundSprite(image + GB(_m[ti->tile].m4, 0, 4) * 12);
+		DrawGroundSprite(image);
 
 		if (_debug_pbs_level >= 1) {
 			byte pbs = PBSTileReserved(ti->tile);
--- a/table/sprites.h	Thu Oct 13 14:44:03 2005 +0000
+++ b/table/sprites.h	Thu Oct 13 16:00:14 2005 +0000
@@ -407,8 +407,15 @@
 	SPR_SHIPLIFT_Y_DOWN_TOP_FRONT			= SPR_CANALS_BASE + 32,
 
 	/* Sprites for tunnels and bridges */
-	SPR_TUNNEL_ENTRY_REAR_RAIL	= 2365,
-	SPR_TUNNEL_ENTRY_REAR_ROAD	= 2389,
+	SPR_TUNNEL_ENTRY_REAR_RAIL   = 2365,
+	SPR_TUNNEL_ENTRY_REAR_MONO   = 2373,
+	SPR_TUNNEL_ENTRY_REAR_MAGLEV = 2381,
+	SPR_TUNNEL_ENTRY_REAR_ROAD   = 2389,
+
+	/* Level crossings */
+	SPR_CROSSING_OFF_X_RAIL   = 1370,
+	SPR_CROSSING_OFF_X_MONO   = 1382,
+	SPR_CROSSING_OFF_X_MAGLEV = 1394,
 
 		/* bridge type sprites */
 
--- a/table/tunnel_land.h	Thu Oct 13 14:44:03 2005 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-/* $Id$ */
-
-static const SpriteID _draw_tunnel_table_1[] = {
-	0x93D, 0x955,
-};
--- a/tunnelbridge_cmd.c	Thu Oct 13 14:44:03 2005 +0000
+++ b/tunnelbridge_cmd.c	Thu Oct 13 16:00:14 2005 +0000
@@ -24,7 +24,6 @@
 #include "bridge.h"
 
 #include "table/bridge_land.h"
-#include "table/tunnel_land.h"
 
 extern const byte _track_sloped_sprites[14];
 extern const SpriteID _water_shore_sprites[15];
@@ -1040,13 +1039,14 @@
 
 	// draw tunnel?
 	if ((ti->map5 & 0xF0) == 0) {
-		/* railway type */
-		image = GB(_m[ti->tile].m3, 0, 4) * 8;
+		if (GB(ti->map5, 2, 2) == 0) { /* Rail tunnel? */
+			image = GetRailTypeInfo(GB(_m[ti->tile].m3, 0, 4))->base_sprites.tunnel;
+		} else {
+			image = SPR_TUNNEL_ENTRY_REAR_ROAD;
+		}
 
-		if (ice)
-			image += 32;
+		if (ice) image += 32;
 
-		image += _draw_tunnel_table_1[GB(ti->map5, 2, 2)];
 		image += GB(ti->map5, 0, 2) * 2;
 		DrawGroundSprite(image);