Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ bool HasBridgeFlatRamp(Slope tileh, Axis axis);
*/
inline const BridgeSpec *GetBridgeSpec(BridgeType i)
{
assert(i < lengthof(_bridge));
assert(i < std::size(_bridge));
return &_bridge[i];
}

Expand Down
4 changes: 2 additions & 2 deletions src/cargotype.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ struct CargoSpec {
*/
static inline size_t GetArraySize()
{
return lengthof(CargoSpec::array);
return std::size(CargoSpec::array);
}

/**
Expand All @@ -130,7 +130,7 @@ struct CargoSpec {
*/
static inline CargoSpec *Get(size_t index)
{
assert(index < lengthof(CargoSpec::array));
assert(index < CargoSpec::GetArraySize());
return &CargoSpec::array[index];
}

Expand Down
2 changes: 1 addition & 1 deletion src/company_manager_face.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static const CompanyManagerFaceBitsInfo _cmf_info[] = {
/* CMFV_GLASSES */ { 31, 1, { 2, 2, 2, 2 }, { 0x347, 0x347, 0x3AE, 0x3AE } } ///< Depends on CMFV_HAS_GLASSES
};
/** Make sure the table's size is right. */
static_assert(lengthof(_cmf_info) == CMFV_END);
static_assert(std::size(_cmf_info) == CMFV_END);

/**
* Gets the company manager's face bits for the given company manager's face variable
Expand Down
2 changes: 1 addition & 1 deletion src/table/airport_defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ extern const AirportSpec _origin_airport_specs[] = {
AS_GENERIC(&_airportfta_oilrig, {}, {}, 1, 1, 0, 4, 0, 0, 0, ATP_TTDP_OILRIG, APC_HELIPORT, STR_NULL, 0, false),
};

static_assert(NEW_AIRPORT_OFFSET == lengthof(_origin_airport_specs));
static_assert(NEW_AIRPORT_OFFSET == std::size(_origin_airport_specs));

const AirportSpec AirportSpec::dummy = AS_GENERIC(&_airportfta_dummy, {}, {}, 0, 0, 0, 0, CalendarTime::MIN_YEAR, CalendarTime::MIN_YEAR, 0, ATP_TTDP_LARGE, APC_BEGIN, STR_NULL, 0, false);

Expand Down
2 changes: 1 addition & 1 deletion src/table/airporttiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static const AirportTileSpec _origin_airporttile_specs[] = {
AT(3, 1), // APT_GRASS_FENCE_NE_FLAG_2
};

static_assert(NEW_AIRPORTTILE_OFFSET == lengthof(_origin_airporttile_specs));
static_assert(NEW_AIRPORTTILE_OFFSET == std::size(_origin_airporttile_specs));

#undef AT_NOANIM
#undef AT
Expand Down
2 changes: 1 addition & 1 deletion src/table/newgrf_debug_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -743,4 +743,4 @@ static const NIFeature * const _nifeatures[] = {
&_nif_roadstop, // GSF_ROADSTOPS
&_nif_town, // GSF_FAKE_TOWNS
};
static_assert(lengthof(_nifeatures) == GSF_FAKE_END);
static_assert(std::size(_nifeatures) == GSF_FAKE_END);
2 changes: 1 addition & 1 deletion src/table/pricebase.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ extern const PriceBaseSpec _price_base_specs[] = {
{ 100, PCAT_RUNNING, GSF_END, PR_STATION_VALUE }, ///< PR_INFRASTRUCTURE_STATION
{ 5000, PCAT_RUNNING, GSF_END, PR_BUILD_STATION_AIRPORT}, ///< PR_INFRASTRUCTURE_AIRPORT
};
static_assert(lengthof(_price_base_specs) == PR_END);
static_assert(std::size(_price_base_specs) == PR_END);
2 changes: 1 addition & 1 deletion src/table/station_land.h
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ static const DrawTileSprites _station_display_datas_waypoint[] = {

/* Default waypoint is also drawn as fallback for NewGRF waypoints.
* As these are drawn/build like stations, they may use the same number of layouts. */
static_assert(lengthof(_station_display_datas_rail) == lengthof(_station_display_datas_waypoint));
static_assert(std::size(_station_display_datas_rail) == std::size(_station_display_datas_waypoint));

static const DrawTileSprites * const _station_display_datas[] = {
_station_display_datas_rail,
Expand Down
4 changes: 2 additions & 2 deletions src/table/town_land.h
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,7 @@ static const DrawBuildingsTileStruct _town_draw_tile_data[] = {
};
#undef M
/** Make sure we have the right number of elements: 4 variants * 4 build stages for each house */
static_assert(lengthof(_town_draw_tile_data) == (NEW_HOUSE_OFFSET) * 4 * 4);
static_assert(std::size(_town_draw_tile_data) == (NEW_HOUSE_OFFSET) * 4 * 4);

/**
* Describes the data that defines each house in the game
Expand Down Expand Up @@ -2277,4 +2277,4 @@ extern const HouseSpec _original_house_specs[] = {
#undef MS

/** Make sure we have the right number of elements: one entry for each house */
static_assert(lengthof(_original_house_specs) == NEW_HOUSE_OFFSET);
static_assert(std::size(_original_house_specs) == NEW_HOUSE_OFFSET);
6 changes: 3 additions & 3 deletions src/table/train_sprites.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ static const uint8_t _wagon_full_adder[] = {
32, 32
};

static_assert(lengthof(_engine_sprite_base) == lengthof(_engine_sprite_and));
static_assert(lengthof(_engine_sprite_base) == lengthof(_engine_sprite_add));
static_assert(lengthof(_engine_sprite_base) == lengthof(_wagon_full_adder));
static_assert(std::size(_engine_sprite_base) == std::size(_engine_sprite_and));
static_assert(std::size(_engine_sprite_base) == std::size(_engine_sprite_add));
static_assert(std::size(_engine_sprite_base) == std::size(_wagon_full_adder));