13 | ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
| 20 |
|
---|
14 | if (ret.Failed()) return ret;
| 21 | if (!IsWaterTile(tile)) {
|
---|
15 | cost.AddCost(ret);
| 22 | ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
---|
| | 23 | if (ret.Failed()) return ret;
|
---|
| | 24 | cost.AddCost(ret);
|
---|
| | 25 | cost.AddCost(_price[PR_BUILD_CANAL]);
|
---|
| | 26 | }
|
---|
| | 81 | }
|
---|
| | 82 |
|
---|
| | 83 | /**
|
---|
| | 84 | * Remove a lock.
|
---|
| | 85 | * @param tile Central tile of the lock.
|
---|
| | 86 | * @param flags Operation to perform.
|
---|
| | 87 | * @return The cost in case of success, or an error code if it failed.
|
---|
| | 88 | */
|
---|
| | 89 | static CommandCost RemoveLock(TileIndex tile, DoCommandFlag flags)
|
---|
| | 90 | {
|
---|
| | 91 | if (GetTileOwner(tile) != OWNER_NONE) {
|
---|
| | 92 | CommandCost ret = CheckTileOwnership(tile);
|
---|
| | 93 | if (ret.Failed()) return ret;
|
---|
| | 94 | }
|
---|
| | 95 |
|
---|
| | 96 | TileIndexDiff delta = TileOffsByDiagDir(GetLockDirection(tile));
|
---|
| | 97 |
|
---|
| | 98 | /* make sure no vehicle is on the tile. */
|
---|
| | 99 | CommandCost ret = EnsureNoVehicleOnGround(tile);
|
---|
| | 100 | if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile + delta);
|
---|
| | 101 | if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile - delta);
|
---|
| | 102 | if (ret.Failed()) return ret;
|
---|
| | 103 |
|
---|
| | 104 | if (flags & DC_EXEC) {
|
---|
| | 105 | /* Remove middle part from company infrastructure count. */
|
---|
| | 106 | Company *c = Company::GetIfValid(GetTileOwner(tile));
|
---|
| | 107 | if (c != NULL) {
|
---|
| | 108 | c->infrastructure.water -= 3 * LOCK_DEPOT_TILE_FACTOR; // three parts of the lock.
|
---|
| | 109 | DirtyCompanyInfrastructureWindows(c->index);
|
---|
| | 110 | }
|
---|
| | 111 |
|
---|
| | 112 | if (GetWaterClass(tile) == WATER_CLASS_RIVER) {
|
---|
| | 113 | MakeRiver(tile, Random());
|
---|
| | 114 | } else {
|
---|
| | 115 | c->infrastructure.water--;
|
---|
| | 116 | DoClearSquare(tile);
|
---|
| | 117 | }
|
---|
| | 118 | MakeWaterKeepingClass(tile + delta, GetTileOwner(tile + delta));
|
---|
| | 119 | MakeWaterKeepingClass(tile - delta, GetTileOwner(tile - delta));
|
---|
| | 120 | MarkCanalsAndRiversAroundDirty(tile);
|
---|
| | 121 | MarkCanalsAndRiversAroundDirty(tile - delta);
|
---|
| | 122 | MarkCanalsAndRiversAroundDirty(tile + delta);
|
---|
| | 123 | }
|
---|
| | 124 |
|
---|
| | 125 | return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_LOCK]);
|
---|