|
|
|
@ -481,6 +481,14 @@ CommandCost CmdBuildCanal(DoCommandFlag flags, TileIndex tile, TileIndex start_t
|
|
|
|
|
if (!water) cost.AddCost(ret);
|
|
|
|
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
|
|
if (IsTileType(current_tile, MP_WATER) && IsCanal(current_tile)) {
|
|
|
|
|
Owner owner = GetTileOwner(current_tile);
|
|
|
|
|
if (Company::IsValidID(owner)) {
|
|
|
|
|
Company::Get(owner)->infrastructure.water--;
|
|
|
|
|
DirtyCompanyInfrastructureWindows(owner);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (wc) {
|
|
|
|
|
case WATER_CLASS_RIVER:
|
|
|
|
|
MakeRiver(current_tile, Random());
|
|
|
|
@ -498,14 +506,11 @@ CommandCost CmdBuildCanal(DoCommandFlag flags, TileIndex tile, TileIndex start_t
|
|
|
|
|
FALLTHROUGH;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
/* If we overbuild a water object with a canal, don't update the infrastructure total. */
|
|
|
|
|
bool is_existing_canal = IsTileType(current_tile, MP_WATER) && IsCanal(current_tile);
|
|
|
|
|
if (Company::IsValidID(_current_company) && !is_existing_canal) {
|
|
|
|
|
MakeCanal(current_tile, _current_company, Random());
|
|
|
|
|
if (Company::IsValidID(_current_company)) {
|
|
|
|
|
Company::Get(_current_company)->infrastructure.water++;
|
|
|
|
|
DirtyCompanyInfrastructureWindows(_current_company);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MakeCanal(current_tile, _current_company, Random());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
MarkTileDirtyByTile(current_tile);
|
|
|
|
|