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_CANAL) {
+ 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.
@@ -348,6 +353,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));
@@ -1276,8 +1284,14 @@
/* 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 (GetWaterClass(tile) == WATER_CLASS_CANAL && is_lock_middle) {
+ 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 (GetWaterClass(tile) == WATER_CLASS_CANAL && is_lock_middle) {
+ 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) {