1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-22 19:54:06 +01:00

Codechange: use std::unique_ptr over CallocT for tiles

This commit is contained in:
Rubidium
2025-01-13 21:39:10 +01:00
committed by rubidium42
parent 3541ba4d0c
commit 3a7cfafe51
2 changed files with 16 additions and 19 deletions

View File

@@ -24,8 +24,8 @@
/* static */ uint Map::size; ///< The number of tiles on the map
/* static */ uint Map::tile_mask; ///< _map_size - 1 (to mask the mapsize)
/* static */ Tile::TileBase *Tile::base_tiles = nullptr; ///< Base tiles of the map
/* static */ Tile::TileExtended *Tile::extended_tiles = nullptr; ///< Extended tiles of the map
/* static */ std::unique_ptr<Tile::TileBase[]> Tile::base_tiles; ///< Base tiles of the map
/* static */ std::unique_ptr<Tile::TileExtended[]> Tile::extended_tiles; ///< Extended tiles of the map
/**
@@ -53,11 +53,8 @@
Map::size = size_x * size_y;
Map::tile_mask = Map::size - 1;
free(Tile::base_tiles);
free(Tile::extended_tiles);
Tile::base_tiles = CallocT<Tile::TileBase>(Map::size);
Tile::extended_tiles = CallocT<Tile::TileExtended>(Map::size);
Tile::base_tiles = std::make_unique<Tile::TileBase[]>(Map::size);
Tile::extended_tiles = std::make_unique<Tile::TileExtended[]>(Map::size);
AllocateWaterRegions();
}