| Old revision #pjtgnjoan | New revision #pb70f60wf | ||
|---|---|---|---|
| 44 | if (rem > 0) rem--; | 44 | if (rem > 0) rem--; |
| 45 | tile_next += delta; | 45 | tile_next += delta; |
| 46 | if (built_lock) { | 46 | if (built_lock) { |
| 47 | /* A lock was built on the last iteration, which means | ||
| 48 | * this iteration's tile belongs to the lock. */ | ||
| 47 | built_lock = false; | 49 | built_lock = false; |
| 48 | continue; | 50 | continue; |
| 49 | } | 51 | } |
| 50 | Slope slope = GetTileSlope(tile); | 52 | Slope slope = GetTileSlope(tile); |
| 51 | |||
| 52 | 53 | ||
| 53 | if (slope != SLOPE_FLAT && !IsInclinedSlope(slope)) { | 54 | if (slope != SLOPE_FLAT && !IsInclinedSlope(slope)) { |
| 54 | return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); | 55 | return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); |
| 55 | } | 56 | } |
| 57 | /* From here on, slope is either flat or inclined. */ | ||
| 56 | 58 | ||
| 57 | /* Can't make water of water! */ | 59 | /* Can't make water of water! */ |
| 58 | if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || wc == WATER_CLASS_SEA)) continue; | 60 | if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || wc == WATER_CLASS_SEA)) continue; | … | … |
| 60 | CommandCost ret; | 62 | CommandCost ret; |
| 61 | bool river = HasTileWaterClass(tile) && GetWaterClass(tile) == WATER_CLASS_RIVER; | 63 | bool river = HasTileWaterClass(tile) && GetWaterClass(tile) == WATER_CLASS_RIVER; |
| 62 | 64 | ||
| 65 | Slope slope_next = GetTileSlope(tile_next); | ||
| 63 | if (rem > 0 && wc == WATER_CLASS_CANAL && slope == SLOPE_FLAT && IsInclinedSlope(slope_next) && DiagDirToAxis(GetInclinedSlopeDirection(slope_next)) == axis) { | 66 | if (rem > 0 && wc == WATER_CLASS_CANAL && slope == SLOPE_FLAT && IsInclinedSlope(slope_next) && DiagDirToAxis(GetInclinedSlopeDirection(slope_next)) == axis) { |
| 64 | /* The conditions indicate a lock might be built on next iteration. Don't clear this tile and skip to the next iteration now. */ | 67 | /* The conditions indicate a lock might be built on next iteration. |
| 68 | * Don't clear this tile and skip to the next iteration now. */ | ||
| 65 | continue; | 69 | continue; |
| 66 | } else { | 70 | } else { |
| 67 | | 67 | bool water = IsWaterTile(tile); |
| 68 | if (rem >= 0) { // Single-line or single-clicking. | 72 | if (rem >= 0) { // Single-line or single-clicking. |
| 69 | if (wc == WATER_CLASS_CANAL && IsInclinedSlope(slope)) { | 73 | if (wc == WATER_CLASS_CANAL && IsInclinedSlope(slope)) { |
| 70 | /* Try to build a lock on inclined tile. */ | 74 | /* Try to build a lock on inclined tile. */ |
| 71 | if ((axis == INVALID_AXIS || DiagDirToAxis(GetInclinedSlopeDirection(slope)) == axis)) { | 75 | if ((axis == INVALID_AXIS || DiagDirToAxis(GetInclinedSlopeDirection(slope)) == axis)) { |
| 72 | if (rem == 0 && axis == INVALID_AXIS || IsTileFlat(tile + TileOffsByDiagDir(GetInclinedSlopeDirection(slope))) && IsTileFlat(tile - TileOffsByDiagDir(GetInclinedSlopeDirection(slope)))) { | 76 | int tile_delta = TileOffsByDiagDir(GetInclinedSlopeDirection(slope)); |
| 77 | if (rem == 0 && axis == INVALID_AXIS || IsTileFlat(tile + tile_delta) && IsTileFlat(tile - tile_delta)) { | ||
| 73 | ret = DoCommand(tile, 0, 0, flags, CMD_BUILD_LOCK); | 78 | ret = DoCommand(tile, 0, 0, flags, CMD_BUILD_LOCK); |
| 74 | if (ret.Failed()) return ret; | 79 | if (ret.Failed()) return ret; |
| 75 | cost.AddCost(ret); | 80 | cost.AddCost(ret); | … | … |
| 83 | } | 88 | } |
| 84 | } | 89 | } |
| 85 | } else { | 90 | } else { |
| 86 | |||
| 87 | ret = DoCommand(tile, 0, 0, flags | DC_FORCE_CLEAR_TILE, CMD_LANDSCAPE_CLEAR); | 91 | ret = DoCommand(tile, 0, 0, flags | DC_FORCE_CLEAR_TILE, CMD_LANDSCAPE_CLEAR); |
| 88 | if (ret.Failed()) return ret; | 92 | if (ret.Failed()) return ret; |
| 89 | if (!water) cost.AddCost(ret); | 93 | if (!water) cost.AddCost(ret); | … | … |
| 92 | if (wc == WATER_CLASS_CANAL && IsInclinedSlope(slope)) { | 96 | if (wc == WATER_CLASS_CANAL && IsInclinedSlope(slope)) { |
| 93 | return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); | 97 | return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED); |
| 94 | } else { | 98 | } else { |
| 95 | |||
| 96 | ret = DoCommand(tile, 0, 0, flags | DC_FORCE_CLEAR_TILE, CMD_LANDSCAPE_CLEAR); | 99 | ret = DoCommand(tile, 0, 0, flags | DC_FORCE_CLEAR_TILE, CMD_LANDSCAPE_CLEAR); |
| 97 | if (ret.Failed()) return ret; | 100 | if (ret.Failed()) return ret; |
| 98 | if (!water) cost.AddCost(ret); | 101 | if (!water) cost.AddCost(ret); |