diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -39,6 +39,7 @@ #include "industry.h" #include "water_cmd.h" #include "landscape_cmd.h" +#include "pathfinder/water_regions.h" #include "table/strings.h" @@ -133,6 +134,9 @@ CommandCost CmdBuildShipDepot(DoCommandF } if (flags & DC_EXEC) { + InvalidateWaterRegion(tile); + InvalidateWaterRegion(tile2); + Depot *depot = new Depot(tile); depot->build_date = TimerGameCalendar::date; @@ -243,6 +247,7 @@ void MakeWaterKeepingClass(TileIndex til /* Zero map array and terminate animation */ DoClearSquare(tile); + InvalidateWaterRegion(tile); /* Maybe change to water */ switch (wc) { @@ -340,6 +345,10 @@ static CommandCost DoBuildLock(TileIndex } if (flags & DC_EXEC) { + InvalidateWaterRegion(tile); + InvalidateWaterRegion(tile + delta); + InvalidateWaterRegion(tile - delta); + /* Update company infrastructure counts. */ Company *c = Company::GetIfValid(_current_company); if (c != nullptr) { @@ -482,6 +491,8 @@ CommandCost CmdBuildCanal(DoCommandFlag if (!water) cost.AddCost(ret); if (flags & DC_EXEC) { + InvalidateWaterRegion(current_tile); + if (IsTileType(current_tile, MP_WATER) && IsCanal(current_tile)) { Owner owner = GetTileOwner(current_tile); if (Company::IsValidID(owner)) { @@ -529,8 +540,11 @@ CommandCost CmdBuildCanal(DoCommandFlag } } + static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags) { + if (flags & DC_EXEC) InvalidateWaterRegion(tile); + switch (GetWaterTileType(tile)) { case WATER_TILE_CLEAR: { if (flags & DC_NO_WATER) return_cmd_error(STR_ERROR_CAN_T_BUILD_ON_WATER); @@ -1161,6 +1175,8 @@ void DoFloodTile(TileIndex target) } if (flooded) { + InvalidateWaterRegion(target); + /* Mark surrounding canal tiles dirty too to avoid glitches */ MarkCanalsAndRiversAroundDirty(target);