(svn r9077) -Fix [FS#612]: the wrong catenary wires were drawn for tunnel entrances.
authorrubidium
Fri, 09 Mar 2007 14:41:39 +0000
changeset 6268 437cf82d933b
parent 6267 9e015326c7fb
child 6269 3e10e20eecff
(svn r9077) -Fix [FS#612]: the wrong catenary wires were drawn for tunnel entrances.
src/elrail.cpp
src/table/elrail_data.h
src/table/sprites.h
--- a/src/elrail.cpp	Fri Mar 09 10:12:08 2007 +0000
+++ b/src/elrail.cpp	Fri Mar 09 14:41:39 2007 +0000
@@ -125,7 +125,7 @@
 {
 	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 		if (IsTunnel(tile)) {
-			*tileh = SLOPE_FLAT;
+			*tileh = SLOPE_STEEP; /* XXX - Hack to make tunnel entrances to always have a pylon */
 		} else {
 			if (*tileh != SLOPE_FLAT) {
 				*tileh = SLOPE_FLAT;
@@ -291,7 +291,16 @@
 	/* Drawing of pylons is finished, now draw the wires */
 	for (t = TRACK_BEGIN; t < TRACK_END; t++) {
 		if (HASBIT(trackconfig[TS_HOME], t)) {
+			if (IsTunnelTile(ti->tile)) {
+				const SortableSpriteStruct* sss = &CatenarySpriteData_Tunnel[GetTunnelDirection(ti->tile)];
 
+				AddSortableSpriteToDraw(
+					sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
+					sss->x_size, sss->y_size, sss->z_size,
+					GetTileZ(ti->tile) + sss->z_offset
+				);
+				break;
+			}
 			byte PCPconfig = HASBIT(PCPstatus, PCPpositions[t][0]) +
 				(HASBIT(PCPstatus, PCPpositions[t][1]) << 1);
 
@@ -371,7 +380,7 @@
 
 	switch (GetTileType(ti->tile)) {
 		case MP_RAILWAY:
-			if (IsRailDepot(ti->tile)) {
+			if ( IsRailDepot(ti->tile)) {
 				const SortableSpriteStruct* sss = &CatenarySpriteData_Depot[GetRailDepotDirection(ti->tile)];
 
 				AddSortableSpriteToDraw(
--- a/src/table/elrail_data.h	Fri Mar 09 10:12:08 2007 +0000
+++ b/src/table/elrail_data.h	Fri Mar 09 14:41:39 2007 +0000
@@ -340,6 +340,14 @@
 	{ SPR_WIRE_DEPOT_NW,      8,  0,  1,  8,  1, ELRAIL_ELEVATION }  //! Wire for NW depot exit
 };
 
+static const SortableSpriteStruct CatenarySpriteData_Tunnel[] = {
+	{ SPR_WIRE_TUNNEL_NE,      0,  8,  8,  1,  1, ELRAIL_ELEVATION }, //! Wire for NE tunnel exit
+	{ SPR_WIRE_TUNNEL_SE,      8,  0,  1,  8,  1, ELRAIL_ELEVATION }, //! Wire for SE tunnel exit
+	{ SPR_WIRE_TUNNEL_SW,      0,  8,  8,  1,  1, ELRAIL_ELEVATION }, //! Wire for SW tunnel exit
+	{ SPR_WIRE_TUNNEL_NW,      8,  0,  1,  8,  1, ELRAIL_ELEVATION }  //! Wire for NW tunnel exit
+};
+
+
 /** Refers to a certain element of the catenary.
  * Identifiers for Wires:
  * <ol><li>Direction of the wire</li>
--- a/src/table/sprites.h	Fri Mar 09 10:12:08 2007 +0000
+++ b/src/table/sprites.h	Fri Mar 09 14:41:39 2007 +0000
@@ -291,6 +291,12 @@
 	SPR_WIRE_Y_NW_DOWN = SPR_ELRAIL_BASE + 26,
 
 	/* Tunnel entries */
+	SPR_WIRE_TUNNEL_NE = SPR_ELRAIL_BASE + 27,
+	SPR_WIRE_TUNNEL_SE = SPR_ELRAIL_BASE + 28,
+	SPR_WIRE_TUNNEL_SW = SPR_ELRAIL_BASE + 29,
+	SPR_WIRE_TUNNEL_NW = SPR_ELRAIL_BASE + 30,
+
+	/* Depot 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,