File diff r18261:0aa61ca7490f → r18262:3bc00eb1e3da
src/elrail.cpp
Show inline comments
 
@@ -200,41 +200,41 @@ static void AdjustTileh(TileIndex tile, 
 
			*tileh = InclinedSlope(GetTunnelBridgeDirection(tile));
 
		}
 
	}
 
}
 

	
 
/**
 
 * Returns the Z position of a Pylon Control Point.
 
 *
 
 * @param tile The tile the pylon should stand on.
 
 * @param PCPpos The PCP of the tile.
 
 * @return The Z position of the PCP.
 
 */
 
static byte GetPCPElevation(TileIndex tile, DiagDirection PCPpos)
 
static int GetPCPElevation(TileIndex tile, DiagDirection PCPpos)
 
{
 
	/* The elevation of the "pylon"-sprite should be the elevation at the PCP.
 
	 * PCPs are always on a tile edge.
 
	 *
 
	 * This position can be outside of the tile, i.e. ?_pcp_offset == TILE_SIZE > TILE_SIZE - 1.
 
	 * So we have to move it inside the tile, because if the neighboured tile has a foundation,
 
	 * that does not smoothly connect to the current tile, we will get a wrong elevation from GetSlopePixelZ().
 
	 *
 
	 * When we move the position inside the tile, we will get a wrong elevation if we have a slope.
 
	 * To catch all cases we round the Z position to the next (TILE_HEIGHT / 2).
 
	 * This will return the correct elevation for slopes and will also detect non-continuous elevation on edges.
 
	 *
 
	 * Also note that the result of GetSlopePixelZ() is very special on bridge-ramps.
 
	 */
 

	
 
	byte z = GetSlopePixelZ(TileX(tile) * TILE_SIZE + min(x_pcp_offsets[PCPpos], TILE_SIZE - 1), TileY(tile) * TILE_SIZE + min(y_pcp_offsets[PCPpos], TILE_SIZE - 1));
 
	int z = GetSlopePixelZ(TileX(tile) * TILE_SIZE + min(x_pcp_offsets[PCPpos], TILE_SIZE - 1), TileY(tile) * TILE_SIZE + min(y_pcp_offsets[PCPpos], TILE_SIZE - 1));
 
	return (z + 2) & ~3; // this means z = (z + TILE_HEIGHT / 4) / (TILE_HEIGHT / 2) * (TILE_HEIGHT / 2);
 
}
 

	
 
/**
 
 * Draws wires on a tunnel tile
 
 *
 
 * DrawTile_TunnelBridge() calls this function to draw the wires as SpriteCombine with the tunnel roof.
 
 *
 
 * @param ti The Tileinfo to draw the tile for
 
 */
 
void DrawCatenaryOnTunnel(const TileInfo *ti)
 
{