src/newgrf_station.cpp
changeset 9662 d21460a10105
parent 9038 38f0f10f8cca
child 9714 5d785e184f2d
equal deleted inserted replaced
9661:7bfc9b673b17 9662:d21460a10105
    23 #include "gfx_func.h"
    23 #include "gfx_func.h"
    24 #include "date_func.h"
    24 #include "date_func.h"
    25 #include "player_func.h"
    25 #include "player_func.h"
    26 #include "animated_tile_func.h"
    26 #include "animated_tile_func.h"
    27 #include "functions.h"
    27 #include "functions.h"
       
    28 #include "tunnelbridge_map.h"
    28 
    29 
    29 #include "table/sprites.h"
    30 #include "table/sprites.h"
    30 #include "table/strings.h"
    31 #include "table/strings.h"
    31 
    32 
    32 static StationClass _station_classes[STAT_CLASS_MAX];
    33 static StationClass _station_classes[STAT_CLASS_MAX];
   292 
   293 
   293 	uint32 res = 0;
   294 	uint32 res = 0;
   294 	uint i;
   295 	uint i;
   295 
   296 
   296 	for (i = 0; i < lengthof(x_dir); i++, dir++, diagdir++) {
   297 	for (i = 0; i < lengthof(x_dir); i++, dir++, diagdir++) {
   297 		TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(tile + TileOffsByDir(*dir), TRANSPORT_RAIL, 0));
   298 		TileIndex neighbour_tile = tile + TileOffsByDir(*dir);
       
   299 		TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(neighbour_tile, TRANSPORT_RAIL, 0));
   298 		if (trackbits != TRACK_BIT_NONE) {
   300 		if (trackbits != TRACK_BIT_NONE) {
   299 			/* If there is any track on the tile, set the bit in the second byte */
   301 			/* If there is any track on the tile, set the bit in the second byte */
   300 			SetBit(res, i + 8);
   302 			SetBit(res, i + 8);
       
   303 
       
   304 			/* With tunnels and bridges the tile has tracks, but they are not necessarily connected
       
   305 			 * with the next tile because the ramp is not going in the right direction. */
       
   306 			if (IsTileType(neighbour_tile, MP_TUNNELBRIDGE) && GetTunnelBridgeDirection(neighbour_tile) != *diagdir) {
       
   307 				continue;
       
   308 			}
   301 
   309 
   302 			/* If any track reaches our exit direction, set the bit in the lower byte */
   310 			/* If any track reaches our exit direction, set the bit in the lower byte */
   303 			if (trackbits & DiagdirReachesTracks(*diagdir)) SetBit(res, i);
   311 			if (trackbits & DiagdirReachesTracks(*diagdir)) SetBit(res, i);
   304 		}
   312 		}
   305 	}
   313 	}