Index: src/saveload/company_sl.cpp
===================================================================
--- src/saveload/company_sl.cpp (revision 27153)
+++ src/saveload/company_sl.cpp (working copy)
@@ -180,6 +180,9 @@
if (IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE) {
/* The middle tile specifies the owner of the lock. */
c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // the middle tile specifies the owner of the
+ if (GetWaterClass(tile) != WATER_CLASS_RIVER) {
+ c->infrastructure.water++;
+ }
break; // do not count the middle tile as canal
}
}
Index: src/water_cmd.cpp
===================================================================
--- src/water_cmd.cpp (revision 27153)
+++ src/water_cmd.cpp (working copy)
@@ -258,10 +258,14 @@
/* middle tile */
WaterClass wc_middle = IsWaterTile(tile) ? GetWaterClass(tile) : WATER_CLASS_CANAL;
- ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
- if (ret.Failed()) return ret;
- cost.AddCost(ret);
+ if (!IsWaterTile(tile)) {
+ ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ if (ret.Failed()) return ret;
+ cost.AddCost(ret);
+ cost.AddCost(_price[PR_BUILD_CANAL]);
+ }
+
/* lower tile */
WaterClass wc_lower = IsWaterTile(tile - delta) ? GetWaterClass(tile - delta) : WATER_CLASS_CANAL;
@@ -298,6 +302,7 @@
if (c != NULL) {
/* Counts for the water. */
if (!IsWaterTile(tile - delta)) c->infrastructure.water++;
+ if (!IsWaterTile(tile)) c->infrastructure.water++;
if (!IsWaterTile(tile + delta)) c->infrastructure.water++;
/* Count for the lock itself. */
c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock is three tiles.
@@ -324,6 +329,8 @@
*/
static CommandCost RemoveLock(TileIndex tile, DoCommandFlag flags)
{
+ CommandCost cost(EXPENSES_CONSTRUCTION);
+
if (GetTileOwner(tile) != OWNER_NONE) {
CommandCost ret = CheckTileOwnership(tile);
if (ret.Failed()) return ret;
@@ -336,7 +343,7 @@
if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile + delta);
if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile - delta);
if (ret.Failed()) return ret;
-
+ if (GetWaterClass(tile) != WATER_CLASS_RIVER) cost.AddCost(_price[PR_CLEAR_CANAL]);
if (flags & DC_EXEC) {
/* Remove middle part from company infrastructure count. */
Company *c = Company::GetIfValid(GetTileOwner(tile));
@@ -348,6 +355,9 @@
if (GetWaterClass(tile) == WATER_CLASS_RIVER) {
MakeRiver(tile, Random());
} else {
+ if (c != NULL) {
+ c->infrastructure.water--;
+ }
DoClearSquare(tile);
}
MakeWaterKeepingClass(tile + delta, GetTileOwner(tile + delta));
@@ -357,7 +367,9 @@
MarkCanalsAndRiversAroundDirty(tile + delta);
}
- return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_LOCK]);
+ cost.AddCost(_price[PR_CLEAR_LOCK]);
+ return cost;
+
}
/**
@@ -1275,9 +1287,15 @@
bool is_lock_middle = IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE;
/* No need to dirty company windows here, we'll redraw the whole screen anyway. */
- if (is_lock_middle) Company::Get(old_owner)->infrastructure.water -= 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
+ if (is_lock_middle) {
+ Company::Get(old_owner)->infrastructure.water -= 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
+ if (GetWaterClass(tile) == WATER_CLASS_CANAL) Company::Get(old_owner)->infrastructure.water--;
+ }
if (new_owner != INVALID_OWNER) {
- if (is_lock_middle) Company::Get(new_owner)->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
+ if (is_lock_middle) {
+ Company::Get(new_owner)->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
+ if (GetWaterClass(tile) == WATER_CLASS_CANAL) Company::Get(new_owner)->infrastructure.water++;
+ }
/* Only subtract from the old owner here if the new owner is valid,
* otherwise we clear ship depots and canal water below. */
if (GetWaterClass(tile) == WATER_CLASS_CANAL && !is_lock_middle) {