summaryrefslogtreecommitdiff
path: root/table
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-03-29 16:30:26 +0000
committercelestar <celestar@openttd.org>2006-03-29 16:30:26 +0000
commit6c44bf50128ccd39a5ba7ba3298634d1298cab03 (patch)
treec1903bfd394f761768fa9d907c58a76229e1b2f8 /table
parentf6662e056ddbf15463827b524a343b67dd5a3440 (diff)
downloadopenttd-6c44bf50128ccd39a5ba7ba3298634d1298cab03.tar.xz
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
Diffstat (limited to 'table')
-rw-r--r--table/elrail_data.h362
-rw-r--r--table/engines.h15
-rw-r--r--table/landscape_const.h29
-rw-r--r--table/sprites.h64
4 files changed, 434 insertions, 36 deletions
diff --git a/table/elrail_data.h b/table/elrail_data.h
new file mode 100644
index 000000000..32a283483
--- /dev/null
+++ b/table/elrail_data.h
@@ -0,0 +1,362 @@
+/* $Id */
+/** @file elrail_data.h Stores all the data for overhead wire and pylon drawing. @see elrail.c */
+
+#ifndef ELRAIL_DATA_H
+#define ELRAIL_DATA_H
+
+/** Tile Location group. This defines whether the X and or Y coordinate of a tile is even */
+typedef enum TLG {
+ XEVEN_YEVEN = 0,
+ XEVEN_YODD = 1,
+ XODD_YEVEN = 2,
+ XODD_YODD = 3,
+ TLG_END
+} TLG;
+
+/** When determining the pylon configuration on the edge, two tiles are taken into account:
+ * the tile being drawn itself (the home tile, the one in ti->tile), and the neighbouring tile
+ */
+typedef enum {
+ TS_HOME = 0,
+ TS_NEIGHBOUR = 1,
+
+ TS_END
+} TileSource;
+
+enum {
+ TRACKS_AT_PCP = 6
+};
+
+/** Which PPPs are possible at all on a given PCP */
+static byte AllowedPPPonPCP[DIAGDIR_END] = {
+ 1 << DIR_N | 1 << DIR_E | 1 << DIR_SE | 1 << DIR_S | 1 << DIR_W | 1 << DIR_NW,
+ 1 << DIR_N | 1 << DIR_NE | 1 << DIR_E | 1 << DIR_S | 1 << DIR_SW | 1 << DIR_W,
+ 1 << DIR_N | 1 << DIR_E | 1 << DIR_SE | 1 << DIR_S | 1 << DIR_W | 1 << DIR_NW,
+ 1 << DIR_N | 1 << DIR_NE | 1 << DIR_E | 1 << DIR_S | 1 << DIR_SW | 1 << DIR_W,
+};
+
+/** Which of the PPPs are inside the tile. For the two PPPs on the tile border the following system is used:
+ if you rotate the PCP so that it is in the north, the eastern PPP belongs to the tile. */
+static byte OwnedPPPonPCP[DIAGDIR_END] = {
+ 1 << DIR_SE | 1 << DIR_S | 1 << DIR_SW | 1 << DIR_W,
+ 1 << DIR_N | 1 << DIR_SW | 1 << DIR_W | 1 << DIR_NW,
+ 1 << DIR_N | 1 << DIR_NE | 1 << DIR_E | 1 << DIR_NW,
+ 1 << DIR_NE | 1 << DIR_E | 1 << DIR_SE | 1 << DIR_S
+};
+
+/** Preferred points of each trackbit. Those are the ones perpendicular to the track, plus the point in
+ extension of the track (to mark end-of-track).*/
+static byte PreferredPPPofTrackBitAtPCP[TRACK_END][DIAGDIR_END] = {
+ {1 << DIR_NE | 1 << DIR_SE | 1 << DIR_NW, 0xFF, 1 << DIR_SE | 1 << DIR_SW | 1 << DIR_NW, 0xFF }, /* X */
+ {0xFF, 1 << DIR_NE | 1 << DIR_SE | 1 << DIR_SW, 0xFF, 1 << DIR_SW | 1 << DIR_NW | 1 << DIR_NE }, /* Y */
+ {1 << DIR_E | 1 << DIR_N | 1 << DIR_S, 0xFF, 0xFF, 1 << DIR_W | 1 << DIR_N | 1 << DIR_S}, /* UPPER */
+ {0xFF, 1 << DIR_E | 1 << DIR_N | 1 << DIR_S, 1 << DIR_W | 1 << DIR_N | 1 << DIR_S, 0xFF}, /* LOWER */
+ {0xFF, 0xFF, 1 << DIR_S | 1 << DIR_E | 1 << DIR_W, 1 << DIR_N | 1 << DIR_E | 1 << DIR_W}, /* LEFT */
+ {1 << DIR_N | 1 << DIR_E | 1 << DIR_W, 1 << DIR_S | 1 << DIR_E | 1 << DIR_W, 0xFF, 0xFF}, /* RIGHT */
+};
+
+#define NUM_IGNORE_GROUPS 3
+/** In case we have a staight line, we place pylon only every two tiles, so there are certain tiles
+ which we ignore. A straight line is found if we have exactly two preferred points.*/
+static byte IgnoredPCP[NUM_IGNORE_GROUPS][TLG_END][DIAGDIR_END] = {
+ {
+ {1 << DIR_N | 1 << DIR_S , 1 << DIR_NE | 1 << DIR_SW, 1 << DIR_NW | 1 << DIR_SE, 1 << DIR_W | 1 << DIR_E},
+ {0xFF , 1 << DIR_E | 1 << DIR_W, 1 << DIR_NW | 1 << DIR_SE, 1 << DIR_NE | 1 << DIR_SW},
+ {1 << DIR_NW | 1 << DIR_SE, 1 << DIR_NE | 1 << DIR_SW, 1 << DIR_N | 1 << DIR_S , 0xFF},
+ {1 << DIR_NW | 1 << DIR_SE, 0xFF , 0xFF, 1 << DIR_NE | 1 << DIR_SW}
+ },
+ {
+ {1 << DIR_E | 1 << DIR_W, 1 << DIR_N | 1 << DIR_S, 0xFF, 1 << DIR_E | 1 << DIR_W},
+ {0xFF, 0xFF, 1 << DIR_N | 1 << DIR_S, 1 << DIR_N | 1 << DIR_S},
+ {0xFF, 1 << DIR_E | 1 << DIR_W, 1 << DIR_E | 1 << DIR_W, 1 << DIR_N | 1 << DIR_S},
+ {1 << DIR_N | 1 << DIR_S, 1 << DIR_N | 1 << DIR_S, 0xFF, 1 << DIR_E | 1 << DIR_W}
+ },
+ {
+ {0xFF, 0xFF, 0xFF, 0xFF},
+ {0xFF, 0xFF, 1 << DIR_E | 1 << DIR_W, 0xFF},
+ {0xFF, 0xFF, 0xFF, 0xFF},
+ {1 << DIR_E | 1 << DIR_W, 0xFF, 0xFF, 0xFF}
+ }
+};
+
+/** Which pylons can definately NOT be built */
+static byte DisallowedPPPofTrackBitAtPCP[TRACK_END][DIAGDIR_END] = {
+ {1 << DIR_SW | 1 << DIR_NE, 0, 1 << DIR_SW | 1 << DIR_NE, 0 }, /* X */
+ {0, 1 << DIR_NW | 1 << DIR_SE, 0, 1 << DIR_NW | 1 << DIR_SE}, /* Y */
+ {1 << DIR_W | 1 << DIR_E, 0, 0, 1 << DIR_W | 1 << DIR_E }, /* UPPER */
+ {0, 1 << DIR_W | 1 << DIR_E, 1 << DIR_W | 1 << DIR_E, 0 }, /* LOWER */
+ {0, 0, 1 << DIR_S | 1 << DIR_N, 1 << DIR_N | 1 << DIR_S }, /* LEFT */
+ {1 << DIR_S | 1 << DIR_N, 1 << DIR_S | 1 << DIR_N, 0, 0, }, /* RIGHT */
+};
+
+typedef struct {
+ SpriteID image;
+ int8 x_offset;
+ int8 y_offset;
+ int8 x_size;
+ int8 y_size;
+ int8 z_size;
+ int8 z_offset;
+} SortableSpriteStruct;
+
+enum {
+ /** Distance between wire and rail */
+ ELRAIL_ELEVATION = 8,
+ /** Corrects an off-by-one error in some places (tileh 12 and 9) (TODO -- find source of error) */
+ ELRAIL_ELEV_CORR = ELRAIL_ELEVATION + 1,
+ /** Wires that a draw one level higher than the north corner. */
+ ELRAIL_ELEVRAISE = ELRAIL_ELEVATION + TILE_HEIGHT
+};
+
+static const SortableSpriteStruct CatenarySpriteData[] = {
+/* X direction */
+ /* Flat tiles: */
+ /* Wires */
+ { SPR_WIRE_X_SW, 0, 8, 16, 1, 1, ELRAIL_ELEVATION }, //! 0: Wire in X direction, pylon on the SW end only
+ { SPR_WIRE_X_NE, 0, 8, 16, 1, 1, ELRAIL_ELEVATION }, //! 1: Wire in X direction, pylon on the NE end
+ { SPR_WIRE_X_SHORT, 0, 8, 16, 1, 1, ELRAIL_ELEVATION }, //! 2: Wire in X direction, pylon on both ends
+
+ /* "up" tiles */
+ /* Wires */
+ { SPR_WIRE_X_SW_UP, 0, 8, 16, 8, 1, ELRAIL_ELEVRAISE }, //! 3: Wire in X pitch up, pylon on the SW end only
+ { SPR_WIRE_X_NE_UP, 0, 8, 16, 8, 1, ELRAIL_ELEVRAISE }, //! 4: Wire in X pitch up, pylon on the NE end
+ { SPR_WIRE_X_SHORT_UP, 0, 8, 16, 8, 1, ELRAIL_ELEVRAISE }, //! 5: Wire in X pitch up, pylon on both ends
+
+ /* "down" tiles */
+ /* Wires */
+ { SPR_WIRE_X_SW_DOWN, 0, 8, 16, 8, 1, ELRAIL_ELEV_CORR }, //! 6: Wire in X pitch down, pylon on the SW end
+ { SPR_WIRE_X_NE_DOWN, 0, 8, 16, 8, 1, ELRAIL_ELEV_CORR }, //! 7: Wire in X pitch down, pylon on the NE end
+ { SPR_WIRE_X_SHORT_DOWN, 0, 8, 16, 8, 1, ELRAIL_ELEV_CORR }, //! 8: Wire in X pitch down, pylon on both ends
+
+
+/* Y direction */
+ /* Flat tiles: */
+ /* Wires */
+ { SPR_WIRE_Y_SE, 8, 0, 1, 16, 1, ELRAIL_ELEVATION }, //! 9: Wire in Y direction, pylon on the SE end only
+ { SPR_WIRE_Y_NW, 8, 0, 1, 16, 1, ELRAIL_ELEVATION }, //!10: Wire in Y direction, pylon on the NW end
+ { SPR_WIRE_Y_SHORT, 8, 0, 1, 16, 1, ELRAIL_ELEVATION }, //!11: Wire in Y direction, pylon on both ends
+
+ /* "up" tiles */
+ /* Wires */
+ { SPR_WIRE_Y_SE_UP, 8, 0, 8, 16, 1, ELRAIL_ELEVRAISE }, //!12: Wire in Y pitch up, pylon on the SE end only
+ { SPR_WIRE_Y_NW_UP, 8, 0, 8, 16, 1, ELRAIL_ELEVRAISE }, //!13: Wire in Y pitch up, pylon on the NW end
+ { SPR_WIRE_Y_SHORT_UP, 8, 0, 8, 16, 1, ELRAIL_ELEVRAISE }, //!14: Wire in Y pitch up, pylon on both ends
+
+ /* "down" tiles */
+ /* Wires */
+ { SPR_WIRE_Y_SE_DOWN, 8, 0, 8, 16, 1, ELRAIL_ELEV_CORR }, //!15: Wire in Y pitch down, pylon on the SE end
+ { SPR_WIRE_Y_NW_DOWN, 8, 0, 8, 16, 1, ELRAIL_ELEV_CORR }, //!16: Wire in Y pitch down, pylon on the NW end
+ { SPR_WIRE_Y_SHORT_DOWN, 8, 0, 8, 16, 1, ELRAIL_ELEV_CORR }, //!17: Wire in Y pitch down, pylon on both ends
+
+/* NS Direction */
+ { SPR_WIRE_NS_SHORT, 8, 0, 8, 8, 1, ELRAIL_ELEVATION }, //!18: LEFT trackbit wire, pylon on both ends
+ { SPR_WIRE_NS_SHORT, 0, 8, 8, 8, 1, ELRAIL_ELEVATION }, //!19: RIGHT trackbit wire, pylon on both ends
+
+ { SPR_WIRE_NS_N, 8, 0, 8, 8, 1, ELRAIL_ELEVATION }, //!20: LEFT trackbit wire, pylon on N end
+ { SPR_WIRE_NS_N, 0, 8, 8, 8, 1, ELRAIL_ELEVATION }, //!21: RIGHT trackbit wire, pylon on N end
+
+ { SPR_WIRE_NS_S, 8, 0, 8, 8, 1, ELRAIL_ELEVATION }, //!22: LEFT trackbit wire, pylon on S end
+ { SPR_WIRE_NS_S, 0, 8, 8, 8, 1, ELRAIL_ELEVATION }, //!23: RIGHT trackbit wire, pylon on S end
+
+/* EW Direction */
+ { SPR_WIRE_EW_SHORT, 8, 0, 8, 8, 1, ELRAIL_ELEVATION }, //!24: UPPER trackbit wire, pylon on both ends
+ { SPR_WIRE_EW_SHORT, 16, 8, 8, 8, 1, ELRAIL_ELEVATION }, //!25: LOWER trackbit wire, pylon on both ends
+
+ { SPR_WIRE_EW_W, 8, 0, 8, 8, 1, ELRAIL_ELEVATION }, //!28: UPPER trackbit wire, pylon on both ends
+ { SPR_WIRE_EW_W, 16, 8, 8, 8, 1, ELRAIL_ELEVATION }, //!29: LOWER trackbit wire, pylon on both ends
+
+ { SPR_WIRE_EW_E, 8, 0, 8, 8, 1, ELRAIL_ELEVATION }, //!32: UPPER trackbit wire, pylon on both ends
+ { SPR_WIRE_EW_E, 16, 8, 8, 8, 1, ELRAIL_ELEVATION }, //!33: LOWER trackbit wire, pylon on both ends
+
+/* Depots */
+ { SPR_WIRE_DEPOT_SW, 0, 8, 8, 1, 1, ELRAIL_ELEVATION }, //!36: Wire for SW depot exit
+ { SPR_WIRE_DEPOT_NW, 8, 0, 1, 8, 1, ELRAIL_ELEVATION }, //!37: Wire for NW depot exit
+ { SPR_WIRE_DEPOT_NE, 0, 8, 8, 1, 1, ELRAIL_ELEVATION }, //!38: Wire for NE depot exit
+ { SPR_WIRE_DEPOT_SE, 8, 0, 1, 8, 1, ELRAIL_ELEVATION }, //!39: Wire for SE depot exit
+};
+
+/** Refers to a certain element of the catenary.
+ * Identifiers for Wires:
+ * <ol><li>Direction of the wire</li>
+ * <li>Slope of the tile for diagonals, placement inside the track for horiz/vertical pieces</li>
+ * <li>Place where a pylon shoule be</li></ol>
+ * Identifiers for Pylons:
+ * <ol><li>Direction of the wire</li>
+ * <li>Slope of the tile</li>
+ * <li>Position of the Pylon relative to the track</li>
+ * <li>Position of the Pylon inside the tile</li></ol>
+ */
+typedef enum {
+ WIRE_X_FLAT_SW,
+ WIRE_X_FLAT_NE,
+ WIRE_X_FLAT_BOTH,
+
+ WIRE_X_UP_SW,
+ WIRE_X_UP_NE,
+ WIRE_X_UP_BOTH,
+
+ WIRE_X_DOWN_SW,
+ WIRE_X_DOWN_NE,
+ WIRE_X_DOWN_BOTH,
+
+ WIRE_Y_FLAT_SE,
+ WIRE_Y_FLAT_NW,
+ WIRE_Y_FLAT_BOTH,
+
+ WIRE_Y_UP_SE,
+ WIRE_Y_UP_NW,
+ WIRE_Y_UP_BOTH,
+
+ WIRE_Y_DOWN_SE,
+ WIRE_Y_DOWN_NW,
+ WIRE_Y_DOWN_BOTH,
+
+ WIRE_NS_W_BOTH,
+ WIRE_NS_E_BOTH,
+
+ WIRE_NS_W_N,
+ WIRE_NS_E_N,
+
+ WIRE_NS_W_S,
+ WIRE_NS_E_S,
+
+ WIRE_EW_N_BOTH,
+ WIRE_EW_S_BOTH,
+
+ WIRE_EW_N_W,
+ WIRE_EW_S_W,
+
+ WIRE_EW_N_E,
+ WIRE_EW_S_E,
+
+ WIRE_DEPOT_SW,
+ WIRE_DEPOT_NW,
+ WIRE_DEPOT_NE,
+ WIRE_DEPOT_SE,
+
+ INVALID_CATENARY = 0xFF
+} CatenarySprite;
+
+/* This array stores which track bits can meet at a tile edge */
+static const Track PPPtracks[DIAGDIR_END][TRACKS_AT_PCP] = {
+ {TRACK_X, TRACK_X, TRACK_UPPER, TRACK_LOWER, TRACK_LEFT, TRACK_RIGHT},
+ {TRACK_Y, TRACK_Y, TRACK_UPPER, TRACK_LOWER, TRACK_LEFT, TRACK_RIGHT},
+ {TRACK_X, TRACK_X, TRACK_UPPER, TRACK_LOWER, TRACK_LEFT, TRACK_RIGHT},
+ {TRACK_Y, TRACK_Y, TRACK_UPPER, TRACK_LOWER, TRACK_LEFT, TRACK_RIGHT},
+};
+
+/* takes each of the 8 track bits from the array above and
+ assigns it to the home tile or neighbour tile */
+static const TileSource trackorigin[DIAGDIR_END][TRACKS_AT_PCP] = {
+ {TS_HOME, TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR, TS_NEIGHBOUR, TS_HOME },
+ {TS_HOME, TS_NEIGHBOUR, TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR, TS_HOME },
+ {TS_HOME, TS_NEIGHBOUR, TS_NEIGHBOUR, TS_HOME , TS_HOME , TS_NEIGHBOUR},
+ {TS_HOME, TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR},
+};
+
+/* Several PPPs maybe exist, here they are sorted in order of preference. */
+static const Direction PPPorder[DIAGDIR_END][TLG_END][DIR_END] = { /* X - Y */
+ { /* PCP 0 */
+ {DIR_NE, DIR_NW, DIR_SE, DIR_SW, DIR_N, DIR_E, DIR_S, DIR_W}, /* evn - evn */
+ {DIR_NE, DIR_SE, DIR_SW, DIR_NW, DIR_S, DIR_W, DIR_N, DIR_E}, /* evn - odd */
+ {DIR_SW, DIR_NW, DIR_NE, DIR_SE, DIR_S, DIR_W, DIR_N, DIR_E}, /* odd - evn */
+ {DIR_SW, DIR_SE, DIR_NE, DIR_NW, DIR_N, DIR_E, DIR_S, DIR_W}, /* odd - odd */
+ }, {/* PCP 1 */
+ {DIR_NE, DIR_NW, DIR_SE, DIR_SW, DIR_S, DIR_E, DIR_N, DIR_W}, /* evn - evn */
+ {DIR_NE, DIR_SE, DIR_SW, DIR_NW, DIR_N, DIR_W, DIR_S, DIR_E}, /* evn - odd */
+ {DIR_SW, DIR_NW, DIR_NE, DIR_SE, DIR_N, DIR_W, DIR_S, DIR_E}, /* odd - evn */
+ {DIR_SW, DIR_SE, DIR_NE, DIR_NW, DIR_S, DIR_E, DIR_N, DIR_W}, /* odd - odd */
+ }, {/* PCP 2 */
+ {DIR_NE, DIR_NW, DIR_SE, DIR_SW, DIR_S, DIR_W, DIR_N, DIR_E}, /* evn - evn */
+ {DIR_NE, DIR_SE, DIR_SW, DIR_NW, DIR_N, DIR_E, DIR_S, DIR_W}, /* evn - odd */
+ {DIR_SW, DIR_NW, DIR_NE, DIR_SE, DIR_N, DIR_E, DIR_S, DIR_W}, /* odd - evn */
+ {DIR_SW, DIR_SE, DIR_NE, DIR_NW, DIR_S, DIR_W, DIR_N, DIR_E}, /* odd - odd */
+ }, {/* PCP 3 */
+ {DIR_NE, DIR_NW, DIR_SE, DIR_SW, DIR_N, DIR_W, DIR_S, DIR_E}, /* evn - evn */
+ {DIR_NE, DIR_SE, DIR_SW, DIR_NW, DIR_S, DIR_E, DIR_N, DIR_W}, /* evn - odd */
+ {DIR_SW, DIR_NW, DIR_NE, DIR_SE, DIR_S, DIR_E, DIR_N, DIR_W}, /* odd - evn */
+ {DIR_SW, DIR_SE, DIR_NE, DIR_NW, DIR_N, DIR_W, DIR_S, DIR_E}, /* odd - odd */
+ }
+};
+/* Geometric placement of the PCP relative to the tile origin */
+static const char x_pcp_offsets[DIAGDIR_END] = {0, 8, 15, 8};
+static const char y_pcp_offsets[DIAGDIR_END] = {8, 15, 8, 0};
+/* Geometric placement of the PPP relative to the PCP*/
+static const char x_ppp_offsets[DIR_END] = {-3, -4, -3, 0, +3, +4, +3, 0};
+static const char y_ppp_offsets[DIR_END] = {-3, 0, +3, +4, +3, 0, -3, -4};
+/* The type of pylon to draw at each PPP */
+static const SpriteID pylons_normal[] = {
+ SPR_PYLON_EW_N,
+ SPR_PYLON_Y_NE,
+ SPR_PYLON_NS_E,
+ SPR_PYLON_X_SE,
+ SPR_PYLON_EW_S,
+ SPR_PYLON_Y_SW,
+ SPR_PYLON_NS_W,
+ SPR_PYLON_X_NW
+};
+
+static const SpriteID pylons_bridge[] = {
+ SPR_PYLON_X_NW,
+ SPR_PYLON_X_SE,
+ SPR_PYLON_Y_NE,
+ SPR_PYLON_Y_SW
+};
+
+/* Maps a track bit onto two PCP positions */
+static const byte PCPpositions[TRACK_END][2] = {
+ {0, 2}, /* X */
+ {1, 3}, /* Y */
+ {3, 0}, /* UPPER */
+ {1, 2}, /* LOWER */
+ {2, 3}, /* LEFT */
+ {0, 1}, /* RIGHT */
+};
+
+/* Selects a Wire (with white and grey ends) depending on whether:
+ a) none (should never happen)
+ b) the first
+ c) the second
+ d) both
+ PCP exists.*/
+static const CatenarySprite Wires[5][TRACK_END][4] = {
+ { /* Tileh == 0 */
+ {INVALID_CATENARY, WIRE_X_FLAT_NE, WIRE_X_FLAT_SW, WIRE_X_FLAT_BOTH},
+ {INVALID_CATENARY, WIRE_Y_FLAT_SE, WIRE_Y_FLAT_NW, WIRE_Y_FLAT_BOTH},
+ {INVALID_CATENARY, WIRE_EW_N_W, WIRE_EW_N_E, WIRE_EW_N_BOTH},
+ {INVALID_CATENARY, WIRE_EW_S_E, WIRE_EW_S_W, WIRE_EW_S_BOTH},
+ {INVALID_CATENARY, WIRE_NS_W_S, WIRE_NS_W_N, WIRE_NS_W_BOTH},
+ {INVALID_CATENARY, WIRE_NS_E_N, WIRE_NS_E_S, WIRE_NS_E_BOTH},
+ }, { /* Tileh == 3 */
+ {INVALID_CATENARY, WIRE_X_UP_NE, WIRE_X_UP_SW, WIRE_X_UP_BOTH},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ }, { /* Tileh == 6 */
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, WIRE_Y_UP_SE, WIRE_Y_UP_NW, WIRE_Y_UP_BOTH},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ }, { /* Tileh == 9 */
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, WIRE_Y_DOWN_SE, WIRE_Y_DOWN_NW, WIRE_Y_DOWN_BOTH},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ }, { /* Tileh == 12 */
+ {INVALID_CATENARY, WIRE_X_DOWN_NE, WIRE_X_DOWN_SW, WIRE_X_DOWN_BOTH},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ {INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY, INVALID_CATENARY},
+ }
+};
+
+#endif /* ELRAIL_DATA_H */
+
diff --git a/table/engines.h b/table/engines.h
index b8fe40190..dc33ebafa 100644
--- a/table/engines.h
+++ b/table/engines.h
@@ -27,11 +27,13 @@
// Rail types
// R = Conventional railway
+// E = Electrified railway
// M = Monorail
// L = MagLev
#define R 0
-#define M 1
-#define L 2
+#define E 1
+#define M 2
+#define L 3
// Climates
// T = Temperate
// A = Arctic
@@ -65,10 +67,10 @@ const EngineInfo orig_engine_info[] = {
MK( 20454, 20, 22, 30, R, A|S ), /* 20 Turner Turbo (Diesel) */
MK( 16071, 20, 22, 30, R, A|S ), /* 21 MJS 1000 (Diesel) */
MK( 20820, 20, 20, 25, R, T ), /* 22 SH '125' (Diesel) */
- MK( 16437, 20, 23, 30, R, T ), /* 23 SH '30' (Electric) */
- MK( 19359, 20, 23, 80, R, T ), /* 24 SH '40' (Electric) */
- MK( 23376, 20, 25, 30, R, T ), /* 25 'T.I.M.' (Electric) */
- MK( 26298, 20, 25, 50, R, T ), /* 26 'AsiaStar' (Electric) */
+ MK( 16437, 20, 23, 30, E, T ), /* 23 SH '30' (Electric) */
+ MK( 19359, 20, 23, 80, E, T ), /* 24 SH '40' (Electric) */
+ MK( 23376, 20, 25, 30, E, T ), /* 25 'T.I.M.' (Electric) */
+ MK( 26298, 20, 25, 50, E, T ), /* 26 'AsiaStar' (Electric) */
MW( 1827, 20, 20, 50, R, T|A|S|Y), /* 27 Passenger Carriage */
MW( 1827, 20, 20, 50, R, T|A|S|Y), /* 28 Mail Van */
MW( 1827, 20, 20, 50, R, T|A ), /* 29 Coal Truck */
@@ -306,6 +308,7 @@ const EngineInfo orig_engine_info[] = {
#undef L
#undef M
#undef R
+#undef E
/** Writes the properties of a rail vehicle into the RailVehicleInfo struct.
* @see RailVehicleInfo
diff --git a/table/landscape_const.h b/table/landscape_const.h
index d7c3179e7..8cf1083c0 100644
--- a/table/landscape_const.h
+++ b/table/landscape_const.h
@@ -42,13 +42,6 @@ static const LandscapePredefVar _landscape_predef_var[4] = {
24, 255, 90, 255, 18, 28, 40, 255, 255, 255, 32, 30,
},
- /* normal railveh by cargo */
- {
- {27, 29, 28, 30, 31, 32, 33, 34, 35, 36, 37, 38},
- {57, 59, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68},
- {89, 91, 90, 92, 93, 94, 95, 96, 97, 98, 99, 100}
- },
-
/* normal road veh by cargo start & count */
{116, 123, 126, 132, 135, 138, 141, 144, 147, 150, 153, 156},
{7, 3, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3}
@@ -95,14 +88,6 @@ static const LandscapePredefVar _landscape_predef_var[4] = {
24, 255, 90, 255, 18, 28, 40, 255, 255, 60, 40, 30
},
- /* hilly railveh by cargo */
- {
- {27, 29, 28, 30, 31, 32, 33, 34, 35, 39, 37, 38},
- {57, 59, 58, 60, 61, 62, 63, 64, 65, 69, 67, 68},
- {89, 91, 90, 92, 93, 94, 95, 96, 97, 101, 99, 100}
- },
-
-
/* hilly road veh by cargo start & count */
{116, 123, 126, 132, 135, 138, 141, 144, 147, 159, 153, 156},
{7, 3, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3},
@@ -150,13 +135,6 @@ static const LandscapePredefVar _landscape_predef_var[4] = {
24, 20, 90, 255, 15, 28, 40, 255, 255, 80, 255, 30
},
- /* desert railveh by cargo */
- {
- {27, 43, 28, 30, 42, 32, 33, 34, 40, 41, 37, 38},
- {57, 73, 58, 60, 72, 62, 63, 64, 70, 71, 67, 68},
- {89, 105, 90, 92, 104, 94, 95, 96, 102, 103, 99, 100}
- },
-
/* desert road veh by cargo start & count */
{116, 171, 126, 132, 168, 138, 141, 144, 162, 165, 153, 156},
{7, 3, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3}
@@ -203,13 +181,6 @@ static const LandscapePredefVar _landscape_predef_var[4] = {
24, 255, 90, 255, 30, 40, 60, 75, 25, 80, 255, 50
},
- /* candy railveh by cargo */
- {
- {27, 44, 28, 50, 51, 49, 46, 48, 45, 47, 53, 52},
- {57, 74, 58, 80, 81, 79, 76, 78, 75, 77, 83, 82},
- {89, 106, 90, 112, 113, 111, 108, 110, 107, 109, 115, 114}
- },
-
/* candy road veh by cargo start & count */
{116, 174, 126, 186, 192, 189, 183, 177, 180, 201, 198, 195},
{7, 3, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3}
diff --git a/table/sprites.h b/table/sprites.h
index 34fda3f64..f7e0817c2 100644
--- a/table/sprites.h
+++ b/table/sprites.h
@@ -51,7 +51,8 @@ enum Sprites {
SPR_CANALS_BASE = 5382,
SPR_SLOPES_BASE = SPR_CANALS_BASE + 70,
SPR_AUTORAIL_BASE = SPR_SLOPES_BASE + 78,
- SPR_2CCMAP_BASE = SPR_AUTORAIL_BASE + 55,
+ SPR_ELRAIL_BASE = SPR_AUTORAIL_BASE + 55,
+ SPR_2CCMAP_BASE = SPR_ELRAIL_BASE + 53,
SPR_OPENTTD_BASE = SPR_2CCMAP_BASE + 256,
SPR_BLOT = SPR_OPENTTD_BASE + 29, // colored circle (mainly used as vehicle profit marker and for sever compatibility)
@@ -206,6 +207,54 @@ enum Sprites {
OFFSET_TILEH_13 = 19,
OFFSET_TILEH_14 = 16,
+ /* Elrail stuff */
+ /* Wires. First identifier is the direction of the track, second is the required placement of the pylon.
+ "short" denotes a wire that requires a pylon on each end. Third identifier is the direction of the slope
+ (in positive coordinate direction) */
+ SPR_WIRE_X_SHORT = SPR_ELRAIL_BASE + 3,
+ SPR_WIRE_Y_SHORT = SPR_ELRAIL_BASE + 4,
+ SPR_WIRE_EW_SHORT = SPR_ELRAIL_BASE + 5,
+ SPR_WIRE_NS_SHORT = SPR_ELRAIL_BASE + 6,
+ SPR_WIRE_X_SHORT_DOWN = SPR_ELRAIL_BASE + 7,
+ SPR_WIRE_Y_SHORT_UP = SPR_ELRAIL_BASE + 8,
+ SPR_WIRE_X_SHORT_UP = SPR_ELRAIL_BASE + 9,
+ SPR_WIRE_Y_SHORT_DOWN = SPR_ELRAIL_BASE + 10,
+
+ SPR_WIRE_X_SW = SPR_ELRAIL_BASE + 11,
+ SPR_WIRE_Y_SE = SPR_ELRAIL_BASE + 12,
+ SPR_WIRE_EW_E = SPR_ELRAIL_BASE + 13,
+ SPR_WIRE_NS_S = SPR_ELRAIL_BASE + 14,
+ SPR_WIRE_X_SW_DOWN = SPR_ELRAIL_BASE + 15,
+ SPR_WIRE_Y_SE_UP = SPR_ELRAIL_BASE + 16,
+ SPR_WIRE_X_SW_UP = SPR_ELRAIL_BASE + 17,
+ SPR_WIRE_Y_SE_DOWN = SPR_ELRAIL_BASE + 18,
+
+ SPR_WIRE_X_NE = SPR_ELRAIL_BASE + 19,
+ SPR_WIRE_Y_NW = SPR_ELRAIL_BASE + 20,
+ SPR_WIRE_EW_W = SPR_ELRAIL_BASE + 21,
+ SPR_WIRE_NS_N = SPR_ELRAIL_BASE + 22,
+ SPR_WIRE_X_NE_DOWN = SPR_ELRAIL_BASE + 23,
+ SPR_WIRE_Y_NW_UP = SPR_ELRAIL_BASE + 24,
+ SPR_WIRE_X_NE_UP = SPR_ELRAIL_BASE + 25,
+ SPR_WIRE_Y_NW_DOWN = SPR_ELRAIL_BASE + 26,
+
+ /* Tunnel entries */
+ SPR_WIRE_DEPOT_SW = SPR_ELRAIL_BASE + 27,
+ SPR_WIRE_DEPOT_NW = SPR_ELRAIL_BASE + 28,
+ SPR_WIRE_DEPOT_NE = SPR_ELRAIL_BASE + 29,
+ SPR_WIRE_DEPOT_SE = SPR_ELRAIL_BASE + 30,
+
+
+ /* Pylons, first identifier is the direction of the track, second the placement relative to the track */
+ SPR_PYLON_Y_NE = SPR_ELRAIL_BASE + 31,
+ SPR_PYLON_Y_SW = SPR_ELRAIL_BASE + 32,
+ SPR_PYLON_X_NW = SPR_ELRAIL_BASE + 33,
+ SPR_PYLON_X_SE = SPR_ELRAIL_BASE + 34,
+ SPR_PYLON_EW_N = SPR_ELRAIL_BASE + 35,
+ SPR_PYLON_EW_S = SPR_ELRAIL_BASE + 36,
+ SPR_PYLON_NS_W = SPR_ELRAIL_BASE + 37,
+ SPR_PYLON_NS_E = SPR_ELRAIL_BASE + 38,
+
/* sprites for airports and airfields*/
/* Small airports are AIRFIELD, everything else is AIRPORT */
SPR_HELIPORT = 2633,
@@ -955,6 +1004,13 @@ enum Sprites {
SPR_BUBBLE_ABSORB_3 = 4761,
SPR_BUBBLE_ABSORB_4 = 4762,
+ /* Electrified rail build menu */
+ SPR_BUILD_NS_ELRAIL = SPR_ELRAIL_BASE + 39,
+ SPR_BUILD_X_ELRAIL = SPR_ELRAIL_BASE + 40,
+ SPR_BUILD_EW_ELRAIL = SPR_ELRAIL_BASE + 41,
+ SPR_BUILD_Y_ELRAIL = SPR_ELRAIL_BASE + 42,
+ SPR_BUILD_TUNNEL_ELRAIL = SPR_ELRAIL_BASE + 47,
+
/* road_gui.c */
SPR_IMG_ROAD_NW = 1309,
SPR_IMG_ROAD_NE = 1310,
@@ -1034,9 +1090,15 @@ typedef enum CursorSprites {
SPR_CURSOR_EW_MAGLEV = 1273,
SPR_CURSOR_NWSE_MAGLEV = 1274,
+ SPR_CURSOR_NS_ELRAIL = SPR_ELRAIL_BASE + 43,
+ SPR_CURSOR_SWNE_ELRAIL = SPR_ELRAIL_BASE + 44,
+ SPR_CURSOR_EW_ELRAIL = SPR_ELRAIL_BASE + 45,
+ SPR_CURSOR_NWSE_ELRAIL = SPR_ELRAIL_BASE + 46,
+
SPR_CURSOR_RAIL_STATION = 1300,
SPR_CURSOR_TUNNEL_RAIL = 2434,
+ SPR_CURSOR_TUNNEL_ELRAIL = SPR_ELRAIL_BASE + 48,
SPR_CURSOR_TUNNEL_MONO = 2435,
SPR_CURSOR_TUNNEL_MAGLEV = 2436,