From b42beecb0db4ccb381634c1e451a6dda257e3ab1 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Wed, 10 Jan 2024 19:19:28 +0000 Subject: [PATCH] Use array unique_ptr for water regions --- src/pathfinder/water_regions.cpp | 6 +++--- src/pathfinder/water_regions.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pathfinder/water_regions.cpp b/src/pathfinder/water_regions.cpp index a7cfbfb3dd..decfc01814 100644 --- a/src/pathfinder/water_regions.cpp +++ b/src/pathfinder/water_regions.cpp @@ -20,6 +20,7 @@ #include "ship.h" #include +#include using TWaterRegionTraversabilityBits = uint16_t; constexpr TWaterRegionPatchLabel FIRST_REGION_LABEL = 1; @@ -273,7 +274,7 @@ public: } }; -std::vector _water_regions; +std::unique_ptr _water_regions; TileIndex GetTileIndexFromLocalCoordinate(uint32_t region_x, uint32_t region_y, uint32_t local_x, uint32_t local_y) { @@ -442,8 +443,7 @@ void VisitWaterRegionPatchNeighbors(const WaterRegionPatchDesc &water_region_pat */ void InitializeWaterRegions() { - _water_regions.clear(); - _water_regions.resize(static_cast(GetWaterRegionMapSizeX()) * GetWaterRegionMapSizeY()); + _water_regions.reset(new WaterRegion[GetWaterRegionMapSizeX() * GetWaterRegionMapSizeY()]); } uint GetWaterRegionTileDebugColourIndex(TileIndex tile) diff --git a/src/pathfinder/water_regions.h b/src/pathfinder/water_regions.h index d06f7d92bc..044c9c4f76 100644 --- a/src/pathfinder/water_regions.h +++ b/src/pathfinder/water_regions.h @@ -13,7 +13,6 @@ #include "tile_type.h" #include "map_func.h" -#include #include using TWaterRegionPatchLabel = uint8_t;