1 | https://imgur.com/wQuDOi5
| 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 | };
|
---|
5 | TrackBits water_track = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0));
| 5 | Slope slope = GetTileSlope(tile);
|
---|
6 | if (water_track != TRACK_BIT_NONE) {
| 6 | if (IsSlopeWithOneCornerRaised(slope)) {
|
---|
7 | if (water_track == TRACK_BIT_UPPER || water_track == TRACK_BIT_LOWER || water_track == TRACK_BIT_LEFT || water_track == TRACK_BIT_RIGHT) {
| 7 | Corner corner = GetHighestSlopeCorner(slope);
|
---|
8 | if (water_track == TRACK_BIT_UPPER) {
| | |
---|
9 | TileIndex opposite_tile = TileAddWrap(tile, -1, -1);
| | |
---|
10 | TrackBits opposite_track = TRACK_BIT_LOWER;
| | |
---|
15 | TileIndex next_tile_2 = TileAddWrap(tile, 0, -1);
| 15 | TileIndex next_tile_1 = tile + table[corner].next_tile_1;
|
---|
16 | TrackBits next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_UPPER : TRACK_BIT_3WAY_NE;
| 16 | TrackBits next_track_1 = table[corner].next_track_1;
|
---|
17 | } else if (water_track == TRACK_BIT_LOWER) {
| | |
---|
18 | TileIndex opposite_tile = TileAddWrap(tile, 1, 1);
| | |
---|
19 | TrackBits opposite_track = TRACK_BIT_UPPER;
| | |
---|
24 | TileIndex next_tile_2 = TileAddWrap(tile, 0, 1);
| 24 | if (IsValidTile(next_tile_1)) {
|
---|
25 | TrackBits next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_LOWER : TRACK_BIT_3WAY_SW;
| 25 | next_track_1 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_1, TRANSPORT_WATER, 0));
|
---|
26 | } else if (water_track == TRACK_BIT_LEFT) {
| 26 | }
|
---|
27 | TileIndex opposite_tile = TileAddWrap(tile, 1, -1);
| 27 | if (IsValidTile(next_tile_2)) {
|
---|
28 | TrackBits opposite_track = TRACK_BIT_RIGHT;
| 28 | next_track_2 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_2, TRANSPORT_WATER, 0));
|
---|
29 |
| 29 | }
|
---|
30 | TileIndex next_tile_1 = TileAddWrap(tile, 0, -1);
| 30 | if (next_track_1 != TRACK_BIT_NONE && next_track_2 != TRACK_BIT_NONE) {
|
---|
31 | TrackBits next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_LEFT : TRACK_BIT_3WAY_SW;
| 31 | if (IsValidTile(opposite_tile)) {
|
---|
32 |
| 32 | opposite_track &= TrackStatusToTrackBits(GetTileTrackStatus(opposite_track, TRANSPORT_WATER, 0));
|
---|
33 | TileIndex next_tile_2 = TileAddWrap(tile, 1, 0);
| | |
---|
34 | TrackBits next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_LEFT : TRACK_BIT_3WAY_NW;
| | |
---|
35 | } else if (water_track == TRACK_BIT_RIGHT) {
| | |
---|
36 | TileIndex opposite_tile = TileAddWrap(tile, -1, 1);
| | |
---|
37 | TrackBits opposite_track = TRACK_BIT_LEFT;
| | |
---|
38 |
| | |
---|
39 | TileIndex next_tile_1 = TileAddWrap(tile, 0, 1);
| | |
---|
40 | TrackBits next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_RIGHT : TRACK_BIT_3WAY_NE;
| | |
---|
41 |
| | |
---|
42 | TileIndex next_tile_2 = TileAddWrap(tile, -1, 0);
| | |
---|
43 | TrackBits next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_RIGHT : TRACK_BIT_3WAY_SE;
| | |
---|