| 32 | if (IsValidTile(tile + m * 3 * delta_mid)) {
| 32 | if (IsValidTile(t_dm + d * 2 * delta)) {
|
|---|
| 33 | if ((GetInclinedSlopeDirection(GetTileSlope(tile + m * 3 * delta_mid)) == dir ||
| 33 | if (!AdjacentLock(t_dm + d * 2 * delta, dir_rot, true)) return false;
|
|---|
| 34 | GetInclinedSlopeDirection(GetTileSlope(tile + m * 3 * delta_mid)) == ReverseDiagDir(dir)) &&
| | |
|---|
| 35 | FlowsLock(tile + m * 3 * delta_mid)) {
| | |
|---|
| 36 | return false;
| | |
|---|
| 37 | }
| | |
|---|
| 38 | }
| | |
|---|
| 39 | }
| | |
|---|
| 40 | }
| | |
|---|
| 41 |
| | |
|---|
| 42 | for (int d = -1; d <= 1; d += 2) {
| | |
|---|
| 43 | if (IsValidTile(tile + m * delta_mid + d * delta)) {
| | |
|---|
| 44 | if (!IsTileFlat(tile + m * delta_mid + d * delta) &&
| | |
|---|
| 45 | (GetInclinedSlopeDirection(GetTileSlope(tile + m * delta_mid + d * delta)) == dir_rot ||
| | |
|---|
| 46 | GetInclinedSlopeDirection(GetTileSlope(tile + m * delta_mid + d * delta)) == ReverseDiagDir(dir_rot)) &&
| | |
|---|
| 47 | FlowsLock(tile + m * delta_mid + d * delta)) {
| | |
|---|
| 48 | return false;
| | |
|---|
| 49 | }
| | |
|---|
| 50 |
| | |
|---|
| 51 | if (IsValidTile(tile + m * delta_mid + d * 2 * delta)) {
| | |
|---|
| 52 | if (!IsTileFlat(tile + m * delta_mid + d * 2 * delta) &&
| | |
|---|
| 53 | (GetInclinedSlopeDirection(GetTileSlope(tile + m * delta_mid + d * 2 * delta)) == dir_rot ||
| | |
|---|
| 54 | GetInclinedSlopeDirection(GetTileSlope(tile + m * delta_mid + d * 2 * delta)) == ReverseDiagDir(dir_rot)) &&
| | |
|---|
| 55 | FlowsLock(tile + m * delta_mid + d * 2 * delta)) {
| | |
|---|
| 56 | return false;
| | |
|---|
| 60 | if (IsValidTile(tile + m * 2 * delta_mid + d * delta)) {
| 43 | // if (IsValidTile(t_dm + d * delta)) {
|
|---|
| 61 | if (IsTileFlat(tile + m * delta_mid + d * delta) && !IsTileFlat(tile + m * 2 * delta_mid + d * delta)) {
| 44 | // if (!IsTileFlat(t_dm + d * delta) &&
|
|---|
| 62 | return false;
| 45 | // (GetInclinedSlopeDirection(GetTileSlope(t_dm + d * delta)) == dir_rot ||
|
|---|
| | | 46 | // GetInclinedSlopeDirection(GetTileSlope(t_dm + d * delta)) == ReverseDiagDir(dir_rot)) &&
|
|---|
| | | 47 | // FlowsLock(t_dm + d * delta)) {
|
|---|
| | | 48 | // return false;
|
|---|
| | | 49 | // }
|
|---|
| | | 50 |
|
|---|
| | | 51 | // if (IsValidTile(t_dm + d * 2 * delta)) {
|
|---|
| | | 52 | // if (!IsTileFlat(t_dm + d * 2 * delta) &&
|
|---|
| | | 53 | // (GetInclinedSlopeDirection(GetTileSlope(t_dm + d * 2 * delta)) == dir_rot ||
|
|---|
| | | 54 | // GetInclinedSlopeDirection(GetTileSlope(t_dm + d * 2 * delta)) == ReverseDiagDir(dir_rot)) &&
|
|---|
| | | 55 | // FlowsLock(t_dm + d * 2 * delta)) {
|
|---|
| | | 56 | // return false;
|
|---|
| | | 57 | // }
|
|---|
| | | 58 | // }
|
|---|
| | | 59 | // }
|
|---|
| | | 60 | }
|
|---|
| | | 61 |
|
|---|
| | | 62 | TileIndex t_2dm = t_dm + m * delta_mid;
|
|---|
| | | 63 | if (IsValidTile(t_2dm)) {
|
|---|
| | | 64 | if (!IsTileFlat(t_2dm)) return false;
|
|---|
| | | 65 |
|
|---|
| | | 66 | for (int d = -1; d <= 1; d += 2) {
|
|---|
| | | 67 | if (IsValidTile(t_2dm + d * delta)) {
|
|---|
| | | 68 | if (IsTileFlat(t_dm + d * delta) && !IsTileFlat(t_2dm + d * delta)) return false;
|
|---|
| | | 69 |
|
|---|
| | | 70 | if (!AdjacentLock(t_2dm + d * delta, dir_rot, true)) return false;
|
|---|
| | | 71 | // if (!IsTileFlat(t_2dm + d * delta) &&
|
|---|
| | | 72 | // (GetInclinedSlopeDirection(GetTileSlope(t_2dm + d * delta)) == dir_rot ||
|
|---|
| | | 73 | // GetInclinedSlopeDirection(GetTileSlope(t_2dm + d * delta)) == ReverseDiagDir(dir_rot)) &&
|
|---|
| | | 74 | // FlowsLock(t_2dm + d * delta)) {
|
|---|
| | | 75 | // return false;
|
|---|
| | | 76 | // }
|
|---|
| 65 | if (!IsTileFlat(tile + m * 2 * delta_mid + d * delta) &&
| 80 | TileIndex t_3dm = t_2dm + m * delta_mid;
|
|---|
| 66 | (GetInclinedSlopeDirection(GetTileSlope(tile + m * 2 * delta_mid + d * delta)) == dir_rot ||
| 81 | if (IsValidTile(t_3dm)) {
|
|---|
| 67 | GetInclinedSlopeDirection(GetTileSlope(tile + m * 2 * delta_mid + d * delta)) == ReverseDiagDir(dir_rot)) &&
| 82 | if (!AdjacentLock(t_3dm, dir, true)) return false;
|
|---|
| 68 | FlowsLock(tile + m * 2 * delta_mid + d * delta)) {
| 83 | // if ((GetInclinedSlopeDirection(GetTileSlope(t_3dm)) == dir ||
|
|---|
| 69 | return false;
| 84 | // GetInclinedSlopeDirection(GetTileSlope(t_3dm)) == ReverseDiagDir(dir)) &&
|
|---|
| 70 | }
| 85 | // FlowsLock(t_3dm)) {
|
|---|
| | | 86 | // return false;
|
|---|
| | | 87 | // }
|
|---|
| | | 88 | }
|
|---|
| 72 | if (IsValidTile(tile + m * 3 * delta_mid + d * delta)) {
| 90 | for (int d = -1; d <= 1; d += 2) {
|
|---|
| 73 | if ((GetInclinedSlopeDirection(GetTileSlope(tile + m * 3 * delta_mid + d * delta)) == dir ||
| 91 | if (IsValidTile(t_3dm + d * delta)) {
|
|---|
| 74 | GetInclinedSlopeDirection(GetTileSlope(tile + m * 3 * delta_mid + d * delta)) == ReverseDiagDir(dir)) &&
| 92 | if (!AdjacentLock(t_3dm + d * delta, dir, true)) return false;
|
|---|
| 75 | FlowsLock(tile + m * 3 * delta_mid + d * delta)) {
| 93 | // if ((GetInclinedSlopeDirection(GetTileSlope(t_3dm + d * delta)) == dir ||
|
|---|
| 76 | return false;
| 94 | // GetInclinedSlopeDirection(GetTileSlope(t_3dm + d * delta)) == ReverseDiagDir(dir)) &&
|
|---|
| 77 | }
| 95 | // FlowsLock(t_3dm + d * delta)) {
|
|---|
| | | 96 | // return false;
|
|---|
| | | 97 | // }
|
|---|
| 85 | }
| | |
|---|
| 86 |
| | |
|---|
| 87 | /**
| | |
|---|
| 88 | * Check whether a river at begin could (logically) flow down to end.
| | |
|---|
| 89 | * @param begin The origin of the flow.
| | |
|---|
| 90 | * @param end The destination of the flow.
| | |
|---|
| 91 | * @return True iff the water can be flowing down.
| | |
|---|
| 92 | */
| | |
|---|
| 93 | static bool FlowsDown(TileIndex begin, TileIndex end)
| | |
|---|
| 94 | {
| | |
|---|
| 95 | assert(DistanceManhattan(begin, end) == 1);
| | |
|---|
| 96 |
| | |
|---|
| 97 | int heightBegin;
| | |
|---|
| 98 | int heightEnd;
| | |
|---|
| 99 | Slope slopeBegin = GetTileSlope(begin, &heightBegin);
| | |
|---|
| 100 | Slope slopeEnd = GetTileSlope(end, &heightEnd);
| | |
|---|
| 101 |
| | |
|---|
| 102 | return heightEnd <= heightBegin &&
| | |
|---|
| 103 | /* Slope either is inclined or flat; rivers don't support other slopes. */
| | |
|---|
| 104 | (slopeEnd == SLOPE_FLAT || (IsInclinedSlope(slopeEnd) && FlowsLock(end, true))) &&
| | |
|---|
| 105 | /* Slope continues, then it must be lower... or either end must be flat. */
| | |
|---|
| 106 | ((slopeEnd == slopeBegin && heightEnd < heightBegin) || slopeEnd == SLOPE_FLAT || (slopeBegin == SLOPE_FLAT && GetTileMaxZ(end) == heightBegin));
| | |
|---|