Changeset - r2511:38fead3e8cf3
[Not reviewed]
master
1 5 0
tron - 19 years ago 2005-10-13 16:00:14
tron@openttd.org
(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
6 files changed with 32 insertions and 20 deletions:
0 comments (0 inline, 0 general)
rail.h
Show inline comments
 
@@ -151,12 +151,14 @@ typedef struct RailtypeInfo {
 
		SpriteID single_y;     ///< single piece of rail in Y direction, without ground
 
		SpriteID single_x;     ///< single piece of rail in X direction
 
		SpriteID single_n;     ///< single piece of rail in the northern corner
 
		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
 
	 * directly in the code are listed */
 
	struct {
 
		SpriteID build_ns_rail;      ///< button for building single rail in N-S direction
railtypes.h
Show inline comments
 
@@ -7,13 +7,16 @@
 
/** Global Railtype definition
 
 */
 
const RailtypeInfo _railtypes[RAILTYPE_END] = {
 
	/** 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,
 
			SPR_OPENTTD_BASE + 0, 0x50E, 0x97E, SPR_OPENTTD_BASE + 25 },
 

	
 
		/* strings */
 
@@ -29,13 +32,16 @@ const RailtypeInfo _railtypes[RAILTYPE_E
 
		0,
 
	},
 

	
 
	/** 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,
 
			SPR_OPENTTD_BASE + 1, SPR_OPENTTD_BASE + 12, 0x97F, SPR_OPENTTD_BASE + 27 },
 

	
 
		/* strings */
 
@@ -51,13 +57,16 @@ const RailtypeInfo _railtypes[RAILTYPE_E
 
		82,
 
	},
 

	
 
	/** 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,
 
			SPR_OPENTTD_BASE + 2, SPR_OPENTTD_BASE + 13, 0x980, SPR_OPENTTD_BASE + 29 },
 

	
 
		/* strings */
road_cmd.c
Show inline comments
 
@@ -847,29 +847,28 @@ static void DrawTile_Road(TileInfo *ti)
 
	if ( (ti->map5 & 0xF0) == 0) { // if it is a road the upper 4 bits are 0
 
		DrawRoadBits(ti, GB(ti->map5, 0, 4), GB(_m[ti->tile].m4, 4, 3), HASBIT(_m[ti->tile].m4, 7), false);
 
	} else if ( (ti->map5 & 0xE0) == 0) { // railroad crossing
 
		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;
 

	
 
		if ( _m[ti->tile].m4 & 0x80) {
 
			image += 8;
 
		} else {
 
			m2 = GB(_m[ti->tile].m4, 4, 3);
 
			if (m2 == 0) image |= PALETTE_TO_BARE_LAND;
 
			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);
 
			if (pbs & TRACK_BIT_DIAG1) DrawGroundSprite(0x3ED | PALETTE_CRASH);
 
			if (pbs & TRACK_BIT_DIAG2) DrawGroundSprite(0x3EE | PALETTE_CRASH);
 
			if (pbs & TRACK_BIT_UPPER) DrawGroundSprite(0x3EF | PALETTE_CRASH);
table/sprites.h
Show inline comments
 
@@ -404,14 +404,21 @@ enum Sprites {
 
	SPR_SHIPLIFT_Y_UP_TOP_FRONT				= SPR_CANALS_BASE + 29,
 
	SPR_SHIPLIFT_X_DOWN_TOP_FRONT			= SPR_CANALS_BASE + 30,
 
	SPR_SHIPLIFT_X_UP_TOP_FRONT				= SPR_CANALS_BASE + 31,
 
	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 */
 

	
 
	/* Wooden bridge (type 0) */
 
	SPR_BTWDN_RAIL_Y_REAR				= 2545,
 
	SPR_BTWDN_RAIL_X_REAR				= 2546,
table/tunnel_land.h
Show inline comments
 
deleted file
tunnelbridge_cmd.c
Show inline comments
 
@@ -21,13 +21,12 @@
 
#include "pbs.h"
 
#include "debug.h"
 
#include "variables.h"
 
#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];
 

	
 
extern void DrawCanalWater(TileIndex tile);
 

	
 
@@ -1037,19 +1036,20 @@ static void DrawTile_TunnelBridge(TileIn
 
	uint tmp;
 
	const uint32 *b;
 
	bool ice = _m[ti->tile].m4 & 0x80;
 

	
 
	// 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);
 

	
 
		AddSortableSpriteToDraw(image+1, ti->x + 15, ti->y + 15, 1, 1, 8, (byte)ti->z);
 
	// draw bridge?
 
	} else if ((byte)ti->map5 & 0x80) {
0 comments (0 inline, 0 general)