if (HasTileWaterGround(tile) && GetWaterClass(tile) == WATER_CLASS_CANAL) {
if (IsDockTile(tile) || IsBuoyTile(tile) || IsOilRig(tile)) {
if (GetCanalOwner(tile) == old_owner) {
Company::Get(old_owner)->infrastructure.water--;
if (new_owner != INVALID_OWNER) {
Company::Get(new_owner)->infrastructure.water++;
} else {
if (IsBuoyTile(tile)) {
/* Remove unused buoys. */
DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR);
/* Set tile owner of canal under (now removed) buoy to OWNER_NONE. */
if (IsTileType(tile, MP_WATER) && IsCanal(tile) && IsTileOwner(tile, old_owner)) SetTileOwner(tile, OWNER_NONE);
}
}
SetCanalOwner(tile, new_owner == INVALID_OWNER ? OWNER_NONE : new_owner);
}
}
}