Loading

Revision differences

Old revision #pktd4qic5New revision #pmf3ej2io
6 */  6 */  
7static bool PeterNGrowingBlocksWaterConnection(TileIndex tile)  7static bool PeterNGrowingBlocksWaterConnection(TileIndex tile)  
8{  8{  
9    if (!IsValidTile(tile)) return false;  9    if (!IsValidTile(tile) || !IsCoastTile(tile)) return false;
10    if (!IsCoastTile(tile)) return false;    
11  10  
12    Slope slope = GetTileSlope(tile);  11    Slope slope = GetTileSlope(tile);  
13  12  
  
17    Track track = TrackBitsToTrack(TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0)));  16    Track track = TrackBitsToTrack(TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0)));  
18    Trackdir trackdir = TrackToTrackdir(track);  17    Trackdir trackdir = TrackToTrackdir(track);  
19  18  
20    Corner corner = GetHighestSlopeCorner(slope);  20    /* Test opposite tile is valid */
21    static const Direction corner_to_direction[] = { DIR_W, DIR_S, DIR_E, DIR_N };  20    static const Direction corner_to_direction[] = { DIR_W, DIR_S, DIR_E, DIR_N };  
22  22    TileIndex tile_o = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDir(corner_to_direction[OppositeCorner(GetHighestSlopeCorner(slope))]));
23    /* Test adjacent tiles are valid */    
24    TileIndex tile_a = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDiagDir(TrackdirToExitdir(trackdir)));    
25    if (!IsValidTile(tile_a)) return false;    
26    TileIndex tile_b = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDiagDir(TrackdirToExitdir(ReverseTrackdir(trackdir))));    
27    if (!IsValidTile(tile_b)) return false;    
28    TileIndex tile_o = AddTileIndexDiffCWrap(tile, TileIndexDiffCByDir(corner_to_direction[OppositeCorner(corner)]));    
29    if (!IsValidTile(tile_o)) return false;  22    if (!IsValidTile(tile_o)) return false;  
30  23  
31    /* Test adjacent tiles are traversible. */  24    /* Test adjacent tiles are traversible. */  
32    if (TrackStatusToTrackBits(GetTileTrackStatus(tile_a, TRANSPORT_WATER, 0)) == TRACK_BIT_NONE) return false;  32    if (TrackStatusToTrackBits(GetTileTrackStatus(AddTileIndexDiffCWrap(tile, TileIndexDiffCByDiagDir(TrackdirToExitdir(trackdir))), TRANSPORT_WATER, 0)) == TRACK_BIT_NONE) return false;
33    if (TrackStatusToTrackBits(GetTileTrackStatus(tile_b, TRANSPORT_WATER, 0)) == TRACK_BIT_NONE) return false;  33    if (TrackStatusToTrackBits(GetTileTrackStatus(AddTileIndexDiffCWrap(tile, TileIndexDiffCByDiagDir(TrackdirToExitdir(ReverseTrackdir(trackdir)))), TRANSPORT_WATER, 0)) == TRACK_BIT_NONE) return false;
34  27  
35    /* If they are, test opposite tile has connecting track. */  28    /* If they are, test opposite tile has connecting track. */  
36    TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(tile_o, TRANSPORT_WATER, 0));  36    if (HasBit(TrackStatusToTrackBits(GetTileTrackStatus(tile_o, TRANSPORT_WATER, 0)), TrackToOppositeTrack(track))) return false;
37    if (HasBit(trackbits, TrackToOppositeTrack(track))) return false;    
38  30  
39    /* Over building would block a route, so deny it. */  31    /* Over building would block a route, so deny it. */  
40    return true;  32    return true;