Merge pull request #15292 from ZehMatt/refactor/paint-constexpr

Apply constexpr where possible
This commit is contained in:
ζeh Matt 2021-08-27 13:04:24 -07:00 committed by GitHub
commit 85d3dc2a84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 98 additions and 61 deletions

View File

@ -239,7 +239,12 @@ CoordsXYZ viewport_adjust_for_map_height(const ScreenCoordsXY& startCoords)
auto max = GetMapSizeMinus2(); auto max = GetMapSizeMinus2();
if (pos.x > max && pos.y > max) if (pos.x > max && pos.y > max)
{ {
const CoordsXY corr[] = { { -1, -1 }, { 1, -1 }, { 1, 1 }, { -1, 1 } }; static constexpr CoordsXY corr[] = {
{ -1, -1 },
{ 1, -1 },
{ 1, 1 },
{ -1, 1 },
};
pos.x += corr[rotation].x * height; pos.x += corr[rotation].x * height;
pos.y += corr[rotation].y * height; pos.y += corr[rotation].y * height;
} }

View File

@ -447,13 +447,13 @@ namespace HybridRC
{ 24, 6, height + 8 }, { 24, 6, height + 8 },
{ 4, 6, height + 8 }, { 4, 6, height + 8 },
}; };
static const CoordsXYZ boundBoxLengths[4] = { static constexpr CoordsXYZ boundBoxLengths[4] = {
{ 2, 20, 31 }, { 2, 20, 31 },
{ 2, 20, 31 }, { 2, 20, 31 },
{ 2, 20, 31 }, { 2, 20, 31 },
{ 2, 20, 31 }, { 2, 20, 31 },
}; };
static const uint32_t imageIds[4] = { static constexpr uint32_t imageIds[4] = {
SPR_G2_HYBRID_TRACK_VERTICAL + 8, SPR_G2_HYBRID_TRACK_VERTICAL + 8,
SPR_G2_HYBRID_TRACK_VERTICAL + 9, SPR_G2_HYBRID_TRACK_VERTICAL + 9,
SPR_G2_HYBRID_TRACK_VERTICAL + 10, SPR_G2_HYBRID_TRACK_VERTICAL + 10,
@ -492,13 +492,13 @@ namespace HybridRC
{ 24, 6, height }, { 24, 6, height },
{ 0, 6, height }, { 0, 6, height },
}; };
static const CoordsXYZ boundBoxLengths[4] = { static constexpr CoordsXYZ boundBoxLengths[4] = {
{ 32, 20, 3 }, { 32, 20, 3 },
{ 2, 20, 55 }, { 2, 20, 55 },
{ 2, 20, 55 }, { 2, 20, 55 },
{ 32, 20, 3 }, { 32, 20, 3 },
}; };
static const uint32_t imageIds[4] = { static constexpr uint32_t imageIds[4] = {
SPR_G2_HYBRID_TRACK_VERTICAL + 0, SPR_G2_HYBRID_TRACK_VERTICAL + 0,
SPR_G2_HYBRID_TRACK_VERTICAL + 1, SPR_G2_HYBRID_TRACK_VERTICAL + 1,
SPR_G2_HYBRID_TRACK_VERTICAL + 2, SPR_G2_HYBRID_TRACK_VERTICAL + 2,
@ -543,13 +543,13 @@ namespace HybridRC
{ 24, 6, height + 8 }, { 24, 6, height + 8 },
{ 0, 6, height + 8 }, { 0, 6, height + 8 },
}; };
static const CoordsXYZ boundBoxLengths[4] = { static constexpr CoordsXYZ boundBoxLengths[4] = {
{ 32, 20, 3 }, { 32, 20, 3 },
{ 2, 20, 31 }, { 2, 20, 31 },
{ 2, 20, 31 }, { 2, 20, 31 },
{ 32, 20, 3 }, { 32, 20, 3 },
}; };
static const uint32_t imageIds[4] = { static constexpr uint32_t imageIds[4] = {
SPR_G2_HYBRID_TRACK_VERTICAL + 4, SPR_G2_HYBRID_TRACK_VERTICAL + 4,
SPR_G2_HYBRID_TRACK_VERTICAL + 5, SPR_G2_HYBRID_TRACK_VERTICAL + 5,
SPR_G2_HYBRID_TRACK_VERTICAL + 6, SPR_G2_HYBRID_TRACK_VERTICAL + 6,

View File

@ -2509,7 +2509,7 @@ void junior_rc_paint_track_left_quarter_turn_5_tiles_25_deg_up(
junior_rc_track_pieces_left_quarter_turn_5_tiles_25_deg_up[EnumValue(chainType)], junior_rc_track_pieces_left_quarter_turn_5_tiles_25_deg_up[EnumValue(chainType)],
junior_rc_left_quarter_turn_5_tiles_25_deg_up_offsets, defaultRightQuarterTurn5TilesBoundLengths, nullptr); junior_rc_left_quarter_turn_5_tiles_25_deg_up_offsets, defaultRightQuarterTurn5TilesBoundLengths, nullptr);
uint8_t supportSpecial[4] = { 8, 8, 8, 3 }; static constexpr uint8_t supportSpecial[4] = { 8, 8, 8, 3 };
switch (trackSequence) switch (trackSequence)
{ {
case 0: case 0:
@ -2589,7 +2589,7 @@ void junior_rc_paint_track_right_quarter_turn_5_tiles_25_deg_up(
junior_rc_track_pieces_right_quarter_turn_5_tiles_25_deg_up[EnumValue(chainType)], defaultRightQuarterTurn5TilesOffsets, junior_rc_track_pieces_right_quarter_turn_5_tiles_25_deg_up[EnumValue(chainType)], defaultRightQuarterTurn5TilesOffsets,
defaultRightQuarterTurn5TilesBoundLengths, nullptr); defaultRightQuarterTurn5TilesBoundLengths, nullptr);
uint8_t supportSpecial[4] = { 11, 8, 8, 7 }; static constexpr uint8_t supportSpecial[4] = { 11, 8, 8, 7 };
switch (trackSequence) switch (trackSequence)
{ {
case 0: case 0:
@ -2712,14 +2712,14 @@ static void junior_rc_s_bend_left_paint_setup(
trackSequence = 3 - trackSequence; trackSequence = 3 - trackSequence;
} }
const CoordsXY offsetList[] = { static constexpr CoordsXY offsetList[] = {
{ 0, 6 }, { 0, 6 },
{ 0, 0 }, { 0, 0 },
{ 0, 6 }, { 0, 6 },
{ 0, 6 }, { 0, 6 },
}; };
const CoordsXY boundsList[] = { static constexpr CoordsXY boundsList[] = {
{ 32, 20 }, { 32, 20 },
{ 32, 26 }, { 32, 26 },
{ 32, 26 }, { 32, 26 },
@ -2816,14 +2816,14 @@ static void junior_rc_s_bend_right_paint_setup(
trackSequence = 3 - trackSequence; trackSequence = 3 - trackSequence;
} }
const CoordsXY offsetList[] = { static constexpr CoordsXY offsetList[] = {
{ 0, 6 }, { 0, 6 },
{ 0, 6 }, { 0, 6 },
{ 0, 0 }, { 0, 0 },
{ 0, 6 }, { 0, 6 },
}; };
const CoordsXY boundsList[] = { static constexpr CoordsXY boundsList[] = {
{ 32, 20 }, { 32, 20 },
{ 32, 26 }, { 32, 26 },
{ 32, 26 }, { 32, 26 },
@ -2921,7 +2921,10 @@ static void junior_rc_right_quarter_turn_3_tiles_paint_setup(
defaultRightQuarterTurn3TilesBoundLengths, nullptr); defaultRightQuarterTurn3TilesBoundLengths, nullptr);
track_paint_util_right_quarter_turn_3_tiles_tunnel(session, height, direction, trackSequence, TUNNEL_0); track_paint_util_right_quarter_turn_3_tiles_tunnel(session, height, direction, trackSequence, TUNNEL_0);
uint8_t supportType[2][4] = { { 1, 0, 0, 2 }, { 2, 0, 0, 1 } }; static constexpr uint8_t supportType[2][4] = {
{ 1, 0, 0, 2 },
{ 2, 0, 0, 1 },
};
switch (trackSequence) switch (trackSequence)
{ {
case 0: case 0:
@ -3009,7 +3012,12 @@ static void junior_rc_right_quarter_turn_3_tiles_bank_paint_setup(
paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height, paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
const TrackElement& trackElement) const TrackElement& trackElement)
{ {
uint8_t thickness[4][4] = { { 1, 1, 1, 1 }, { 1, 1, 1, 1 }, { 26, 1, 1, 26 }, { 1, 1, 1, 1 } }; static constexpr uint8_t thickness[4][4] = {
{ 1, 1, 1, 1 },
{ 1, 1, 1, 1 },
{ 26, 1, 1, 26 },
{ 1, 1, 1, 1 },
};
track_paint_util_right_quarter_turn_3_tiles_paint( track_paint_util_right_quarter_turn_3_tiles_paint(
session, thickness[direction][trackSequence], height, direction, trackSequence, session->TrackColours[SCHEME_TRACK], session, thickness[direction][trackSequence], height, direction, trackSequence, session->TrackColours[SCHEME_TRACK],
@ -3187,7 +3195,10 @@ void junior_rc_paint_track_right_quarter_turn_3_tiles_25_deg_down(
paint_util_push_tunnel_right(session, height + 8, TUNNEL_2); paint_util_push_tunnel_right(session, height + 8, TUNNEL_2);
} }
uint8_t supportType[2][4] = { { 1, 0, 0, 2 }, { 2, 0, 0, 1 } }; static constexpr uint8_t supportType[2][4] = {
{ 1, 0, 0, 2 },
{ 2, 0, 0, 1 },
};
switch (trackSequence) switch (trackSequence)
{ {
case 0: case 0:
@ -3274,7 +3285,7 @@ static void junior_rc_right_half_banked_helix_up_small_paint_setup(
paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height, paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
const TrackElement& trackElement) const TrackElement& trackElement)
{ {
const int8_t thickness[2] = { 1, 26 }; static constexpr int8_t thickness[2] = { 1, 26 };
if (trackSequence > 3) if (trackSequence > 3)
{ {
@ -3342,7 +3353,7 @@ static void junior_rc_right_half_banked_helix_down_small_paint_setup(
paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height, paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
const TrackElement& trackElement) const TrackElement& trackElement)
{ {
const int8_t thickness[2] = { 1, 26 }; static constexpr int8_t thickness[2] = { 1, 26 };
if (trackSequence > 3) if (trackSequence > 3)
{ {
@ -3442,7 +3453,7 @@ static void junior_rc_right_half_banked_helix_up_large_paint_setup(
paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height, paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
const TrackElement& trackElement) const TrackElement& trackElement)
{ {
const int8_t thickness[2] = { 1, 26 }; static constexpr int8_t thickness[2] = { 1, 26 };
if (trackSequence > 6) if (trackSequence > 6)
{ {
@ -3528,7 +3539,7 @@ static void junior_rc_right_half_banked_helix_down_large_paint_setup(
paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height, paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
const TrackElement& trackElement) const TrackElement& trackElement)
{ {
const int8_t thickness[2] = { 1, 26 }; static constexpr int8_t thickness[2] = { 1, 26 };
if (trackSequence > 6) if (trackSequence > 6)
{ {
@ -4162,7 +4173,7 @@ static void junior_rc_left_eighth_to_orthogonal_bank_paint_setup(
paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height, paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
const TrackElement& trackElement) const TrackElement& trackElement)
{ {
const uint8_t map[] = { 4, 2, 3, 1, 0 }; static constexpr uint8_t map[] = { 4, 2, 3, 1, 0 };
trackSequence = map[trackSequence]; trackSequence = map[trackSequence];
junior_rc_right_eighth_to_diag_bank_paint_setup(session, ride, trackSequence, (direction + 2) % 4, height, trackElement); junior_rc_right_eighth_to_diag_bank_paint_setup(session, ride, trackSequence, (direction + 2) % 4, height, trackElement);
} }
@ -4172,7 +4183,7 @@ static void junior_rc_right_eighth_to_orthogonal_bank_paint_setup(
paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height, paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
const TrackElement& trackElement) const TrackElement& trackElement)
{ {
const uint8_t map[] = { 4, 2, 3, 1, 0 }; static constexpr uint8_t map[] = { 4, 2, 3, 1, 0 };
trackSequence = map[trackSequence]; trackSequence = map[trackSequence];
junior_rc_left_eighth_to_diag_bank_paint_setup(session, ride, trackSequence, (direction + 3) % 4, height, trackElement); junior_rc_left_eighth_to_diag_bank_paint_setup(session, ride, trackSequence, (direction + 3) % 4, height, trackElement);
} }
@ -4978,7 +4989,7 @@ void junior_rc_paint_track_60_deg_up(
break; break;
} }
int8_t support[4] = { 35, 29, 25, 32 }; static constexpr int8_t support[4] = { 35, 29, 25, 32 };
if (track_paint_util_should_paint_supports(session->MapPosition)) if (track_paint_util_should_paint_supports(session->MapPosition))
{ {
metal_a_supports_paint_setup( metal_a_supports_paint_setup(
@ -5067,7 +5078,7 @@ void junior_rc_paint_track_25_deg_up_to_60_deg_up(
break; break;
} }
int8_t support[4] = { 12, 12, 12, 14 }; static constexpr int8_t support[4] = { 12, 12, 12, 14 };
if (track_paint_util_should_paint_supports(session->MapPosition)) if (track_paint_util_should_paint_supports(session->MapPosition))
{ {
metal_a_supports_paint_setup( metal_a_supports_paint_setup(
@ -5449,7 +5460,7 @@ static void junior_rc_flat_to_60_deg_up_paint_setup(
break; break;
} }
int8_t support[4] = { 12, 12, 12, 14 }; static constexpr int8_t support[4] = { 12, 12, 12, 14 };
if (track_paint_util_should_paint_supports(session->MapPosition)) if (track_paint_util_should_paint_supports(session->MapPosition))
{ {
metal_a_supports_paint_setup( metal_a_supports_paint_setup(

View File

@ -18,8 +18,11 @@
#include "../TrackData.h" #include "../TrackData.h"
#include "../TrackPaint.h" #include "../TrackPaint.h"
#define LOOPING_RC_BOOSTER_NE_SW (SPR_CSG_BEGIN + 55679) static constexpr auto SPR_LOOPING_RC_BOOSTER_NE_SW = (SPR_CSG_BEGIN + 55679);
#define LOOPING_RC_BOOSTER_NW_SE (SPR_CSG_BEGIN + 55680) static constexpr auto SPR_LOOPING_RC_BOOSTER_NW_SE = (SPR_CSG_BEGIN + 55680);
static constexpr auto SPR_LOOPING_RC_FLAT_CHAINED_SW_NE = 15016;
static constexpr auto SPR_LOOPING_RC_FLAT_CHAINED_NW_SE = 15017;
/** rct2: 0x008A6370 */ /** rct2: 0x008A6370 */
static void looping_rc_track_flat( static void looping_rc_track_flat(
@ -82,15 +85,19 @@ static void looping_rc_track_station(
paint_session* session, const Ride* ride, [[maybe_unused]] uint8_t trackSequence, uint8_t direction, int32_t height, paint_session* session, const Ride* ride, [[maybe_unused]] uint8_t trackSequence, uint8_t direction, int32_t height,
const TrackElement& trackElement) const TrackElement& trackElement)
{ {
const uint32_t stationTrackNESW = is_csg_loaded() ? LOOPING_RC_BOOSTER_NE_SW : 15016; static constexpr uint32_t imageIdsWithCsg[4][2] = {
const uint32_t stationTrackNWSE = is_csg_loaded() ? LOOPING_RC_BOOSTER_NW_SE : 15017; { SPR_LOOPING_RC_BOOSTER_NE_SW, SPR_STATION_BASE_B_SW_NE },
{ SPR_LOOPING_RC_BOOSTER_NW_SE, SPR_STATION_BASE_B_NW_SE },
static const uint32_t imageIds[4][2] = { { SPR_LOOPING_RC_BOOSTER_NE_SW, SPR_STATION_BASE_B_SW_NE },
{ stationTrackNESW, SPR_STATION_BASE_B_SW_NE }, { SPR_LOOPING_RC_BOOSTER_NW_SE, SPR_STATION_BASE_B_NW_SE },
{ stationTrackNWSE, SPR_STATION_BASE_B_NW_SE },
{ stationTrackNESW, SPR_STATION_BASE_B_SW_NE },
{ stationTrackNWSE, SPR_STATION_BASE_B_NW_SE },
}; };
static constexpr uint32_t imageIdsWithoutCsg[4][2] = {
{ SPR_LOOPING_RC_FLAT_CHAINED_SW_NE, SPR_STATION_BASE_B_SW_NE },
{ SPR_LOOPING_RC_FLAT_CHAINED_NW_SE, SPR_STATION_BASE_B_NW_SE },
{ SPR_LOOPING_RC_FLAT_CHAINED_SW_NE, SPR_STATION_BASE_B_SW_NE },
{ SPR_LOOPING_RC_FLAT_CHAINED_NW_SE, SPR_STATION_BASE_B_NW_SE },
};
const auto imageIds = is_csg_loaded() ? imageIdsWithCsg : imageIdsWithoutCsg;
PaintAddImageAsParentRotated( PaintAddImageAsParentRotated(
session, direction, imageIds[direction][0] | session->TrackColours[SCHEME_TRACK], 0, 0, 32, 20, 1, height, 0, 6, session, direction, imageIds[direction][0] | session->TrackColours[SCHEME_TRACK], 0, 0, 32, 20, 1, height, 0, 6,
@ -9165,14 +9172,14 @@ static void looping_rc_track_booster(
case 0: case 0:
case 2: case 2:
PaintAddImageAsParentRotated( PaintAddImageAsParentRotated(
session, direction, session->TrackColours[SCHEME_TRACK] | LOOPING_RC_BOOSTER_NE_SW, 0, 0, 32, 20, 3, height, 0, session, direction, session->TrackColours[SCHEME_TRACK] | SPR_LOOPING_RC_BOOSTER_NE_SW, 0, 0, 32, 20, 3, height,
6, height); 0, 6, height);
break; break;
case 1: case 1:
case 3: case 3:
PaintAddImageAsParentRotated( PaintAddImageAsParentRotated(
session, direction, session->TrackColours[SCHEME_TRACK] | LOOPING_RC_BOOSTER_NW_SE, 0, 0, 32, 20, 3, height, 0, session, direction, session->TrackColours[SCHEME_TRACK] | SPR_LOOPING_RC_BOOSTER_NW_SE, 0, 0, 32, 20, 3, height,
6, height); 0, 6, height);
break; break;
} }
if (track_paint_util_should_paint_supports(session->MapPosition)) if (track_paint_util_should_paint_supports(session->MapPosition))

View File

@ -572,14 +572,18 @@ static uint32_t miniature_railway_track_to_grooved_indent(
if (direction & 0x1) if (direction & 0x1)
{ {
uint32_t imageIds[2][2] = { { SPR_G2_MINIATURE_RAILWAY_INSET_NW_SE, SPR_G2_MINIATURE_RAILWAY_INSET_END_NW }, static constexpr uint32_t imageIds[2][2] = {
{ SPR_G2_MINIATURE_RAILWAY_INSET_END_SE, SPR_G2_MINIATURE_RAILWAY_INSET_END_NW_SE } }; { SPR_G2_MINIATURE_RAILWAY_INSET_NW_SE, SPR_G2_MINIATURE_RAILWAY_INSET_END_NW },
{ SPR_G2_MINIATURE_RAILWAY_INSET_END_SE, SPR_G2_MINIATURE_RAILWAY_INSET_END_NW_SE },
};
imageIdAlt = imageIds[(correctedEdges & 0x2) ? 0 : 1][(correctedEdges & 0x8) ? 0 : 1]; imageIdAlt = imageIds[(correctedEdges & 0x2) ? 0 : 1][(correctedEdges & 0x8) ? 0 : 1];
} }
else else
{ {
uint32_t imageIds[2][2] = { { SPR_G2_MINIATURE_RAILWAY_INSET_SW_NE, SPR_G2_MINIATURE_RAILWAY_INSET_END_SW }, static constexpr uint32_t imageIds[2][2] = {
{ SPR_G2_MINIATURE_RAILWAY_INSET_END_NE, SPR_G2_MINIATURE_RAILWAY_INSET_END_SW_NE } }; { SPR_G2_MINIATURE_RAILWAY_INSET_SW_NE, SPR_G2_MINIATURE_RAILWAY_INSET_END_SW },
{ SPR_G2_MINIATURE_RAILWAY_INSET_END_NE, SPR_G2_MINIATURE_RAILWAY_INSET_END_SW_NE },
};
imageIdAlt = imageIds[(correctedEdges & 0x1) ? 0 : 1][(correctedEdges & 0x4) ? 0 : 1]; imageIdAlt = imageIds[(correctedEdges & 0x1) ? 0 : 1][(correctedEdges & 0x4) ? 0 : 1];
} }
@ -1411,7 +1415,12 @@ static void paint_miniature_railway_track_left_eighth_to_diag(
paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height, paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
const TrackElement& trackElement) const TrackElement& trackElement)
{ {
const uint8_t supportType[4][5] = { { 0, 0, 3, 5, 1 }, { 1, 1, 4, 2, 0 }, { 0, 0, 5, 3, 1 }, { 1, 1, 2, 4, 0 } }; static constexpr uint8_t supportType[4][5] = {
{ 0, 0, 3, 5, 1 },
{ 1, 1, 4, 2, 0 },
{ 0, 0, 5, 3, 1 },
{ 1, 1, 2, 4, 0 },
};
bool isSupported = false; bool isSupported = false;
bool isRightEighthToOrthog = trackElement.GetTrackType() == TrackElemType::RightEighthToOrthogonal; bool isRightEighthToOrthog = trackElement.GetTrackType() == TrackElemType::RightEighthToOrthogonal;
@ -1547,7 +1556,12 @@ static void paint_miniature_railway_track_right_eighth_to_diag(
paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height, paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
const TrackElement& trackElement) const TrackElement& trackElement)
{ {
const uint8_t supportType[4][5] = { { 0, 0, 2, 4, 1 }, { 1, 1, 3, 5, 0 }, { 0, 0, 4, 2, 1 }, { 1, 1, 5, 3, 0 } }; static constexpr uint8_t supportType[4][5] = {
{ 0, 0, 2, 4, 1 },
{ 1, 1, 3, 5, 0 },
{ 0, 0, 4, 2, 1 },
{ 1, 1, 5, 3, 0 },
};
bool isSupported = false; bool isSupported = false;
bool isLeftEighthToOrthog = trackElement.GetTrackType() == TrackElemType::LeftEighthToOrthogonal; bool isLeftEighthToOrthog = trackElement.GetTrackType() == TrackElemType::LeftEighthToOrthogonal;
@ -1752,7 +1766,7 @@ static void miniature_railway_track_diag_25_deg_up(
supportFunction = WOOD_A; supportFunction = WOOD_A;
} }
int8_t heightDiffs[] = { +8, -8, +8, -8 }; static constexpr int8_t heightDiffs[] = { +8, -8, +8, -8 };
int8_t heightDiff = heightDiffs[direction]; int8_t heightDiff = heightDiffs[direction];
if (trackSequence == 3) if (trackSequence == 3)
{ {
@ -1868,7 +1882,7 @@ static void miniature_railway_track_diag_25_deg_up_to_flat(
paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height, paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
const TrackElement& trackElement) const TrackElement& trackElement)
{ {
const int8_t supportOffsets[][4] = { static constexpr int8_t supportOffsets[][4] = {
{ 0, +8, +8, +8 }, { 0, +8, +8, +8 },
{ 0, -8, -8, 0 }, { 0, -8, -8, 0 },
{ 0, +8, +8, +8 }, { 0, +8, +8, +8 },
@ -1903,7 +1917,7 @@ static void miniature_railway_track_diag_25_deg_up_to_flat(
floorBoundOffset = CoordsXY(-16, -16); floorBoundOffset = CoordsXY(-16, -16);
} }
const int8_t offsetsB[4][4][2] = { static constexpr int8_t offsetsB[4][4][2] = {
{ { 0, 0 }, { +8, +16 }, { +8, +8 }, { +8, +8 } }, { { 0, 0 }, { +8, +16 }, { +8, +8 }, { +8, +8 } },
{ { 0, 0 }, { -8, -8 }, { -8, -8 }, { +8, +8 } }, { { 0, 0 }, { -8, -8 }, { -8, -8 }, { +8, +8 } },
{ { 0, 0 }, { +8, +8 }, { +8, +16 }, { +8, +8 } }, { { 0, 0 }, { +8, +8 }, { +8, +16 }, { +8, +8 } },
@ -1913,7 +1927,7 @@ static void miniature_railway_track_diag_25_deg_up_to_flat(
uint32_t imageId = miniature_railway_track_pieces_diag_25_deg_up_to_flat[direction]; uint32_t imageId = miniature_railway_track_pieces_diag_25_deg_up_to_flat[direction];
bool drawRail = miniature_railway_diag_image_segment[direction][trackSequence]; bool drawRail = miniature_railway_diag_image_segment[direction][trackSequence];
const int8_t railOffsets[] = { +8, 0, +8, +8 }; static constexpr int8_t railOffsets[] = { +8, 0, +8, +8 };
if (hasSupports) if (hasSupports)
{ {
@ -1944,7 +1958,7 @@ static void miniature_railway_track_diag_25_deg_down(
paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height, paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
const TrackElement& trackElement) const TrackElement& trackElement)
{ {
const int8_t supportOffsets[][4] = { static constexpr int8_t supportOffsets[][4] = {
{ 0, +16, +16, 0 }, { 0, +16, +16, 0 },
{ 0, -8, -8, 0 }, { 0, -8, -8, 0 },
{ 0, +16, +16, 0 }, { 0, +16, +16, 0 },
@ -1981,9 +1995,9 @@ static void miniature_railway_track_diag_25_deg_down(
uint32_t imageId = miniature_railway_track_pieces_diag_25_deg_up[(direction + 2) % 4]; uint32_t imageId = miniature_railway_track_pieces_diag_25_deg_up[(direction + 2) % 4];
bool drawRail = miniature_railway_diag_image_segment[direction][trackSequence]; bool drawRail = miniature_railway_diag_image_segment[direction][trackSequence];
const int8_t railOffsets[] = { 0, +8, +8, +8 }; static constexpr int8_t railOffsets[] = { 0, +8, +8, +8 };
const int8_t offsetsB[4][4][2] = { static constexpr int8_t offsetsB[4][4][2] = {
{ { 0, 0 }, { +8, +8 }, { +8, +8 }, { -8, -8 } }, { { 0, 0 }, { +8, +8 }, { +8, +8 }, { -8, -8 } },
{ { 0, 0 }, { -8, -8 }, { -8, -8 }, { -8, 0 } }, { { 0, 0 }, { -8, -8 }, { -8, -8 }, { -8, 0 } },
{ { 0, 0 }, { +8, +8 }, { +8, +16 }, { -8, -8 } }, { { 0, 0 }, { +8, +8 }, { +8, +16 }, { -8, -8 } },
@ -2019,7 +2033,7 @@ static void miniature_railway_track_diag_flat_to_25_deg_down(
paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height, paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
const TrackElement& trackElement) const TrackElement& trackElement)
{ {
const int8_t supportOffsets[][4] = { static constexpr int8_t supportOffsets[][4] = {
{ 0, +16, +16, 0 }, { 0, +16, +16, 0 },
{ 0, -8, -8, -8 }, { 0, -8, -8, -8 },
{ 0, +8, +8, 0 }, { 0, +8, +8, 0 },
@ -2053,7 +2067,7 @@ static void miniature_railway_track_diag_flat_to_25_deg_down(
floorBoundOffset = CoordsXY(-16, -16); floorBoundOffset = CoordsXY(-16, -16);
} }
const int8_t offsetsB[4][4][2] = { static constexpr int8_t offsetsB[4][4][2] = {
{ { 0, 0 }, { +8, +8 }, { +8, +8 }, { -8, -8 } }, { { 0, 0 }, { +8, +8 }, { +8, +8 }, { -8, -8 } },
{ { 0, 0 }, { -8, -8 }, { -8, -8 }, { -8, 0 } }, { { 0, 0 }, { -8, -8 }, { -8, -8 }, { -8, 0 } },
{ { 0, 0 }, { +8, +8 }, { +8, +16 }, { -8, -8 } }, { { 0, 0 }, { +8, +8 }, { +8, +16 }, { -8, -8 } },
@ -2062,7 +2076,7 @@ static void miniature_railway_track_diag_flat_to_25_deg_down(
uint32_t imageId = miniature_railway_track_pieces_diag_25_deg_up_to_flat[(direction + 2) % 4]; uint32_t imageId = miniature_railway_track_pieces_diag_25_deg_up_to_flat[(direction + 2) % 4];
bool drawRail = miniature_railway_diag_image_segment[direction][trackSequence]; bool drawRail = miniature_railway_diag_image_segment[direction][trackSequence];
const int8_t railOffsets[] = { 0, +8, +8, +8 }; static constexpr int8_t railOffsets[] = { 0, +8, +8, +8 };
if (hasSupports) if (hasSupports)
{ {

View File

@ -746,14 +746,14 @@ static void paint_monorail_track_s_bend_left(
trackSequence = 3 - trackSequence; trackSequence = 3 - trackSequence;
} }
const CoordsXY offsetList[] = { static constexpr CoordsXY offsetList[] = {
{ 0, 6 }, { 0, 6 },
{ 0, 0 }, { 0, 0 },
{ 0, 6 }, { 0, 6 },
{ 0, 6 }, { 0, 6 },
}; };
const CoordsXY boundsList[] = { static constexpr CoordsXY boundsList[] = {
{ 32, 20 }, { 32, 20 },
{ 32, 26 }, { 32, 26 },
{ 32, 26 }, { 32, 26 },
@ -850,14 +850,14 @@ static void paint_monorail_track_s_bend_right(
trackSequence = 3 - trackSequence; trackSequence = 3 - trackSequence;
} }
const CoordsXY offsetList[] = { static constexpr CoordsXY offsetList[] = {
{ 0, 6 }, { 0, 6 },
{ 0, 6 }, { 0, 6 },
{ 0, 0 }, { 0, 0 },
{ 0, 6 }, { 0, 6 },
}; };
const CoordsXY boundsList[] = { static constexpr CoordsXY boundsList[] = {
{ 32, 20 }, { 32, 20 },
{ 32, 26 }, { 32, 26 },
{ 32, 26 }, { 32, 26 },
@ -1133,7 +1133,7 @@ static void paint_monorail_track_left_eighth_to_orthogonal(
paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height, paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
const TrackElement& trackElement) const TrackElement& trackElement)
{ {
const uint8_t map[] = { 4, 2, 3, 1, 0 }; static constexpr uint8_t map[] = { 4, 2, 3, 1, 0 };
trackSequence = map[trackSequence]; trackSequence = map[trackSequence];
paint_monorail_track_right_eighth_to_diag(session, ride, trackSequence, (direction + 2) % 4, height, trackElement); paint_monorail_track_right_eighth_to_diag(session, ride, trackSequence, (direction + 2) % 4, height, trackElement);
} }
@ -1143,7 +1143,7 @@ static void paint_monorail_track_right_eighth_to_orthogonal(
paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height, paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
const TrackElement& trackElement) const TrackElement& trackElement)
{ {
const uint8_t map[] = { 4, 2, 3, 1, 0 }; static constexpr uint8_t map[] = { 4, 2, 3, 1, 0 };
trackSequence = map[trackSequence]; trackSequence = map[trackSequence];
paint_monorail_track_left_eighth_to_diag(session, ride, trackSequence, (direction + 3) % 4, height, trackElement); paint_monorail_track_left_eighth_to_diag(session, ride, trackSequence, (direction + 3) % 4, height, trackElement);
} }