Use array unique_ptr for water regions

This commit is contained in:
Jonathan G Rennison 2024-01-10 19:19:28 +00:00
parent 316d34918f
commit b42beecb0d
2 changed files with 3 additions and 4 deletions

View File

@ -20,6 +20,7 @@
#include "ship.h"
#include <array>
#include <vector>
using TWaterRegionTraversabilityBits = uint16_t;
constexpr TWaterRegionPatchLabel FIRST_REGION_LABEL = 1;
@ -273,7 +274,7 @@ public:
}
};
std::vector<WaterRegion> _water_regions;
std::unique_ptr<WaterRegion[]> _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<size_t>(GetWaterRegionMapSizeX()) * GetWaterRegionMapSizeY());
_water_regions.reset(new WaterRegion[GetWaterRegionMapSizeX() * GetWaterRegionMapSizeY()]);
}
uint GetWaterRegionTileDebugColourIndex(TileIndex tile)

View File

@ -13,7 +13,6 @@
#include "tile_type.h"
#include "map_func.h"
#include <vector>
#include <functional>
using TWaterRegionPatchLabel = uint8_t;