| Old revision #pun0ehlix | New revision #phckb7exn | ||
|---|---|---|---|
| 2 | =================================================================== | 2 | =================================================================== |
| 3 | --- src/saveload/company_sl.cpp (revision 27153) | 3 | --- src/saveload/company_sl.cpp (revision 27153) |
| 4 | +++ src/saveload/company_sl.cpp (working copy) | 4 | +++ src/saveload/company_sl.cpp (working copy) |
| 5 | @@ -180,6 +180,9 @@ | 5 | @@ -179,8 +179,11 @@ |
| 6 | if (IsShipDepot(tile)) c->infrastructure.water += LOCK_DEPOT_TILE_FACTOR; | ||
| 6 | if (IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE) { | 7 | if (IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE) { |
| 7 | /* The middle tile specifies the owner of the lock. */ | 8 | /* The middle tile specifies the owner of the lock. */ |
| 8 | c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // the middle tile specifies the owner of the | 9 | - c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // the middle tile specifies the owner of the |
| 9 | + if (GetWaterClass(tile) != WATER_CLASS_CANAL) { | 10 | - break; // do not count the middle tile as canal |
| 10 | + c->infrastructure.water++; | 11 | + c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; |
| 11 | + } | 12 | + |
| 12 | break; // do not count the middle tile as canal | 13 | + /* Only count the middle tile as canal if the tile is not river. */ |
| 14 | + if (GetWaterClass(tile) != WATER_CLASS_RIVER) c->infrastructure.water++; | ||
| 15 | + break; | ||
| 13 | } | 16 | } |
| 14 | } | 17 | } |
| 18 | } | ||
| 15 | Index: src/water_cmd.cpp | 19 | Index: src/water_cmd.cpp |
| 16 | =================================================================== | 20 | =================================================================== |
| 17 | --- src/water_cmd.cpp (revision 27153) | 21 | --- src/water_cmd.cpp (revision 27153) |
| 18 | +++ src/water_cmd.cpp (working copy) | 22 | +++ src/water_cmd.cpp (working copy) |
| 19 | @@ -258, | 19 | @@ -258,9 +258,14 @@ |
| 20 | 24 | ||
| 21 | /* middle tile */ | 25 | /* middle tile */ |
| 22 | WaterClass wc_middle = IsWaterTile(tile) ? GetWaterClass(tile) : WATER_CLASS_CANAL; | 26 | WaterClass wc_middle = IsWaterTile(tile) ? GetWaterClass(tile) : WATER_CLASS_CANAL; |
| 23 | - ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); | 27 | - ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
| 24 | - if (ret.Failed()) return ret; | 28 | - if (ret.Failed()) return ret; |
| 25 | - cost.AddCost(ret); | 29 | - cost.AddCost(ret); |
| 26 | 26 | + | |
| 27 | + if (!IsWaterTile(tile)) { | 31 | + if (!IsWaterTile(tile)) { |
| 28 | + ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); | 32 | + ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
| 29 | + if (ret.Failed()) return ret; | 33 | + if (ret.Failed()) return ret; |
| 30 | + cost.AddCost(ret); | 34 | + cost.AddCost(ret); |
| 35 | + /* Add an extra cost only if not building on a river. */ | ||
| 31 | + cost.AddCost(_price[PR_BUILD_CANAL]); | 36 | + cost.AddCost(_price[PR_BUILD_CANAL]); |
| 32 | + } | 37 | + } |
| 33 | 33 | ||
| 34 | /* lower tile */ | 39 | /* lower tile */ |
| 35 | WaterClass wc_lower = IsWaterTile(tile - delta) ? GetWaterClass(tile - delta) : WATER_CLASS_CANAL; | 40 | WaterClass wc_lower = IsWaterTile(tile - delta) ? GetWaterClass(tile - delta) : WATER_CLASS_CANAL; |
| 36 | 36 | @@ -298,6 +303,7 @@ | |
| 37 | @@ -298,6 +302,7 @@ | ||
| 38 | if (c != NULL) { | 42 | if (c != NULL) { |
| 39 | /* Counts for the water. */ | 43 | /* Counts for the water. */ |
| 40 | if (!IsWaterTile(tile - delta)) c->infrastructure.water++; | 44 | if (!IsWaterTile(tile - delta)) c->infrastructure.water++; | … | … |
| 42 | if (!IsWaterTile(tile + delta)) c->infrastructure.water++; | 46 | if (!IsWaterTile(tile + delta)) c->infrastructure.water++; |
| 43 | /* Count for the lock itself. */ | 47 | /* Count for the lock itself. */ |
| 44 | c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock is three tiles. | 48 | c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock is three tiles. |
| 45 | @@ -324,6 +3 | 45 | @@ -324,6 +330,8 @@ |
| 46 | */ | 50 | */ |
| 47 | static CommandCost RemoveLock(TileIndex tile, DoCommandFlag flags) | 51 | static CommandCost RemoveLock(TileIndex tile, DoCommandFlag flags) |
| 48 | { | 52 | { | … | … |
| 51 | if (GetTileOwner(tile) != OWNER_NONE) { | 55 | if (GetTileOwner(tile) != OWNER_NONE) { |
| 52 | CommandCost ret = CheckTileOwnership(tile); | 56 | CommandCost ret = CheckTileOwnership(tile); |
| 53 | if (ret.Failed()) return ret; | 57 | if (ret.Failed()) return ret; |
| 54 | @@ -336,7 +343,7 @@ | 54 | @@ -337,6 +345,9 @@ |
| 55 | if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile + delta); | ||
| 56 | if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile - delta); | 59 | if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile - delta); |
| 57 | if (ret.Failed()) return ret; | 60 | if (ret.Failed()) return ret; |
| 58 | - | 61 | |
| 62 | + /* Add an extra cost only if it was not built on a river. */ | ||
| 59 | + if (GetWaterClass(tile) != WATER_CLASS_RIVER) cost.AddCost(_price[PR_CLEAR_CANAL]); | 63 | + if (GetWaterClass(tile) != WATER_CLASS_RIVER) cost.AddCost(_price[PR_CLEAR_CANAL]); |
| 64 | + | ||
| 60 | if (flags & DC_EXEC) { | 65 | if (flags & DC_EXEC) { |
| 61 | /* Remove middle part from company infrastructure count. */ | 66 | /* Remove middle part from company infrastructure count. */ |
| 62 | Company *c = Company::GetIfValid(GetTileOwner(tile)); | 67 | Company *c = Company::GetIfValid(GetTileOwner(tile)); |
| 63 | @@ -348,6 +35 | 63 | @@ -348,6 +359,7 @@ |
| 64 | if (GetWaterClass(tile) == WATER_CLASS_RIVER) { | 69 | if (GetWaterClass(tile) == WATER_CLASS_RIVER) { |
| 65 | MakeRiver(tile, Random()); | 70 | MakeRiver(tile, Random()); |
| 66 | } else { | 71 | } else { |
| 67 | + if (c != NULL) { | 67 | + if (c != NULL) c->infrastructure.water--; // Make sure it's not a leftover or neutral lock. |
| 68 | + c->infrastructure.water--; | ||
| 69 | + } | ||
| 70 | DoClearSquare(tile); | 73 | DoClearSquare(tile); |
| 71 | } | 74 | } |
| 72 | MakeWaterKeepingClass(tile + delta, GetTileOwner(tile + delta)); | 75 | MakeWaterKeepingClass(tile + delta, GetTileOwner(tile + delta)); |
| 73 | @@ -357,7 +36 | 73 | @@ -357,7 +369,9 @@ |
| 74 | MarkCanalsAndRiversAroundDirty(tile + delta); | 77 | MarkCanalsAndRiversAroundDirty(tile + delta); |
| 75 | } | 78 | } |
| 76 | 79 | … | … |
| 81 | } | 84 | } |
| 82 | 85 | ||
| 83 | /** | 86 | /** |
| 84 | @@ -1275,9 +128 | 84 | @@ -1275,9 +1289,15 @@ |
| 85 | bool is_lock_middle = IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE; | 88 | bool is_lock_middle = IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE; |
| 86 | 89 | ||
| 87 | /* No need to dirty company windows here, we'll redraw the whole screen anyway. */ | 90 | /* No need to dirty company windows here, we'll redraw the whole screen anyway. */ |