diff --git a/src/openrct2/Intro.cpp b/src/openrct2/Intro.cpp index 24a0a3be71..d34fff2d2b 100644 --- a/src/openrct2/Intro.cpp +++ b/src/openrct2/Intro.cpp @@ -19,8 +19,8 @@ #define BACKROUND_COLOUR_LOGO PALETTE_INDEX_245 #define BORDER_COLOUR_PUBLISHER PALETTE_INDEX_129 -#define PALETTE_G1_IDX_DEVELOPER 23217 -#define PALETTE_G1_IDX_LOGO 23224 +constexpr int32_t PALETTE_G1_IDX_DEVELOPER = 23217; +constexpr int32_t PALETTE_G1_IDX_LOGO = 23224; uint8_t gIntroState; diff --git a/src/openrct2/drawing/ScrollingText.cpp b/src/openrct2/drawing/ScrollingText.cpp index 441ece67c3..d06dd64f2e 100644 --- a/src/openrct2/drawing/ScrollingText.cpp +++ b/src/openrct2/drawing/ScrollingText.cpp @@ -30,7 +30,7 @@ struct rct_draw_scroll_text uint8_t bitmap[64 * 40]; }; -#define MAX_SCROLLING_TEXT_ENTRIES 32 +constexpr int32_t MAX_SCROLLING_TEXT_ENTRIES = 32; static rct_draw_scroll_text _drawScrollTextList[MAX_SCROLLING_TEXT_ENTRIES]; static uint8_t _characterBitmaps[FONT_SPRITE_GLYPH_COUNT + SPR_G2_GLYPH_COUNT][8]; diff --git a/src/openrct2/management/Award.cpp b/src/openrct2/management/Award.cpp index 0d01d19d3a..16784c6272 100644 --- a/src/openrct2/management/Award.cpp +++ b/src/openrct2/management/Award.cpp @@ -20,8 +20,8 @@ #include -#define NEGATIVE 0 -#define POSITIVE 1 +constexpr uint8_t NEGATIVE = 0; +constexpr uint8_t POSITIVE = 1; static constexpr const uint8_t AwardPositiveMap[] = { NEGATIVE, // PARK_AWARD_MOST_UNTIDY diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index e87e7e2760..ef581978b4 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -28,9 +28,6 @@ #include #include -#define ACTION_COOLDOWN_TIME_PLACE_SCENERY 20 -#define ACTION_COOLDOWN_TIME_DEMOLISH_RIDE 1000 - // This string specifies which version of network stream current build uses. // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. diff --git a/src/openrct2/ride/TrackDesignSave.cpp b/src/openrct2/ride/TrackDesignSave.cpp index 05bfcbddf1..209ed502e4 100644 --- a/src/openrct2/ride/TrackDesignSave.cpp +++ b/src/openrct2/ride/TrackDesignSave.cpp @@ -32,9 +32,8 @@ #include -#define TRACK_MAX_SAVED_TILE_ELEMENTS 1500 -#define TRACK_NEARBY_SCENERY_DISTANCE 1 -#define TRACK_TD6_MAX_ELEMENTS 8192 +constexpr size_t TRACK_MAX_SAVED_TILE_ELEMENTS = 1500; +constexpr int32_t TRACK_NEARBY_SCENERY_DISTANCE = 1; bool gTrackDesignSaveMode = false; ride_id_t gTrackDesignSaveRideIndex = RIDE_ID_NULL; diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 31fbe9028a..21c242dd78 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -86,12 +86,14 @@ static SoundId vehicle_update_scream_sound(rct_vehicle* vehicle); static void vehicle_kill_all_passengers(rct_vehicle* vehicle); static bool vehicle_can_depart_synchronised(rct_vehicle* vehicle); -#define VEHICLE_INVALID_ID (-1) +constexpr int32_t VEHICLE_INVALID_ID = -1; -#define VEHICLE_MAX_SPIN_SPEED 1536 -#define VEHICLE_MAX_SPIN_SPEED_FOR_STOPPING 700 -#define VEHICLE_MAX_SPIN_SPEED_WATER_RIDE 512 -#define VEHICLE_STOPPING_SPIN_SPEED 600 +constexpr int16_t VEHICLE_MAX_SPIN_SPEED = 1536; +constexpr int16_t VEHICLE_MIN_SPIN_SPEED = -VEHICLE_MAX_SPIN_SPEED; +constexpr int16_t VEHICLE_MAX_SPIN_SPEED_FOR_STOPPING = 700; +constexpr int16_t VEHICLE_MAX_SPIN_SPEED_WATER_RIDE = 512; +constexpr int16_t VEHICLE_MIN_SPIN_SPEED_WATER_RIDE = -VEHICLE_MAX_SPIN_SPEED_WATER_RIDE; +constexpr int16_t VEHICLE_STOPPING_SPIN_SPEED = 600; rct_vehicle* gCurrentVehicle; @@ -2672,7 +2674,7 @@ struct rct_synchronised_vehicle assert_struct_size(rct_synchronised_vehicle, 4); #pragma pack(pop) -#define SYNCHRONISED_VEHICLE_COUNT 16 +constexpr int32_t SYNCHRONISED_VEHICLE_COUNT = 16; // Synchronised vehicle info static rct_synchronised_vehicle _synchronisedVehicles[SYNCHRONISED_VEHICLE_COUNT] = {}; @@ -7182,8 +7184,7 @@ static void vehicle_update_spinning_car(rct_vehicle* vehicle) break; } - spinSpeed = std::clamp( - vehicle->spin_speed, static_cast(-VEHICLE_MAX_SPIN_SPEED), static_cast(VEHICLE_MAX_SPIN_SPEED)); + spinSpeed = std::clamp(vehicle->spin_speed, VEHICLE_MIN_SPIN_SPEED, VEHICLE_MAX_SPIN_SPEED); vehicle->spin_speed = spinSpeed; vehicle->spin_sprite += spinSpeed >> 8; // Note this actually increases the spin speed if going right! @@ -9388,8 +9389,7 @@ loc_6DCEFF: if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING) { vehicle->spin_speed = std::clamp( - vehicle->spin_speed, static_cast(-VEHICLE_MAX_SPIN_SPEED_WATER_RIDE), - static_cast(VEHICLE_MAX_SPIN_SPEED_WATER_RIDE)); + vehicle->spin_speed, VEHICLE_MIN_SPIN_SPEED_WATER_RIDE, VEHICLE_MAX_SPIN_SPEED_WATER_RIDE); } if (vehicle->vehicle_sprite_type != 0) @@ -9508,8 +9508,7 @@ static void vehicle_update_track_motion_powered_ride_acceleration( if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING) { vehicle->spin_speed = std::clamp( - vehicle->spin_speed, static_cast(-VEHICLE_MAX_SPIN_SPEED_WATER_RIDE), - static_cast(VEHICLE_MAX_SPIN_SPEED_WATER_RIDE)); + vehicle->spin_speed, VEHICLE_MIN_SPIN_SPEED_WATER_RIDE, VEHICLE_MAX_SPIN_SPEED_WATER_RIDE); } if (vehicle->vehicle_sprite_type != 0) diff --git a/src/openrct2/ride/coaster/SideFrictionRollerCoaster.cpp b/src/openrct2/ride/coaster/SideFrictionRollerCoaster.cpp index 2b8524524f..c8130792b0 100644 --- a/src/openrct2/ride/coaster/SideFrictionRollerCoaster.cpp +++ b/src/openrct2/ride/coaster/SideFrictionRollerCoaster.cpp @@ -19,52 +19,52 @@ #include "../TrackData.h" #include "../TrackPaint.h" -#define SPR_SIDE_FRICTION_60_DEG_UP_DIR_0_A 21646 -#define SPR_SIDE_FRICTION_60_DEG_UP_DIR_0_B 21658 -#define SPR_SIDE_FRICTION_60_DEG_UP_DIR_1_A 21647 -#define SPR_SIDE_FRICTION_60_DEG_UP_DIR_1_B 21659 -#define SPR_SIDE_FRICTION_60_DEG_UP_DIR_2_A 21648 -#define SPR_SIDE_FRICTION_60_DEG_UP_DIR_2_B 21660 -#define SPR_SIDE_FRICTION_60_DEG_UP_DIR_3_A 21649 -#define SPR_SIDE_FRICTION_60_DEG_UP_DIR_3_B 21661 +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_DIR_0_B = 21658; +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_DIR_1_A = 21647; +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_DIR_1_B = 21659; +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_DIR_2_A = 21648; +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_DIR_0_A = 21646; +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_DIR_2_B = 21660; +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_DIR_3_A = 21649; +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_DIR_3_B = 21661; -#define SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_0_A 21638 -#define SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_0_B 21650 -#define SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_1_A 21639 -#define SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_1_B 21651 -#define SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_2_A 21640 -#define SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_2_B 21652 -#define SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_3_A 21641 -#define SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_3_B 21653 +constexpr int32_t SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_0_A = 21638; +constexpr int32_t SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_0_B = 21650; +constexpr int32_t SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_1_A = 21639; +constexpr int32_t SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_1_B = 21651; +constexpr int32_t SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_2_A = 21640; +constexpr int32_t SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_2_B = 21652; +constexpr int32_t SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_3_A = 21641; +constexpr int32_t SPR_SIDE_FRICTION_25_DEG_UP_TO_60_DEG_UP_DIR_3_B = 21653; -#define SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_0_A 21642 -#define SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_0_B 21654 -#define SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_1_A 21643 -#define SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_1_B 21655 -#define SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_2_A 21644 -#define SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_2_B 21656 -#define SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_3_A 21645 -#define SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_3_B 21657 +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_0_A = 21642; +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_0_B = 21654; +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_1_A = 21643; +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_1_B = 21655; +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_2_A = 21644; +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_2_B = 21656; +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_3_A = 21645; +constexpr int32_t SPR_SIDE_FRICTION_60_DEG_UP_TO_25_DEG_UP_DIR_3_B = 21657; -#define SPR_SIDE_FRICTION_DIAG_60_DEG_UP_DIR_0_A 21882 -#define SPR_SIDE_FRICTION_DIAG_60_DEG_UP_DIR_0_B 21886 -#define SPR_SIDE_FRICTION_DIAG_60_DEG_UP_DIR_1_A 21883 // Needs no B piece -#define SPR_SIDE_FRICTION_DIAG_60_DEG_UP_DIR_2_A 21884 -#define SPR_SIDE_FRICTION_DIAG_60_DEG_UP_DIR_2_B 21887 -#define SPR_SIDE_FRICTION_DIAG_60_DEG_UP_DIR_3_A 21885 // Needs no B piece +constexpr int32_t SPR_SIDE_FRICTION_DIAG_60_DEG_UP_DIR_0_A = 21882; +constexpr int32_t SPR_SIDE_FRICTION_DIAG_60_DEG_UP_DIR_0_B = 21886; +constexpr int32_t SPR_SIDE_FRICTION_DIAG_60_DEG_UP_DIR_1_A = 21883; // Needs no B piece +constexpr int32_t SPR_SIDE_FRICTION_DIAG_60_DEG_UP_DIR_2_A = 21884; +constexpr int32_t SPR_SIDE_FRICTION_DIAG_60_DEG_UP_DIR_2_B = 21887; +constexpr int32_t SPR_SIDE_FRICTION_DIAG_60_DEG_UP_DIR_3_A = 21885; // Needs no B piece // Whole block appears to lack B counterparts -#define SPR_SIDE_FRICTION_DIAG_25_DEG_UP_TO_60_DEG_UP_DIR_0_A 21870 -#define SPR_SIDE_FRICTION_DIAG_25_DEG_UP_TO_60_DEG_UP_DIR_1_A 21871 -#define SPR_SIDE_FRICTION_DIAG_25_DEG_UP_TO_60_DEG_UP_DIR_2_A 21872 -#define SPR_SIDE_FRICTION_DIAG_25_DEG_UP_TO_60_DEG_UP_DIR_3_A 21873 +constexpr int32_t SPR_SIDE_FRICTION_DIAG_25_DEG_UP_TO_60_DEG_UP_DIR_0_A = 21870; +constexpr int32_t SPR_SIDE_FRICTION_DIAG_25_DEG_UP_TO_60_DEG_UP_DIR_1_A = 21871; +constexpr int32_t SPR_SIDE_FRICTION_DIAG_25_DEG_UP_TO_60_DEG_UP_DIR_2_A = 21872; +constexpr int32_t SPR_SIDE_FRICTION_DIAG_25_DEG_UP_TO_60_DEG_UP_DIR_3_A = 21873; -#define SPR_SIDE_FRICTION_DIAG_60_DEG_UP_TO_25_DEG_UP_DIR_0_A 21876 -#define SPR_SIDE_FRICTION_DIAG_60_DEG_UP_TO_25_DEG_UP_DIR_0_B 21880 -#define SPR_SIDE_FRICTION_DIAG_60_DEG_UP_TO_25_DEG_UP_DIR_1_A 21877 // Needs no B piece -#define SPR_SIDE_FRICTION_DIAG_60_DEG_UP_TO_25_DEG_UP_DIR_2_A 21878 -#define SPR_SIDE_FRICTION_DIAG_60_DEG_UP_TO_25_DEG_UP_DIR_2_B 21881 -#define SPR_SIDE_FRICTION_DIAG_60_DEG_UP_TO_25_DEG_UP_DIR_3_A 21879 // Needs no B piece +constexpr int32_t SPR_SIDE_FRICTION_DIAG_60_DEG_UP_TO_25_DEG_UP_DIR_0_A = 21876; +constexpr int32_t SPR_SIDE_FRICTION_DIAG_60_DEG_UP_TO_25_DEG_UP_DIR_0_B = 21880; +constexpr int32_t SPR_SIDE_FRICTION_DIAG_60_DEG_UP_TO_25_DEG_UP_DIR_1_A = 21877; // Needs no B piece +constexpr int32_t SPR_SIDE_FRICTION_DIAG_60_DEG_UP_TO_25_DEG_UP_DIR_2_A = 21878; +constexpr int32_t SPR_SIDE_FRICTION_DIAG_60_DEG_UP_TO_25_DEG_UP_DIR_2_B = 21881; +constexpr int32_t SPR_SIDE_FRICTION_DIAG_60_DEG_UP_TO_25_DEG_UP_DIR_3_A = 21879; // Needs no B piece /** rct2: 0x0077839C */ static void side_friction_rc_track_flat( diff --git a/src/openrct2/util/Util.cpp b/src/openrct2/util/Util.cpp index 0cd47c5cfb..442b2d5113 100644 --- a/src/openrct2/util/Util.cpp +++ b/src/openrct2/util/Util.cpp @@ -533,8 +533,8 @@ uint32_t util_rand() return _prng(); } -#define CHUNK (128 * 1024) -#define MAX_ZLIB_REALLOC (4 * 1024 * 1024) +constexpr size_t CHUNK = 128 * 1024; +constexpr int32_t MAX_ZLIB_REALLOC = 4 * 1024 * 1024; /** * @brief Inflates zlib-compressed data diff --git a/src/openrct2/world/MapGen.cpp b/src/openrct2/world/MapGen.cpp index 8b37ff45b9..f189a7ac25 100644 --- a/src/openrct2/world/MapGen.cpp +++ b/src/openrct2/world/MapGen.cpp @@ -82,8 +82,6 @@ static constexpr const char* SnowTrees[] = { // Randomly chosen base terrains. We rarely want a whole map made out of chequerboard or rock. static constexpr const uint8_t BaseTerrain[] = { TERRAIN_GRASS, TERRAIN_SAND, TERRAIN_SAND_LIGHT, TERRAIN_DIRT, TERRAIN_ICE }; -#define BLOB_HEIGHT 255 - static void mapgen_place_trees(); static void mapgen_set_water_level(int32_t waterLevel); static void mapgen_smooth_height(int32_t iterations);