| | | 42 |
|
|---|
| | | 43 | // if (IsValidTile(t_dm + d * delta)) {
|
|---|
| | | 44 | // if (!IsTileFlat(t_dm + d * delta) &&
|
|---|
| | | 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 | if (!IsTileFlat(t_2dm + d * delta) &&
| 70 | if (!AdjacentLock(t_2dm + d * delta, dir_rot, true)) return false;
|
|---|
| 61 | (GetInclinedSlopeDirection(GetTileSlope(t_2dm + d * delta)) == dir_rot ||
| 71 | // if (!IsTileFlat(t_2dm + d * delta) &&
|
|---|
| 62 | GetInclinedSlopeDirection(GetTileSlope(t_2dm + d * delta)) == ReverseDiagDir(dir_rot)) &&
| 72 | // (GetInclinedSlopeDirection(GetTileSlope(t_2dm + d * delta)) == dir_rot ||
|
|---|
| 63 | FlowsLock(t_2dm + d * delta)) {
| 73 | // GetInclinedSlopeDirection(GetTileSlope(t_2dm + d * delta)) == ReverseDiagDir(dir_rot)) &&
|
|---|
| 64 | return false;
| 74 | // FlowsLock(t_2dm + d * delta)) {
|
|---|
| 65 | }
| 75 | // return false;
|
|---|
| | | 76 | // }
|
|---|
| 71 | if ((GetInclinedSlopeDirection(GetTileSlope(t_3dm)) == dir ||
| 82 | if (!AdjacentLock(t_3dm, dir, true)) return false;
|
|---|
| 72 | GetInclinedSlopeDirection(GetTileSlope(t_3dm)) == ReverseDiagDir(dir)) &&
| 83 | // if ((GetInclinedSlopeDirection(GetTileSlope(t_3dm)) == dir ||
|
|---|
| 73 | FlowsLock(t_3dm)) {
| 84 | // GetInclinedSlopeDirection(GetTileSlope(t_3dm)) == ReverseDiagDir(dir)) &&
|
|---|
| 74 | return false;
| 85 | // FlowsLock(t_3dm)) {
|
|---|
| | | 86 | // return false;
|
|---|
| | | 87 | // }
|
|---|
| | | 88 | }
|
|---|
| | | 89 |
|
|---|
| | | 90 | for (int d = -1; d <= 1; d += 2) {
|
|---|
| | | 91 | if (IsValidTile(t_3dm + d * delta)) {
|
|---|
| | | 92 | if (!AdjacentLock(t_3dm + d * delta, dir, true)) return false;
|
|---|
| | | 93 | // if ((GetInclinedSlopeDirection(GetTileSlope(t_3dm + d * delta)) == dir ||
|
|---|
| | | 94 | // GetInclinedSlopeDirection(GetTileSlope(t_3dm + d * delta)) == ReverseDiagDir(dir)) &&
|
|---|
| | | 95 | // FlowsLock(t_3dm + d * delta)) {
|
|---|
| | | 96 | // return false;
|
|---|
| | | 97 | // }
|
|---|
| 82 | }
| | |
|---|
| 83 |
| | |
|---|
| 84 | /**
| | |
|---|
| 85 | * Check whether a river at begin could (logically) flow down to end.
| | |
|---|
| 86 | * @param begin The origin of the flow.
| | |
|---|
| 87 | * @param end The destination of the flow.
| | |
|---|
| 88 | * @return True iff the water can be flowing down.
| | |
|---|
| 89 | */
| | |
|---|
| 90 | static bool FlowsDown(TileIndex begin, TileIndex end)
| | |
|---|
| 91 | {
| | |
|---|
| 92 | assert(DistanceManhattan(begin, end) == 1);
| | |
|---|
| 93 |
| | |
|---|
| 94 | int heightBegin;
| | |
|---|
| 95 | int heightEnd;
| | |
|---|
| 96 | Slope slopeBegin = GetTileSlope(begin, &heightBegin);
| | |
|---|
| 97 | Slope slopeEnd = GetTileSlope(end, &heightEnd);
| | |
|---|
| 98 |
| | |
|---|
| 99 | return heightEnd <= heightBegin &&
| | |
|---|
| 100 | /* Slope either is inclined or flat; rivers don't support other slopes. */
| | |
|---|
| 101 | (slopeEnd == SLOPE_FLAT || (IsInclinedSlope(slopeEnd) && FlowsLock(end, true))) &&
| | |
|---|
| 102 | /* Slope continues, then it must be lower... or either end must be flat. */
| | |
|---|
| 103 | ((slopeEnd == slopeBegin && heightEnd < heightBegin) || slopeEnd == SLOPE_FLAT || (slopeBegin == SLOPE_FLAT && GetTileMaxZ(end) == heightBegin));
| | |
|---|