src/elrail.cpp
branchgamebalance
changeset 9895 7bd07f43b0e3
parent 6498 aff910a05c6e
child 6307 f40e88cff863
--- a/src/elrail.cpp	Mon Mar 19 09:33:17 2007 +0000
+++ b/src/elrail.cpp	Mon Mar 19 12:38:16 2007 +0000
@@ -125,18 +125,16 @@
 {
 	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 		if (IsTunnel(tile)) {
+			*tileh = SLOPE_STEEP; // XXX - Hack to make tunnel entrances to always have a pylon
+		} else if (*tileh != SLOPE_FLAT) {
 			*tileh = SLOPE_FLAT;
 		} else {
-			if (*tileh != SLOPE_FLAT) {
-				*tileh = SLOPE_FLAT;
-			} else {
-				switch (GetBridgeRampDirection(tile)) {
-					case DIAGDIR_NE: *tileh = SLOPE_NE; break;
-					case DIAGDIR_SE: *tileh = SLOPE_SE; break;
-					case DIAGDIR_SW: *tileh = SLOPE_SW; break;
-					case DIAGDIR_NW: *tileh = SLOPE_NW; break;
-					default: NOT_REACHED();
-				}
+			switch (GetBridgeRampDirection(tile)) {
+				case DIAGDIR_NE: *tileh = SLOPE_NE; break;
+				case DIAGDIR_SE: *tileh = SLOPE_SE; break;
+				case DIAGDIR_SW: *tileh = SLOPE_SW; break;
+				case DIAGDIR_NW: *tileh = SLOPE_NW; break;
+				default: NOT_REACHED();
 			}
 		}
 	}
@@ -187,7 +185,7 @@
 		if (IsTunnelTile(neighbour) && i != GetTunnelDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE;
 		isflat[TS_NEIGHBOUR] = ((trackconfig[TS_NEIGHBOUR] & (TRACK_BIT_HORZ | TRACK_BIT_VERT)) != 0);
 
-		PPPpreferred[i] = 0xFF; /* We start with preferring everything (end-of-line in any direction) */
+		PPPpreferred[i] = 0xFF; // We start with preferring everything (end-of-line in any direction)
 		PPPallowed[i] = AllowedPPPonPCP[i];
 
 		/* We cycle through all the existing tracks at a PCP and see what
@@ -206,7 +204,7 @@
 				/* track found, if track is in the neighbour tile, adjust the number
 				 * of the PCP for preferred/allowed determination*/
 				DiagDirection PCPpos = (TrackSourceTile[i][k] == TS_HOME) ? i : ReverseDiagDir(i);
-				SETBIT(PCPstatus, i); /* This PCP is in use */
+				SETBIT(PCPstatus, i); // This PCP is in use
 
 				PPPpreferred[i] &= PreferredPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos];
 				PPPallowed[i] &= ~DisallowedPPPofTrackAtPCP[TracksAtPCP[i][k]][PCPpos];
@@ -227,11 +225,7 @@
 		}
 
 		if (foundation != 0) {
-			if (foundation < 15) {
-				tileh[TS_NEIGHBOUR] = SLOPE_FLAT;
-			} else {
-				tileh[TS_NEIGHBOUR] = _inclined_tileh[foundation - 15];
-			}
+			tileh[TS_NEIGHBOUR] = foundation < 15 ? SLOPE_FLAT : _inclined_tileh[foundation - 15];
 		}
 
 		AdjustTileh(neighbour, &tileh[TS_NEIGHBOUR]);
@@ -255,7 +249,9 @@
 			uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
 
 			if ((height <= TilePixelHeight(ti->tile) + TILE_HEIGHT) &&
-			(i == PCPpositions[bridgetrack][0] || i == PCPpositions[bridgetrack][1])) SETBIT(OverridePCP, i);
+					(i == PCPpositions[bridgetrack][0] || i == PCPpositions[bridgetrack][1])) {
+				SETBIT(OverridePCP, i);
+			}
 		}
 
 		if (PPPallowed[i] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) {
@@ -291,7 +287,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);
 
@@ -372,7 +377,7 @@
 	switch (GetTileType(ti->tile)) {
 		case MP_RAILWAY:
 			if (IsRailDepot(ti->tile)) {
-				const SortableSpriteStruct* sss = &CatenarySpriteData_Depot[GetRailDepotDirection(ti->tile)];
+				const SortableSpriteStruct *sss = &CatenarySpriteData_Depot[GetRailDepotDirection(ti->tile)];
 
 				AddSortableSpriteToDraw(
 					sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
@@ -396,7 +401,7 @@
 int32 SettingsDisableElrail(int32 p1)
 {
 	EngineID e_id;
-	Vehicle* v;
+	Vehicle *v;
 	Player *p;
 	bool disable = (p1 != 0);
 
@@ -418,7 +423,7 @@
 	*  normal rail too */
 	if (disable) {
 		FOR_ALL_VEHICLES(v) {
-			if (v->type == VEH_Train && v->u.rail.railtype == RAILTYPE_ELECTRIC) {
+			if (v->type == VEH_TRAIN && v->u.rail.railtype == RAILTYPE_ELECTRIC) {
 				/* this railroad vehicle is now compatible only with elrail,
 				*  so add there also normal rail compatibility */
 				v->u.rail.compatible_railtypes |= (1 << RAILTYPE_RAIL);
@@ -431,7 +436,7 @@
 	/* setup total power for trains */
 	FOR_ALL_VEHICLES(v) {
 		/* power is cached only for front engines */
-		if (v->type == VEH_Train && IsFrontEngine(v)) TrainPowerChanged(v);
+		if (v->type == VEH_TRAIN && IsFrontEngine(v)) TrainPowerChanged(v);
 	}
 
 	FOR_ALL_PLAYERS(p) p->avail_railtypes = GetPlayerRailtypes(p->index);