Codechange: Replace assert_compile macro with static_assert

This commit is contained in:
Charles Pigott
2020-12-27 10:44:22 +00:00
parent 395a5d9991
commit 860c270c73
77 changed files with 133 additions and 135 deletions

View File

@@ -406,7 +406,7 @@ extern const AirportSpec _origin_airport_specs[] = {
AS_GENERIC(&_airportfta_oilrig, nullptr, _default_airports_rotation, 0, nullptr, 0, 1, 1, 0, 4, 0, 0, 0, ATP_TTDP_OILRIG, APC_HELIPORT, STR_NULL, 0, false),
};
assert_compile(NEW_AIRPORT_OFFSET == lengthof(_origin_airport_specs));
static_assert(NEW_AIRPORT_OFFSET == lengthof(_origin_airport_specs));
const AirportSpec AirportSpec::dummy = AS_GENERIC(&_airportfta_dummy, nullptr, _default_airports_rotation, 0, nullptr, 0, 0, 0, 0, 0, MIN_YEAR, MIN_YEAR, 0, ATP_TTDP_LARGE, APC_BEGIN, STR_NULL, 0, false);

View File

@@ -104,7 +104,7 @@ static const AirportTileSpec _origin_airporttile_specs[] = {
AT(3, 1), // APT_GRASS_FENCE_NE_FLAG_2
};
assert_compile(NEW_AIRPORTTILE_OFFSET == lengthof(_origin_airporttile_specs));
static_assert(NEW_AIRPORTTILE_OFFSET == lengthof(_origin_airporttile_specs));
#undef AT_NOANIM
#undef AT

View File

@@ -620,4 +620,4 @@ static const NIFeature * const _nifeatures[] = {
&_nif_tramtype, // GSF_TRAMTYPES
&_nif_town, // GSF_FAKE_TOWNS
};
assert_compile(lengthof(_nifeatures) == GSF_FAKE_END);
static_assert(lengthof(_nifeatures) == GSF_FAKE_END);

View File

@@ -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
};
assert_compile(lengthof(_price_base_specs) == PR_END);
static_assert(lengthof(_price_base_specs) == PR_END);

View File

@@ -1545,11 +1545,11 @@ enum SpriteMasks {
PALETTE_MASK = MAX_PALETTES - 1, ///< The mask for the auxiliary sprite (the one that takes care of recolouring)
};
assert_compile( (1 << TRANSPARENT_BIT & SPRITE_MASK) == 0 );
assert_compile( (1 << RECOLOUR_BIT & SPRITE_MASK) == 0 );
assert_compile( TRANSPARENT_BIT != RECOLOUR_BIT );
assert_compile( (1 << TRANSPARENT_BIT & PALETTE_MASK) == 0);
assert_compile( (1 << RECOLOUR_BIT & PALETTE_MASK) == 0 );
static_assert( (1 << TRANSPARENT_BIT & SPRITE_MASK) == 0 );
static_assert( (1 << RECOLOUR_BIT & SPRITE_MASK) == 0 );
static_assert( TRANSPARENT_BIT != RECOLOUR_BIT );
static_assert( (1 << TRANSPARENT_BIT & PALETTE_MASK) == 0);
static_assert( (1 << RECOLOUR_BIT & PALETTE_MASK) == 0 );
static const PaletteID PAL_NONE = 0;

View File

@@ -988,7 +988,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. */
assert_compile(lengthof(_station_display_datas_rail) == lengthof(_station_display_datas_waypoint));
static_assert(lengthof(_station_display_datas_rail) == lengthof(_station_display_datas_waypoint));
static const DrawTileSprites * const _station_display_datas[] = {
_station_display_datas_rail,

View File

@@ -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 */
assert_compile(lengthof(_town_draw_tile_data) == (NEW_HOUSE_OFFSET) * 4 * 4);
static_assert(lengthof(_town_draw_tile_data) == (NEW_HOUSE_OFFSET) * 4 * 4);
/**
* Describes the data that defines each house in the game
@@ -2276,4 +2276,4 @@ static const HouseSpec _original_house_specs[] = {
#undef MS
/** Make sure we have the right number of elements: one entry for each house */
assert_compile(lengthof(_original_house_specs) == NEW_HOUSE_OFFSET);
static_assert(lengthof(_original_house_specs) == NEW_HOUSE_OFFSET);

View File

@@ -63,6 +63,6 @@ static const byte _wagon_full_adder[] = {
32, 32
};
assert_compile(lengthof(_engine_sprite_base) == lengthof(_engine_sprite_and));
assert_compile(lengthof(_engine_sprite_base) == lengthof(_engine_sprite_add));
assert_compile(lengthof(_engine_sprite_base) == lengthof(_wagon_full_adder));
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));