| | 1 | struct { TileIndexDiff opposite_tile, next_tile_1, next_tile_2; TrackBits opposite_track, next_track_1, next_track_2; } table[] = {
|
---|
| | 2 | { TileDiffXY(-1, 1), TileDiffXY( 0, 1), TileDiffXY(-1, 0), TRACK_BIT_LEFT, _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_RIGHT : TRACK_BIT_3WAY_NE, _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_RIGHT : TRACK_BIT_3WAY_SE },
|
---|
| | 3 | { TileDiffXY(-1, -1), TileDiffXY(-1, 0), TileDiffXY( 0, -1), TRACK_BIT_LOWER, _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_UPPER : TRACK_BIT_3WAY_NW, _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_UPPER : TRACK_BIT_3WAY_NE },
|
---|
| | 4 | { TileDiffXY( 1, -1), TileDiffXY( 0, -1), TileDiffXY( 1, 0), TRACK_BIT_RIGHT, _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_LEFT : TRACK_BIT_3WAY_SW, _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_LEFT : TRACK_BIT_3WAY_NW },
|
---|
| | 5 | { TileDiffXY( 1, 1), TileDiffXY( 1, 0), TileDiffXY( 0, 1), TRACK_BIT_UPPER, _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_LOWER : TRACK_BIT_3WAY_SE, _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_LOWER : TRACK_BIT_3WAY_SW },
|
---|
| | 6 | };
|
---|
| | 7 |
|
---|
3 | TrackBits water_track = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0));
| 3 | Slope slope = GetTileSlope(tile);
|
---|
4 | if (water_track != TRACK_BIT_NONE) {
| 4 | if (IsSlopeWithOneCornerRaised(slope)) {
|
---|
5 | if (water_track == TRACK_BIT_UPPER || water_track == TRACK_BIT_LOWER || water_track == TRACK_BIT_LEFT || water_track == TRACK_BIT_RIGHT) {
| 5 | Corner corner = GetHighestSlopeCorner(slope);
|
---|
6 | TileIndex opposite_tile = INVALID_TILE;
| | |
---|
7 | TrackBits opposite_track = TRACK_BIT_NONE;
| | |
---|
21 | next_tile_2 = TileAddWrap(tile, 0, -1);
| 21 | if (IsValidTile(next_tile_1)) {
|
---|
22 | next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_UPPER : TRACK_BIT_3WAY_NE;
| 22 | next_track_1 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_1, TRANSPORT_WATER, 0));
|
---|
23 | } else if (water_track == TRACK_BIT_RIGHT) {
| 23 | }
|
---|
24 | opposite_tile = TileAddWrap(tile, -1, 1);
| 24 | if (IsValidTile(next_tile_2)) {
|
---|
25 | opposite_track = TRACK_BIT_LEFT;
| 25 | next_track_2 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_2, TRANSPORT_WATER, 0));
|
---|
26 |
| 26 | }
|
---|
27 | next_tile_1 = TileAddWrap(tile, 0, 1);
| 27 | if (next_track_1 != TRACK_BIT_NONE && next_track_2 != TRACK_BIT_NONE) {
|
---|
28 | next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_RIGHT : TRACK_BIT_3WAY_NE;
| 28 | if (IsValidTile(opposite_tile)) {
|
---|
29 |
| 29 | opposite_track &= TrackStatusToTrackBits(GetTileTrackStatus(opposite_track, TRANSPORT_WATER, 0));
|
---|
30 | next_tile_2 = TileAddWrap(tile, -1, 0);
| | |
---|
31 | next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_RIGHT : TRACK_BIT_3WAY_SE;
| | |
---|
32 | } else if (water_track == TRACK_BIT_LOWER) {
| | |
---|
33 | opposite_tile = TileAddWrap(tile, 1, 1);
| | |
---|
34 | opposite_track = TRACK_BIT_UPPER;
| | |
---|
35 |
| | |
---|
36 | next_tile_1 = TileAddWrap(tile, 1, 0);
| | |
---|
37 | next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_LOWER : TRACK_BIT_3WAY_SE;
| | |
---|
38 |
| | |
---|
39 | next_tile_2 = TileAddWrap(tile, 0, 1);
| | |
---|
40 | next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_LOWER : TRACK_BIT_3WAY_SW;
| | |
---|
41 | } else if (water_track == TRACK_BIT_LEFT) {
| | |
---|
42 | opposite_tile = TileAddWrap(tile, 1, -1);
| | |
---|
43 | opposite_track = TRACK_BIT_RIGHT;
| | |
---|
44 |
| | |
---|
45 | next_tile_1 = TileAddWrap(tile, 0, -1);
| | |
---|
46 | next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_LEFT : TRACK_BIT_3WAY_SW;
| | |
---|
47 |
| | |
---|
48 | next_tile_2 = TileAddWrap(tile, 1, 0);
| | |
---|
49 | next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_LEFT : TRACK_BIT_3WAY_NW;
| | |
---|
51 | if (IsValidTile(next_tile_1)) {
| 51 | }
|
---|
52 | next_track_1 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_1, TRANSPORT_WATER, 0));
| 52 | if (next_track_1 != TRACK_BIT_NONE) {
|
---|
53 | }
| 53 | if (next_track_2 == TRACK_BIT_NONE) {
|
---|
54 | if (IsValidTile(next_tile_2)) {
| 54 | return false;
|
---|
55 | next_track_2 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_2, TRANSPORT_WATER, 0));
| 55 | } else {
|
---|
56 | }
| 56 | if (opposite_track == TRACK_BIT_NONE) {
|
---|
57 | if (next_track_1 != TRACK_BIT_NONE && next_track_2 != TRACK_BIT_NONE) {
| 57 | return true;
|
---|
58 | if (IsValidTile(opposite_tile)) {
| 58 | } else {
|
---|
59 | opposite_track &= TrackStatusToTrackBits(GetTileTrackStatus(opposite_track, TRANSPORT_WATER, 0));
| 59 | return false;
|
---|