mirror of https://github.com/OpenTTD/OpenTTD
Fix #10638: Incorrect water infra total when building canal over object
In the case where the object is on an unowned canal tile and the new canal tile is ownedpull/10922/head
parent
da20e0f6e6
commit
08a5637f98
|
@ -475,6 +475,14 @@ CommandCost CmdBuildCanal(DoCommandFlag flags, TileIndex tile, TileIndex start_t
|
||||||
if (!water) cost.AddCost(ret);
|
if (!water) cost.AddCost(ret);
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
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) {
|
switch (wc) {
|
||||||
case WATER_CLASS_RIVER:
|
case WATER_CLASS_RIVER:
|
||||||
MakeRiver(current_tile, Random());
|
MakeRiver(current_tile, Random());
|
||||||
|
@ -492,14 +500,11 @@ CommandCost CmdBuildCanal(DoCommandFlag flags, TileIndex tile, TileIndex start_t
|
||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* If we overbuild a water object with a canal, don't update the infrastructure total. */
|
MakeCanal(current_tile, _current_company, Random());
|
||||||
bool is_existing_canal = IsTileType(current_tile, MP_WATER) && IsCanal(current_tile);
|
if (Company::IsValidID(_current_company)) {
|
||||||
if (Company::IsValidID(_current_company) && !is_existing_canal) {
|
|
||||||
Company::Get(_current_company)->infrastructure.water++;
|
Company::Get(_current_company)->infrastructure.water++;
|
||||||
DirtyCompanyInfrastructureWindows(_current_company);
|
DirtyCompanyInfrastructureWindows(_current_company);
|
||||||
}
|
}
|
||||||
|
|
||||||
MakeCanal(current_tile, _current_company, Random());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
MarkTileDirtyByTile(current_tile);
|
MarkTileDirtyByTile(current_tile);
|
||||||
|
|
Loading…
Reference in New Issue