Merge branch 'master' into jgrpp

Bump savegame for water regions for ship pathfinder
Use ring_buffer for ShipPathCache
This commit is contained in:
Jonathan G Rennison
2024-01-09 16:30:06 +00:00
45 changed files with 1406 additions and 332 deletions

View File

@@ -38,6 +38,7 @@
#include "company_gui.h"
#include "newgrf_generic.h"
#include "industry.h"
#include "pathfinder/water_regions.h"
#include "object_base.h"
#include "object_map.h"
#include "newgrf_object.h"
@@ -145,6 +146,9 @@ CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32_t p1,
}
if (flags & DC_EXEC) {
InvalidateWaterRegion(tile);
InvalidateWaterRegion(tile2);
Depot *depot = new Depot(tile);
depot->build_date = _date;
@@ -258,6 +262,7 @@ void MakeWaterKeepingClass(TileIndex tile, Owner o)
/* Zero map array and terminate animation */
DoClearSquare(tile);
InvalidateWaterRegion(tile);
/* Maybe change to water */
switch (wc) {
@@ -355,6 +360,10 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlag
}
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) {
@@ -512,6 +521,8 @@ CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint
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)) {
@@ -561,8 +572,11 @@ CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint
}
}
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);
@@ -1250,6 +1264,8 @@ void DoFloodTile(TileIndex target)
}
if (flooded) {
InvalidateWaterRegion(target);
/* Mark surrounding canal tiles dirty too to avoid glitches */
MarkCanalsAndRiversAroundDirty(target);