summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-10-13 16:00:14 +0000
committertron <tron@openttd.org>2005-10-13 16:00:14 +0000
commit7520ef8f3325bcaec2496e52e0d351767193da28 (patch)
treeee9f710faeaacffe616dd886460d095de751bb0d
parentd37639ac3eab8c7d8deb37ff9b7784f57aa580d4 (diff)
downloadopenttd-7520ef8f3325bcaec2496e52e0d351767193da28.tar.xz
(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
-rw-r--r--rail.h2
-rw-r--r--railtypes.h15
-rw-r--r--road_cmd.c7
-rw-r--r--table/sprites.h11
-rw-r--r--table/tunnel_land.h5
-rw-r--r--tunnelbridge_cmd.c12
6 files changed, 32 insertions, 20 deletions
diff --git a/rail.h b/rail.h
index be03813be..215a291dd 100644
--- a/rail.h
+++ b/rail.h
@@ -154,6 +154,8 @@ typedef struct RailtypeInfo {
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
diff --git a/railtypes.h b/railtypes.h
index 74cd0768f..9e09e3e65 100644
--- a/railtypes.h
+++ b/railtypes.h
@@ -10,7 +10,10 @@ 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,
@@ -32,7 +35,10 @@ const RailtypeInfo _railtypes[RAILTYPE_END] = {
/** 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 @@ const RailtypeInfo _railtypes[RAILTYPE_END] = {
/** 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,
diff --git a/road_cmd.c b/road_cmd.c
index eea3d00b4..6064e2204 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -850,10 +850,9 @@ static void DrawTile_Road(TileInfo *ti)
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 @@ static void DrawTile_Road(TileInfo *ti)
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);
diff --git a/table/sprites.h b/table/sprites.h
index 1537a6b83..442282b33 100644
--- a/table/sprites.h
+++ b/table/sprites.h
@@ -407,8 +407,15 @@ enum Sprites {
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 */
diff --git a/table/tunnel_land.h b/table/tunnel_land.h
deleted file mode 100644
index db75c163c..000000000
--- a/table/tunnel_land.h
+++ /dev/null
@@ -1,5 +0,0 @@
-/* $Id$ */
-
-static const SpriteID _draw_tunnel_table_1[] = {
- 0x93D, 0x955,
-};
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index d51ffe6f3..c16329669 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -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 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
// 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);