mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-28 06:34:33 +01:00
This commit is contained in:
committed by
GitHub
parent
98f27ed83c
commit
89ddc87c16
@@ -66,7 +66,7 @@ extern const TileTypeProcs
|
||||
* @ingroup TileCallbackGroup
|
||||
* @see TileType
|
||||
*/
|
||||
const EnumClassIndexContainer<std::array<const TileTypeProcs *, to_underlying(TileType::End)>, TileType> _tile_type_procs = {
|
||||
const EnumClassIndexContainer<std::array<const TileTypeProcs *, to_underlying(TileType::MaxSize)>, TileType> _tile_type_procs = {
|
||||
&_tile_type_clear_procs, // Callback functions for TileType::Clear tiles
|
||||
&_tile_type_rail_procs, // Callback functions for TileType::Railway tiles
|
||||
&_tile_type_road_procs, // Callback functions for TileType::Road tiles
|
||||
@@ -78,6 +78,12 @@ const EnumClassIndexContainer<std::array<const TileTypeProcs *, to_underlying(Ti
|
||||
&_tile_type_industry_procs, // Callback functions for TileType::Industry tiles
|
||||
&_tile_type_tunnelbridge_procs, // Callback functions for TileType::TunnelBridge tiles
|
||||
&_tile_type_object_procs, // Callback functions for TileType::Object tiles
|
||||
/* Explicitly initialize invalid elements to make sure that they are nullptr. */
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
};
|
||||
|
||||
/** landscape slope => sprite */
|
||||
|
||||
@@ -169,7 +169,7 @@ struct TileTypeProcs {
|
||||
CheckBuildAboveProc *check_build_above_proc;
|
||||
};
|
||||
|
||||
extern const EnumClassIndexContainer<std::array<const TileTypeProcs *, to_underlying(TileType::End)>, TileType> _tile_type_procs;
|
||||
extern const EnumClassIndexContainer<std::array<const TileTypeProcs *, to_underlying(TileType::MaxSize)>, TileType> _tile_type_procs;
|
||||
|
||||
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side = INVALID_DIAGDIR);
|
||||
VehicleEnterTileStates VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y);
|
||||
|
||||
@@ -96,7 +96,7 @@ inline uint TilePixelHeightOutsideMap(int x, int y)
|
||||
[[debug_inline]] inline static TileType GetTileType(Tile tile)
|
||||
{
|
||||
assert(tile < Map::Size());
|
||||
return TileType(GB(tile.type(), 4, 4));
|
||||
return TileType(GB(tile.type(), 4, TILE_TYPE_BITS));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +135,7 @@ inline void SetTileType(Tile tile, TileType type)
|
||||
* edges of the map. If _settings_game.construction.freeform_edges is true,
|
||||
* the upper edges of the map are also VOID tiles. */
|
||||
assert(IsInnerTile(tile) == (type != TileType::Void));
|
||||
SB(tile.type(), 4, 4, to_underlying(type));
|
||||
SB(tile.type(), 4, TILE_TYPE_BITS, to_underlying(type));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,6 +36,7 @@ static constexpr uint MAX_SNOWLINE_HEIGHT = (MAX_TILE_HEIGHT - 2); ///< Maximum
|
||||
static constexpr uint DEF_SNOW_COVERAGE = 40; ///< Default snow coverage.
|
||||
static constexpr uint DEF_DESERT_COVERAGE = 50; ///< Default desert coverage.
|
||||
|
||||
static constexpr size_t TILE_TYPE_BITS = 4; ///< How many bits in map array are dedicated for type of each tile.
|
||||
|
||||
/**
|
||||
* The different types of tiles.
|
||||
@@ -57,8 +58,11 @@ enum class TileType : uint8_t {
|
||||
TunnelBridge, ///< Tunnel entry/exit and bridge heads.
|
||||
Object, ///< Contains objects such as transmitters and owned land.
|
||||
End, ///< End marker.
|
||||
MaxSize = 1U << TILE_TYPE_BITS, ///< The maximum possible number of tile types to be stored in map.
|
||||
};
|
||||
|
||||
static_assert(TileType::End <= TileType::MaxSize);
|
||||
|
||||
/**
|
||||
* Additional infos of a tile on a tropic game.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user