Loading

Revision differences

Old revision #pbfwpiqdiNew revision #pae1wjqpy
21    if (!IsValidTile(opposite_tile)) return false;  21    if (!IsValidTile(opposite_tile)) return false;  
22  22  
23    /* Test adjacent tiles are traversible. */  23    /* Test adjacent tiles are traversible. */  
24    Track track = TrackBitsToTrack(TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0)));  24    Track track = TrackBitsToTrack(GetTileShipTrackStatus(tile));
25    Trackdir main_trackdir = TrackToTrackdir(track);  25    Trackdir main_trackdir = TrackToTrackdir(track);  
26  26  
27    DiagDirection main_dir_1 = TrackdirToExitdir(main_trackdir);  27    DiagDirection main_dir_1 = TrackdirToExitdir(main_trackdir);  
28    DiagDirection main_dir_2 = TrackdirToExitdir(ReverseTrackdir(main_trackdir));  28    DiagDirection main_dir_2 = TrackdirToExitdir(ReverseTrackdir(main_trackdir));  
29  29  
30    TrackBits trackbits_1 = TrackStatusToTrackBits(GetTileTrackStatus(AddTileIndexDiffCWrap(tile, TileIndexDiffCByDiagDir(main_dir_1)), TRANSPORT_WATER, 0));  30    TrackBits trackbits_1 = GetTileShipTrackStatus(AddTileIndexDiffCWrap(tile, TileIndexDiffCByDiagDir(main_dir_1)));
31    TrackBits trackbits_2 = TrackStatusToTrackBits(GetTileTrackStatus(AddTileIndexDiffCWrap(tile, TileIndexDiffCByDiagDir(main_dir_2)), TRANSPORT_WATER, 0));  31    TrackBits trackbits_2 = GetTileShipTrackStatus(AddTileIndexDiffCWrap(tile, TileIndexDiffCByDiagDir(main_dir_2)));
32  32  
33    TrackBits main_track_1 = trackbits_1 & DiagdirReachesTracks(main_dir_1);  33    TrackBits main_track_1 = trackbits_1 & DiagdirReachesTracks(main_dir_1);  
34    TrackBits main_track_2 = trackbits_2 & DiagdirReachesTracks(main_dir_2);  34    TrackBits main_track_2 = trackbits_2 & DiagdirReachesTracks(main_dir_2);  
  
37    if (!main_track_1 || !main_track_2) return false;  37    if (!main_track_1 || !main_track_2) return false;  
38  38  
39    Track opposite_track = TrackToOppositeTrack(track);  39    Track opposite_track = TrackToOppositeTrack(track);  
40    
41    Trackdir oppo_trackdir = TrackToTrackdir(opposite_track);  40    Trackdir oppo_trackdir = TrackToTrackdir(opposite_track);  
42  41  
43    TrackBits oppo_track_1 = trackbits_1 & DiagdirReachesTracks(TrackdirToExitdir(oppo_trackdir));  42    TrackBits oppo_track_1 = trackbits_1 & DiagdirReachesTracks(TrackdirToExitdir(oppo_trackdir));  
  
45  44  
46    TrackBits mirror = TRACK_BIT_CROSS | (corner & 1 ? TRACK_BIT_HORZ : TRACK_BIT_VERT);  45    TrackBits mirror = TRACK_BIT_CROSS | (corner & 1 ? TRACK_BIT_HORZ : TRACK_BIT_VERT);  
47  46  
48    /* Is there a connection between tile_1 and tile_2 via opposite_tile? */  48    /* Is opposite tile connected to adjacent tiles? */
49    if (HasTrack(TrackStatusToTrackBits(GetTileTrackStatus(opposite_tile, TRANSPORT_WATER, 0)), opposite_track) &&  49    if (HasTrack(GetTileShipTrackStatus(opposite_tile), opposite_track) &&
50            oppo_track_1 & (main_track_1 ^ mirror) && oppo_track_2 & (main_track_2 ^ mirror)) return false;  49            oppo_track_1 & (main_track_1 ^ mirror) && oppo_track_2 & (main_track_2 ^ mirror)) return false;  
51  50  
52    /* There is either no track or an incomplete connection via opposite_tile. */  52    /* There is either no track or an incomplete connection via opposite tile. */
53    return true;  52    return true;  
54} 53}