From 4d62a7396c36368c88f7b77e16bf5dd1a1233f39 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 14:38:34 +0200 Subject: [PATCH 01/39] Add CoordsXYZ overload for PaintAddImageAsParent --- src/openrct2/paint/Paint.cpp | 29 +++++++++++++++-------------- src/openrct2/paint/Paint.h | 3 +++ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index b5d7ded9a6..4c76e4583d 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -1,4 +1,4 @@ -/***************************************************************************** +/***************************************************************************** * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md @@ -694,9 +694,7 @@ void PaintSessionFree([[maybe_unused]] paint_session* session) paint_struct* PaintAddImageAsParent( paint_session* session, uint32_t image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize) { - return PaintAddImageAsParent( - session, image_id, offset.x, offset.y, boundBoxSize.x, boundBoxSize.y, boundBoxSize.z, offset.z, offset.x, offset.y, - offset.z); + return PaintAddImageAsParent(session, image_id, offset, boundBoxSize, offset); } paint_struct* PaintAddImageAsParent( @@ -724,17 +722,12 @@ paint_struct* PaintAddImageAsParent( */ // Track Pieces, Shops. paint_struct* PaintAddImageAsParent( - paint_session* session, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, - int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset, int16_t bound_box_offset_x, - int16_t bound_box_offset_y, int16_t bound_box_offset_z) + paint_session* session, uint32_t image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize, + const CoordsXYZ& boundBoxOffset) { session->LastPS = nullptr; session->LastAttachedPS = nullptr; - CoordsXYZ offset = { x_offset, y_offset, z_offset }; - CoordsXYZ boundBoxSize = { bound_box_length_x, bound_box_length_y, bound_box_length_z }; - CoordsXYZ boundBoxOffset = { bound_box_offset_x, bound_box_offset_y, bound_box_offset_z }; - auto* ps = CreateNormalPaintStruct(session, image_id, offset, boundBoxSize, boundBoxOffset); if (ps == nullptr) { @@ -746,6 +739,16 @@ paint_struct* PaintAddImageAsParent( return ps; } +paint_struct* PaintAddImageAsParent( + paint_session* session, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, + int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset, int16_t bound_box_offset_x, + int16_t bound_box_offset_y, int16_t bound_box_offset_z) +{ + return PaintAddImageAsParent( + session, image_id, { x_offset, y_offset, z_offset }, { bound_box_length_x, bound_box_length_y, bound_box_length_z }, + { bound_box_offset_x, bound_box_offset_y, bound_box_offset_z }); +} + /** * * rct2: 0x00686EF0, 0x00687056, 0x006871C8, 0x0068733C, 0x0098198C @@ -811,9 +814,7 @@ paint_struct* PaintAddImageAsChild( paint_struct* parentPS = session->LastPS; if (parentPS == nullptr) { - return PaintAddImageAsParent( - session, image_id, offset.x, offset.y, boundBoxLength.x, boundBoxLength.y, boundBoxLength.z, offset.z, - boundBoxOffset.x, boundBoxOffset.y, boundBoxOffset.z); + return PaintAddImageAsParent(session, image_id, offset, boundBoxLength, boundBoxOffset); } auto* ps = CreateNormalPaintStruct(session, image_id, offset, boundBoxLength, boundBoxOffset); diff --git a/src/openrct2/paint/Paint.h b/src/openrct2/paint/Paint.h index a82832dea2..a327ef5ca3 100644 --- a/src/openrct2/paint/Paint.h +++ b/src/openrct2/paint/Paint.h @@ -298,6 +298,9 @@ paint_struct* PaintAddImageAsParent( paint_session* session, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset, int16_t bound_box_offset_x, int16_t bound_box_offset_y, int16_t bound_box_offset_z); +paint_struct* PaintAddImageAsParent( + paint_session* session, uint32_t image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize, + const CoordsXYZ& boundBoxOffset); [[nodiscard]] paint_struct* PaintAddImageAsOrphan( paint_session* session, uint32_t image_id, int8_t x_offset, int8_t y_offset, int16_t bound_box_length_x, int16_t bound_box_length_y, int8_t bound_box_length_z, int16_t z_offset, int16_t bound_box_offset_x, From 5818a0a4f3a0b98d72f6d41b0e97ec6c29b12a02 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 14:52:48 +0200 Subject: [PATCH 02/39] Refactor uses of PaintAddImageAsParent in VirtualFloor.cpp --- src/openrct2/paint/VirtualFloor.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/openrct2/paint/VirtualFloor.cpp b/src/openrct2/paint/VirtualFloor.cpp index 0a97801a7c..7731ec8b0c 100644 --- a/src/openrct2/paint/VirtualFloor.cpp +++ b/src/openrct2/paint/VirtualFloor.cpp @@ -366,13 +366,14 @@ void virtual_floor_paint(paint_session* session) uint8_t dullEdges = 0xF & ~occupiedEdges & ~litEdges; uint8_t paintEdges = ((weAreOccupied || weAreLit) && weAreOwned) ? ~dullEdges : 0xF; + const auto virtualFloorOffset = CoordsXYZ{ 0, 0, _virtualFloorHeight }; if (paintEdges & EDGE_NE) { PaintAddImageAsParent( session, SPR_G2_SELECTION_EDGE_NE | (!(occupiedEdges & EDGE_NE) ? ((litEdges & EDGE_NE) ? remap_lit : remap_base) : remap_edge), - 0, 0, 0, 0, 1, _virtualFloorHeight, 5, 5, _virtualFloorHeight + ((dullEdges & EDGE_NE) ? -2 : 0)); + virtualFloorOffset, { 0, 0, 1 }, { 5, 5, _virtualFloorHeight + ((dullEdges & EDGE_NE) ? -2 : 0) }); } if (paintEdges & EDGE_SE) { @@ -380,7 +381,7 @@ void virtual_floor_paint(paint_session* session) session, SPR_G2_SELECTION_EDGE_SE | (!(occupiedEdges & EDGE_SE) ? ((litEdges & EDGE_SE) ? remap_lit : remap_base) : remap_edge), - 0, 0, 1, 1, 1, _virtualFloorHeight, 16, 27, _virtualFloorHeight + ((dullEdges & EDGE_SE) ? -2 : 0)); + virtualFloorOffset, { 1, 1, 1 }, { 16, 27, _virtualFloorHeight + ((dullEdges & EDGE_SE) ? -2 : 0) }); } if (paintEdges & EDGE_SW) { @@ -388,7 +389,7 @@ void virtual_floor_paint(paint_session* session) session, SPR_G2_SELECTION_EDGE_SW | (!(occupiedEdges & EDGE_SW) ? ((litEdges & EDGE_SW) ? remap_lit : remap_base) : remap_edge), - 0, 0, 1, 1, 1, _virtualFloorHeight, 27, 16, _virtualFloorHeight + ((dullEdges & EDGE_SW) ? -2 : 0)); + virtualFloorOffset, { 1, 1, 1 }, { 27, 16, _virtualFloorHeight + ((dullEdges & EDGE_SW) ? -2 : 0) }); } if (paintEdges & EDGE_NW) { @@ -396,7 +397,7 @@ void virtual_floor_paint(paint_session* session) session, SPR_G2_SELECTION_EDGE_NW | (!(occupiedEdges & EDGE_NW) ? ((litEdges & EDGE_NW) ? remap_lit : remap_base) : remap_edge), - 0, 0, 0, 0, 1, _virtualFloorHeight, 5, 5, _virtualFloorHeight + ((dullEdges & EDGE_NW) ? -2 : 0)); + virtualFloorOffset, { 0, 0, 1 }, { 5, 5, _virtualFloorHeight + ((dullEdges & EDGE_NW) ? -2 : 0) }); } if (gConfigGeneral.virtual_floor_style != VirtualFloorStyles::Glassy) @@ -406,7 +407,7 @@ void virtual_floor_paint(paint_session* session) { int32_t imageColourFlats = SPR_G2_SURFACE_GLASSY_RECOLOURABLE | IMAGE_TYPE_REMAP | IMAGE_TYPE_TRANSPARENT | EnumValue(FilterPaletteID::PaletteWater) << 19; - PaintAddImageAsParent(session, imageColourFlats, 0, 0, 30, 30, 0, _virtualFloorHeight, 2, 2, _virtualFloorHeight - 3); + PaintAddImageAsParent(session, imageColourFlats, virtualFloorOffset, { 30, 30, 0 }, { 2, 2, _virtualFloorHeight - 3 }); } } From fcf8903304f33b6d5693fed73fa5a892b185c42e Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 15:03:28 +0200 Subject: [PATCH 03/39] Refactor uses of PaintAddImageAsParent in Paint.TileElement.cpp --- src/openrct2/paint/tile_element/Paint.TileElement.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.cpp b/src/openrct2/paint/tile_element/Paint.TileElement.cpp index 6175fec4ea..e658754663 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.cpp +++ b/src/openrct2/paint/tile_element/Paint.TileElement.cpp @@ -124,7 +124,7 @@ static void blank_tiles_paint(paint_session* session, int32_t x, int32_t y) session->SpritePosition.x = x; session->SpritePosition.y = y; session->InteractionType = ViewportInteractionItem::None; - PaintAddImageAsParent(session, SPR_BLANK_TILE, 0, 0, 32, 32, -1, 16); + PaintAddImageAsParent(session, SPR_BLANK_TILE, { 0, 0, 16 }, { 32, 32, -1 }); } bool gShowSupportSegmentHeights = false; @@ -200,7 +200,7 @@ static void sub_68B3FB(paint_session* session, int32_t x, int32_t y) session->SpritePosition.y = y; session->InteractionType = ViewportInteractionItem::None; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 32, -1, arrowZ, 0, 0, arrowZ + 18); + PaintAddImageAsParent(session, imageId, { 0, 0, arrowZ }, { 32, 32, -1 }, { 0, 0, arrowZ + 18 }); } int32_t bx = dx + 52; @@ -371,8 +371,8 @@ static void sub_68B3FB(paint_session* session, int32_t x, int32_t y) int32_t xOffset = sy * 10; int32_t yOffset = -22 + sx * 10; paint_struct* ps = PaintAddImageAsParent( - session, 5504 | imageColourFlats, xOffset, yOffset, 10, 10, 1, segmentHeight, xOffset + 1, yOffset + 16, - segmentHeight); + session, 5504 | imageColourFlats, { xOffset, yOffset, segmentHeight }, { 10, 10, 1 }, + { xOffset + 1, yOffset + 16, segmentHeight }); if (ps != nullptr) { ps->flags &= PAINT_STRUCT_FLAG_IS_MASKED; From 83a196ca136d7d1c50426573bc08d9712dd7262d Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 15:03:43 +0200 Subject: [PATCH 04/39] Refactor uses of PaintAddImageAsParent in BoatHire.cpp --- src/openrct2/ride/water/BoatHire.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/openrct2/ride/water/BoatHire.cpp b/src/openrct2/ride/water/BoatHire.cpp index 9fdf1345d7..c8c9e3e141 100644 --- a/src/openrct2/ride/water/BoatHire.cpp +++ b/src/openrct2/ride/water/BoatHire.cpp @@ -36,21 +36,22 @@ static void paint_boat_hire_track_flat( { uint32_t imageId; + const auto offset = CoordsXYZ{ 0, 0, height }; if (direction & 1) { imageId = SPR_BOAT_HIRE_FLAT_BACK_NW_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 3, height, 4, 0, height); + PaintAddImageAsParent(session, imageId, offset, { 1, 32, 3 }, { 4, 0, height }); imageId = SPR_BOAT_HIRE_FLAT_FRONT_NW_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 3, height, 28, 0, height); + PaintAddImageAsParent(session, imageId, offset, { 1, 32, 3 }, { 28, 0, height }); } else { imageId = SPR_BOAT_HIRE_FLAT_BACK_SW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 3, height, 0, 4, height); + PaintAddImageAsParent(session, imageId, offset, { 32, 1, 3 }, { 0, 4, height }); imageId = SPR_BOAT_HIRE_FLAT_FRONT_SW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 3, height, 0, 28, height); + PaintAddImageAsParent(session, imageId, offset, { 32, 1, 3 }, { 0, 28, height }); } paint_util_set_segment_support_height( @@ -92,35 +93,36 @@ static void paint_boat_hire_track_left_quarter_turn_1_tile( const TileElement* tileElement) { uint32_t imageId; + const auto offset = CoordsXYZ{ 0, 0, height }; switch (direction) { case 0: imageId = SPR_BOAT_HIRE_FLAT_QUARTER_TURN_1_TILE_BACK_SW_NW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 32, 0, height, 0, 0, height); + PaintAddImageAsParent(session, imageId, offset, { 32, 32, 0 }, { 0, 0, height }); imageId = SPR_BOAT_HIRE_FLAT_QUARTER_TURN_1_TILE_FRONT_SW_NW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 3, 3, 3, height, 28, 28, height + 2); + PaintAddImageAsParent(session, imageId, offset, { 3, 3, 3 }, { 28, 28, height + 2 }); break; case 1: imageId = SPR_BOAT_HIRE_FLAT_QUARTER_TURN_1_TILE_BACK_NW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 32, 0, height, 0, 0, height); + PaintAddImageAsParent(session, imageId, offset, { 32, 32, 0 }, { 0, 0, height }); imageId = SPR_BOAT_HIRE_FLAT_QUARTER_TURN_1_TILE_FRONT_NW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 3, 3, 3, height, 28, 28, height + 2); + PaintAddImageAsParent(session, imageId, offset, { 3, 3, 3 }, { 28, 28, height + 2 }); break; case 2: imageId = SPR_BOAT_HIRE_FLAT_QUARTER_TURN_1_TILE_BACK_NE_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 32, 0, height, 0, 0, height); + PaintAddImageAsParent(session, imageId, offset, { 32, 32, 0 }, { 0, 0, height }); imageId = SPR_BOAT_HIRE_FLAT_QUARTER_TURN_1_TILE_FRONT_NE_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 3, 3, 3, height, 28, 28, height + 2); + PaintAddImageAsParent(session, imageId, offset, { 3, 3, 3 }, { 28, 28, height + 2 }); break; case 3: imageId = SPR_BOAT_HIRE_FLAT_QUARTER_TURN_1_TILE_FRONT_SE_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 3, 3, 3, height, 28, 28, height + 2); + PaintAddImageAsParent(session, imageId, offset, { 3, 3, 3 }, { 28, 28, height + 2 }); imageId = SPR_BOAT_HIRE_FLAT_QUARTER_TURN_1_TILE_BACK_SE_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 32, 0, height, 0, 0, height); + PaintAddImageAsParent(session, imageId, offset, { 32, 32, 0 }, { 0, 0, height }); break; } From bcef621ac88b7ef6a0915f5fe9e6ec1cad2f3178 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 15:07:54 +0200 Subject: [PATCH 05/39] Refactor uses of PaintAddImageAsParent in Paint.Misc.cpp --- src/openrct2/paint/sprite/Paint.Misc.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/openrct2/paint/sprite/Paint.Misc.cpp b/src/openrct2/paint/sprite/Paint.Misc.cpp index b4d33e60c7..61352ae456 100644 --- a/src/openrct2/paint/sprite/Paint.Misc.cpp +++ b/src/openrct2/paint/sprite/Paint.Misc.cpp @@ -32,7 +32,7 @@ const uint32_t vehicle_particle_base_sprites[] = { template<> void PaintEntity(paint_session* session, const SteamParticle* particle, int32_t imageDirection) { uint32_t imageId = 22637 + (particle->frame / 256); - PaintAddImageAsParent(session, imageId, 0, 0, 1, 1, 0, particle->z); + PaintAddImageAsParent(session, imageId, { 0, 0, particle->z }, { 1, 1, 0 }); } template<> void PaintEntity(paint_session* session, const MoneyEffect* moneyEffect, int32_t imageDirection) @@ -63,7 +63,7 @@ template<> void PaintEntity(paint_session* session, const VehicleCrashParticle* return; uint32_t imageId = vehicle_particle_base_sprites[particle->crashed_sprite_base] + particle->frame / 256; imageId = imageId | (particle->colour[0] << 19) | (particle->colour[1] << 24) | IMAGE_TYPE_REMAP | IMAGE_TYPE_REMAP_2_PLUS; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 1, 0, particle->z); + PaintAddImageAsParent(session, imageId, { 0, 0, particle->z }, { 1, 1, 0 }); } template<> void PaintEntity(paint_session* session, const ExplosionCloud* particle, int32_t imageDirection) @@ -71,7 +71,7 @@ template<> void PaintEntity(paint_session* session, const ExplosionCloud* partic if (particle == nullptr) return; uint32_t imageId = 22878 + (particle->frame / 256); - PaintAddImageAsParent(session, imageId, 0, 0, 1, 1, 0, particle->z); + PaintAddImageAsParent(session, imageId, { 0, 0, particle->z }, { 1, 1, 0 }); } template<> void PaintEntity(paint_session* session, const CrashSplashParticle* crashSplash, int32_t imageDirection) @@ -79,7 +79,7 @@ template<> void PaintEntity(paint_session* session, const CrashSplashParticle* c if (crashSplash == nullptr) return; uint32_t imageId = 22927 + (crashSplash->frame / 256); - PaintAddImageAsParent(session, imageId, 0, 0, 1, 1, 0, crashSplash->z); + PaintAddImageAsParent(session, imageId, { 0, 0, crashSplash->z }, { 1, 1, 0 }); } template<> void PaintEntity(paint_session* session, const ExplosionFlare* flare, int32_t imageDirection) @@ -88,7 +88,7 @@ template<> void PaintEntity(paint_session* session, const ExplosionFlare* flare, if (flare == nullptr) return; uint32_t imageId = 22896 + (flare->frame / 256); - PaintAddImageAsParent(session, imageId, 0, 0, 1, 1, 0, flare->z); + PaintAddImageAsParent(session, imageId, { 0, 0, flare->z }, { 1, 1, 0 }); } constexpr uint32_t JumpingFountainSnowBaseImage = 23037; @@ -141,7 +141,7 @@ template<> void PaintEntity(paint_session* session, const Balloon* balloon, int3 } imageId = imageId | (balloon->colour << 19) | IMAGE_TYPE_REMAP; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 1, 0, balloon->z); + PaintAddImageAsParent(session, imageId, { 0, 0, balloon->z }, { 1, 1, 0 }); } template<> void PaintEntity(paint_session* session, const Duck* duck, int32_t imageDirection) @@ -154,7 +154,7 @@ template<> void PaintEntity(paint_session* session, const Duck* duck, int32_t im uint32_t imageId = duck->GetFrameImage(imageDirection); if (imageId != 0) { - PaintAddImageAsParent(session, imageId, 0, 0, 1, 1, 0, duck->z); + PaintAddImageAsParent(session, imageId, { 0, 0, duck->z }, { 1, 1, 0 }); } } } From ef527d3c4bf860adf2693b531b60225f34740cd9 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 15:19:19 +0200 Subject: [PATCH 06/39] Refactor uses of PaintAddImageAsParent in CarRide.cpp --- src/openrct2/ride/gentle/CarRide.cpp | 64 ++++++++++++++-------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/openrct2/ride/gentle/CarRide.cpp b/src/openrct2/ride/gentle/CarRide.cpp index cc5799d0a7..1113493bf4 100644 --- a/src/openrct2/ride/gentle/CarRide.cpp +++ b/src/openrct2/ride/gentle/CarRide.cpp @@ -152,11 +152,11 @@ static void paint_car_ride_track_flat( if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 6, 32, 20, 1, height); + PaintAddImageAsParent(session, imageId, { 0, 6, height }, { 32, 20, 1 }); } else { - PaintAddImageAsParent(session, imageId, 6, 0, 20, 32, 1, height); + PaintAddImageAsParent(session, imageId, { 6, 0, height }, { 20, 32, 1 }); } if (direction == 0 || direction == 2) @@ -183,11 +183,11 @@ static void paint_car_ride_track_25_deg_up( if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 2, 32, 20, 1, height, 0, 6, height); + PaintAddImageAsParent(session, imageId, { 0, 2, height }, { 32, 20, 1 }, { 0, 6, height }); } else { - PaintAddImageAsParent(session, imageId, 2, 0, 20, 32, 1, height, 6, 0, height); + PaintAddImageAsParent(session, imageId, { 2, 0, height }, { 20, 32, 1 }, { 6, 0, height }); } switch (direction) @@ -221,11 +221,11 @@ static void paint_car_ride_track_flat_to_25_deg_up( if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 2, 32, 20, 1, height, 0, 6, height); + PaintAddImageAsParent(session, imageId, { 0, 2, height }, { 32, 20, 1 }, { 0, 6, height }); } else { - PaintAddImageAsParent(session, imageId, 2, 0, 20, 32, 1, height, 6, 0, height); + PaintAddImageAsParent(session, imageId, { 2, 0, height }, { 20, 32, 1 }, { 6, 0, height }); } switch (direction) @@ -259,11 +259,11 @@ static void paint_car_ride_track_25_deg_up_to_flat( if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 2, 32, 20, 1, height, 0, 6, height); + PaintAddImageAsParent(session, imageId, { 0, 2, height }, { 32, 20, 1 }, { 0, 6, height }); } else { - PaintAddImageAsParent(session, imageId, 2, 0, 20, 32, 1, height, 6, 0, height); + PaintAddImageAsParent(session, imageId, { 2, 0, height }, { 20, 32, 1 }, { 6, 0, height }); } switch (direction) @@ -322,22 +322,22 @@ static void paint_car_ride_station( if (direction == 0 || direction == 2) { imageId = SPR_STATION_BASE_B_SW_NE | session->TrackColours[SCHEME_MISC]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 28, 1, height - 2, 0, 2, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height - 2 }, { 32, 28, 1 }, { 0, 2, height }); } else if (direction == 1 || direction == 3) { imageId = SPR_STATION_BASE_B_NW_SE | session->TrackColours[SCHEME_MISC]; - PaintAddImageAsParent(session, imageId, 0, 0, 28, 32, 1, height - 2, 2, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height - 2 }, { 28, 32, 1 }, { 2, 0, height }); } imageId = car_ride_track_pieces_flat[direction] | session->TrackColours[SCHEME_TRACK]; if (direction == 0 || direction == 2) { - PaintAddImageAsChild(session, imageId, 0, 6, 32, 20, 1, height, 0, 0, height); + PaintAddImageAsChild(session, imageId, { 0, 6, height }, { 32, 20, 1 }, { 0, 0, height }); } else { - PaintAddImageAsChild(session, imageId, 6, 0, 20, 32, 1, height, 0, 0, height); + PaintAddImageAsChild(session, imageId, { 6, 0, height }, { 20, 32, 1 }, { 0, 0, height }); } if (direction == 0 || direction == 2) @@ -423,16 +423,16 @@ static void paint_car_ride_track_left_quarter_turn_1_tile( switch (direction) { case 0: - PaintAddImageAsParent(session, imageId, 6, 0, 26, 24, 1, height, 6, 2, height); + PaintAddImageAsParent(session, imageId, { 6, 0, height }, { 26, 24, 1 }, { 6, 2, height }); break; case 1: - PaintAddImageAsParent(session, imageId, 0, 0, 26, 26, 1, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 26, 26, 1 }); break; case 2: - PaintAddImageAsParent(session, imageId, 0, 6, 24, 26, 1, height, 2, 6, height); + PaintAddImageAsParent(session, imageId, { 0, 6, height }, { 24, 26, 1 }, { 2, 6, height }); break; case 3: - PaintAddImageAsParent(session, imageId, 6, 6, 24, 24, 1, height); + PaintAddImageAsParent(session, imageId, { 6, 6, height }, { 24, 24, 1 }); break; } @@ -461,11 +461,11 @@ static void paint_car_ride_track_spinning_tunnel( if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 6, 32, 20, 1, height); + PaintAddImageAsParent(session, imageId, { 0, 6, height }, { 32, 20, 1 }); } else { - PaintAddImageAsParent(session, imageId, 6, 0, 20, 32, 1, height); + PaintAddImageAsParent(session, imageId, { 6, 0, height }, { 20, 32, 1 }); } track_paint_util_spinning_tunnel_paint(session, 1, height, direction); @@ -495,16 +495,16 @@ static void paint_car_ride_track_60_deg_up( switch (direction) { case 0: - PaintAddImageAsParent(session, imageId, 0, 0, 32, 20, 1, height, 0, 6, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 20, 1 }, { 0, 6, height }); break; case 1: - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 98, height, 27, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 98 }, { 27, 0, height }); break; case 2: - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 98, height, 0, 27, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 98 }, { 0, 27, height }); break; case 3: - PaintAddImageAsParent(session, imageId, 0, 0, 20, 32, 1, height, 6, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 20, 32, 1 }, { 6, 0, height }); break; } @@ -543,11 +543,11 @@ static void paint_car_ride_track_25_deg_up_to_60_deg_up( if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 0, 32, 20, 1, height, 0, 6, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 20, 1 }, { 0, 6, height }); } else { - PaintAddImageAsParent(session, imageId, 0, 0, 20, 32, 1, height, 6, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 20, 32, 1 }, { 6, 0, height }); } if (car_ride_track_pieces_25_deg_up_to_60_deg_up[direction][1] != 0) @@ -556,11 +556,11 @@ static void paint_car_ride_track_25_deg_up_to_60_deg_up( if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 66, height, 0, 27, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 66 }, { 0, 27, height }); } else { - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 66, height, 27, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 66 }, { 27, 0, height }); } } @@ -599,11 +599,11 @@ static void paint_car_ride_track_60_deg_up_to_25_deg_up( if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 0, 32, 20, 1, height, 0, 6, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 20, 1 }, { 0, 6, height }); } else { - PaintAddImageAsParent(session, imageId, 0, 0, 20, 32, 1, height, 6, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 20, 32, 1 }, { 6, 0, height }); } if (car_ride_track_pieces_60_deg_up_to_25_deg_up[direction][1] != 0) @@ -612,11 +612,11 @@ static void paint_car_ride_track_60_deg_up_to_25_deg_up( if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 66, height, 0, 27, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 66 }, { 0, 27, height }); } else { - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 66, height, 27, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 66 }, { 27, 0, height }); } } @@ -679,11 +679,11 @@ static void paint_car_ride_track_log_bumps( if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 6, 32, 20, 1, height); + PaintAddImageAsParent(session, imageId, { 0, 6, height }, { 32, 20, 1 }); } else { - PaintAddImageAsParent(session, imageId, 6, 0, 20, 32, 1, height); + PaintAddImageAsParent(session, imageId, { 6, 0, height }, { 20, 32, 1 }); } if (direction == 0 || direction == 2) From 5781f8e8100d96fb96198f4c90bdeb881a2b7297 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 15:20:20 +0200 Subject: [PATCH 07/39] Refactor uses of PaintAddImageAsParent in FlyingSaucers.cpp --- src/openrct2/ride/gentle/FlyingSaucers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/ride/gentle/FlyingSaucers.cpp b/src/openrct2/ride/gentle/FlyingSaucers.cpp index e47ecb9c84..44aaa9b951 100644 --- a/src/openrct2/ride/gentle/FlyingSaucers.cpp +++ b/src/openrct2/ride/gentle/FlyingSaucers.cpp @@ -43,7 +43,7 @@ static void paint_flying_saucers( wooden_a_supports_paint_setup(session, direction & 1, 0, height, session->TrackColours[SCHEME_MISC], nullptr); uint32_t imageId = SPR_FLYING_SAUCERS_FLOOR | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 30, 30, 1, height, 1, 1, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 30, 30, 1 }, { 1, 1, height }); auto ride = get_ride(rideIndex); if (ride != nullptr) From 8509ecd2b877cdccbf4a4630c9ce4ad270238c60 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 15:28:59 +0200 Subject: [PATCH 08/39] Refactor uses of PaintAddImageAsParent in Paint.Surface.cpp --- .../paint/tile_element/Paint.Surface.cpp | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/openrct2/paint/tile_element/Paint.Surface.cpp b/src/openrct2/paint/tile_element/Paint.Surface.cpp index ed831ebc76..ab7e0d2574 100644 --- a/src/openrct2/paint/tile_element/Paint.Surface.cpp +++ b/src/openrct2/paint/tile_element/Paint.Surface.cpp @@ -658,7 +658,7 @@ static void viewport_surface_draw_tile_side_bottom( { uint32_t image_id = base_image_id + image_offset; PaintAddImageAsParent( - session, image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * COORDS_Z_PER_TINY_Z); + session, image_id, { offset.x, offset.y, curHeight * COORDS_Z_PER_TINY_Z }, { bounds.x, bounds.y, 15 }); curHeight++; } } @@ -683,7 +683,7 @@ static void viewport_surface_draw_tile_side_bottom( const uint32_t image_id = base_image_id + image_offset; PaintAddImageAsParent( - session, image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * COORDS_Z_PER_TINY_Z); + session, image_id, { offset.x, offset.y, curHeight * COORDS_Z_PER_TINY_Z }, { bounds.x, bounds.y, 15 }); return; } @@ -699,7 +699,8 @@ static void viewport_surface_draw_tile_side_bottom( if (isWater || curHeight != tunnelArray[tunnelIndex].height) { PaintAddImageAsParent( - session, base_image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * COORDS_Z_PER_TINY_Z); + session, base_image_id, { offset.x, offset.y, curHeight * COORDS_Z_PER_TINY_Z }, + { bounds.x, bounds.y, 15 }); curHeight++; continue; @@ -877,7 +878,7 @@ static void viewport_surface_draw_tile_side_top( { const uint32_t image_id = base_image_id + image_offset; PaintAddImageAsParent( - session, image_id, offset.x, offset.y, bounds.x, bounds.y, 15, cur_height * COORDS_Z_PER_TINY_Z); + session, image_id, { offset.x, offset.y, cur_height * COORDS_Z_PER_TINY_Z }, { bounds.x, bounds.y, 15 }); cur_height++; } } @@ -893,7 +894,7 @@ static void viewport_surface_draw_tile_side_top( while (cur_height < cornerHeight1 && cur_height < neighbourCornerHeight1) { PaintAddImageAsParent( - session, base_image_id, offset.x, offset.y, bounds.x, bounds.y, 15, cur_height * COORDS_Z_PER_TINY_Z); + session, base_image_id, { offset.x, offset.y, cur_height * COORDS_Z_PER_TINY_Z }, { bounds.x, bounds.y, 15 }); cur_height++; } @@ -909,7 +910,8 @@ static void viewport_surface_draw_tile_side_top( } const uint32_t image_id = base_image_id + image_offset; - PaintAddImageAsParent(session, image_id, offset.x, offset.y, bounds.x, bounds.y, 15, cur_height * COORDS_Z_PER_TINY_Z); + PaintAddImageAsParent( + session, image_id, { offset.x, offset.y, cur_height * COORDS_Z_PER_TINY_Z }, { bounds.x, bounds.y, 15 }); } /** @@ -1049,10 +1051,10 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c if (session->VerticalTunnelHeight * COORDS_Z_PER_TINY_Z == height) { // Vertical tunnels - PaintAddImageAsParent(session, 1575, 0, 0, 1, 30, 39, height, -2, 1, height - 40); - PaintAddImageAsParent(session, 1576, 0, 0, 30, 1, 0, height, 1, 31, height); - PaintAddImageAsParent(session, 1577, 0, 0, 1, 30, 0, height, 31, 1, height); - PaintAddImageAsParent(session, 1578, 0, 0, 30, 1, 39, height, 1, -2, height - 40); + PaintAddImageAsParent(session, 1575, { 0, 0, height }, { 1, 30, 39 }, { -2, 1, height - 40 }); + PaintAddImageAsParent(session, 1576, { 0, 0, height }, { 30, 1, 0 }, { 1, 31, height }); + PaintAddImageAsParent(session, 1577, { 0, 0, height }, { 1, 30, 0 }, { 31, 1, height }); + PaintAddImageAsParent(session, 1578, { 0, 0, height }, { 30, 1, 39 }, { 1, -2, height - 40 }); } else { @@ -1081,7 +1083,7 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c imageId |= 0x41880000; } - PaintAddImageAsParent(session, imageId, 0, 0, 32, 32, -1, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 32, -1 }); has_surface = true; } @@ -1124,7 +1126,7 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c image_id |= patrolColour << 19; paint_struct* backup = session->LastPS; - PaintAddImageAsParent(session, image_id, 0, 0, 32, 32, 1, local_height); + PaintAddImageAsParent(session, image_id, { 0, 0, local_height }, { 32, 32, 1 }); session->LastPS = backup; } } @@ -1142,7 +1144,7 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c const int32_t offset = (direction_reverse(spawn.direction) + rotation) & 3; const uint32_t image_id = (PEEP_SPAWN_ARROW_0 + offset) | 0x20380000; - PaintAddImageAsParent(session, image_id, 0, 0, 32, 32, 19, spawn.z); + PaintAddImageAsParent(session, image_id, { 0, 0, spawn.z }, { 32, 32, 19 }); } } } @@ -1160,7 +1162,7 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c const CoordsXY& pos = session->MapPosition; const int32_t height2 = (tile_element_height({ pos.x + 16, pos.y + 16 })) + 3; paint_struct* backup = session->LastPS; - PaintAddImageAsParent(session, SPR_LAND_OWNERSHIP_AVAILABLE, 16, 16, 1, 1, 0, height2); + PaintAddImageAsParent(session, SPR_LAND_OWNERSHIP_AVAILABLE, { 16, 16, height2 }, { 1, 1, 0 }); session->LastPS = backup; } } @@ -1177,7 +1179,7 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c const CoordsXY& pos = session->MapPosition; const int32_t height2 = tile_element_height({ pos.x + 16, pos.y + 16 }); paint_struct* backup = session->LastPS; - PaintAddImageAsParent(session, SPR_LAND_CONSTRUCTION_RIGHTS_AVAILABLE, 16, 16, 1, 1, 0, height2 + 3); + PaintAddImageAsParent(session, SPR_LAND_CONSTRUCTION_RIGHTS_AVAILABLE, { 16, 16, height2 + 3 }, { 1, 1, 0 }); session->LastPS = backup; } } @@ -1232,7 +1234,7 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c const int32_t image_id = (SPR_TERRAIN_SELECTION_CORNER + byte_97B444[local_surfaceShape]) | 0x21300000; paint_struct* backup = session->LastPS; - PaintAddImageAsParent(session, image_id, 0, 0, 32, 32, 1, local_height); + PaintAddImageAsParent(session, image_id, { 0, 0, local_height }, { 32, 32, 1 }); session->LastPS = backup; } } @@ -1314,7 +1316,7 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c const int32_t image_id = (SPR_WATER_MASK + image_offset) | IMAGE_TYPE_REMAP | IMAGE_TYPE_TRANSPARENT | EnumValue(FilterPaletteID::PaletteWater) << 19; - PaintAddImageAsParent(session, image_id, 0, 0, 32, 32, -1, waterHeight); + PaintAddImageAsParent(session, image_id, { 0, 0, waterHeight }, { 32, 32, -1 }); const bool transparent = gConfigGeneral.transparent_water || (session->ViewFlags & VIEWPORT_FLAG_UNDERGROUND_INSIDE); const uint32_t overlayStart = transparent ? SPR_WATER_OVERLAY : SPR_RCT1_WATER_OVERLAY; @@ -1393,8 +1395,9 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c } PaintAddImageAsParent( - session, image_id, fenceData.offset.x, fenceData.offset.y, fenceData.box_size.x, fenceData.box_size.y, 9, - local_height, fenceData.box_offset.x, fenceData.box_offset.y, local_height + 1); + session, image_id, { fenceData.offset.x, fenceData.offset.y, local_height }, + { fenceData.box_size.x, fenceData.box_size.y, 9 }, + { fenceData.box_offset.x, fenceData.box_offset.y, local_height + 1 }); } } From 3af40e0ec551ceb04f41f3f27e181e9609b811d9 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 15:31:38 +0200 Subject: [PATCH 09/39] Refactor uses of PaintAddImageAsParent in Paint.Peep.cpp --- src/openrct2/paint/sprite/Paint.Peep.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openrct2/paint/sprite/Paint.Peep.cpp b/src/openrct2/paint/sprite/Paint.Peep.cpp index b5b095d8bf..804e6f5026 100644 --- a/src/openrct2/paint/sprite/Paint.Peep.cpp +++ b/src/openrct2/paint/sprite/Paint.Peep.cpp @@ -87,21 +87,21 @@ template<> void PaintEntity(paint_session* session, const Peep* peep, int32_t im if (baseImageId >= 10717 && baseImageId < 10749) { imageId = (baseImageId + 32) | guest->HatColour << 19 | IMAGE_TYPE_REMAP; - PaintAddImageAsChild(session, imageId, 0, 0, 1, 1, 11, peep->z, 0, 0, peep->z + 5); + PaintAddImageAsChild(session, imageId, { 0, 0, peep->z }, { 1, 1, 11 }, { 0, 0, peep->z + 5 }); return; } if (baseImageId >= 10781 && baseImageId < 10813) { imageId = (baseImageId + 32) | guest->BalloonColour << 19 | IMAGE_TYPE_REMAP; - PaintAddImageAsChild(session, imageId, 0, 0, 1, 1, 11, peep->z, 0, 0, peep->z + 5); + PaintAddImageAsChild(session, imageId, { 0, 0, peep->z }, { 1, 1, 11 }, { 0, 0, peep->z + 5 }); return; } if (baseImageId >= 11197 && baseImageId < 11229) { imageId = (baseImageId + 32) | guest->UmbrellaColour << 19 | IMAGE_TYPE_REMAP; - PaintAddImageAsChild(session, imageId, 0, 0, 1, 1, 11, peep->z, 0, 0, peep->z + 5); + PaintAddImageAsChild(session, imageId, { 0, 0, peep->z }, { 1, 1, 11 }, { 0, 0, peep->z + 5 }); return; } } From 38ce48fdf17738291ab4049d7c0b44dba388c537 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 16:33:56 +0200 Subject: [PATCH 10/39] Refactor uses of PaintAddImageAsParent in Chairlift.cpp --- src/openrct2/ride/transport/Chairlift.cpp | 102 +++++++++++----------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/src/openrct2/ride/transport/Chairlift.cpp b/src/openrct2/ride/transport/Chairlift.cpp index ebcecc843a..ce5e9f9083 100644 --- a/src/openrct2/ride/transport/Chairlift.cpp +++ b/src/openrct2/ride/transport/Chairlift.cpp @@ -193,11 +193,11 @@ static void chairlift_paint_station_ne_sw( if (!isStart && !isEnd) { imageId = ((direction == 0) ? SPR_20502 : SPR_20504) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 6, 2 }, { 0, 13, height + 28 }); } imageId = SPR_FLOOR_METAL | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 32, 1, height, 0, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 32, 1 }, { 0, 0, height }); bool hasFence = track_paint_util_has_fence(EDGE_NW, pos, tileElement, ride, session->CurrentRotation); if (hasFence) @@ -217,7 +217,7 @@ static void chairlift_paint_station_ne_sw( if (hasFence) { imageId = SPR_FENCE_METAL_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 27, height, 0, 30, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 27 }, { 0, 30, height + 2 }); } track_paint_util_draw_station_covers(session, EDGE_SE, hasFence, stationObj, height); @@ -226,10 +226,10 @@ static void chairlift_paint_station_ne_sw( if ((direction == 0 && isStart) || (direction == 2 && isEnd)) { imageId = SPR_FENCE_METAL_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 28, 27, height, 30, 2, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 28, 27 }, { 30, 2, height + 4 }); imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 4, 4, 26 }, { 14, 14, height + 4 }); imageId = SPR_CHAIRLIFT_STATION_END_CAP_NE | session->TrackColours[SCHEME_TRACK]; PaintAddImageAsChild(session, imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4); @@ -239,7 +239,7 @@ static void chairlift_paint_station_ne_sw( else if ((direction == 2 && isStart) || (direction == 0 && isEnd)) { imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 4, 4, 26 }, { 14, 14, height + 4 }); imageId = SPR_CHAIRLIFT_STATION_END_CAP_SW | session->TrackColours[SCHEME_TRACK]; PaintAddImageAsChild(session, imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4); @@ -250,13 +250,14 @@ static void chairlift_paint_station_ne_sw( if (drawBackColumn) { imageId = SPR_CHAIRLIFT_STATION_COLUMN_NE_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 16, 1, 1, 7, height + 2, 1, 16, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 16, height + 2 }, { 1, 1, 7 }, { 1, 16, height + 2 }); } if (drawFrontColumn) { imageId = SPR_CHAIRLIFT_STATION_COLUMN_NE_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 30, 16, 1, 1, 7, height + 2, 1, 16, height + 2); // bound offset x is wrong? + PaintAddImageAsParent( + session, imageId, { 30, 16, height + 2 }, { 1, 1, 7 }, { 1, 16, height + 2 }); // bound offset x is wrong? } paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); @@ -286,11 +287,11 @@ static void chairlift_paint_station_se_nw( if (!isStart && !isEnd) { imageId = ((direction == 1) ? SPR_20503 : SPR_20505) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 6, 32, 2 }, { 13, 0, height + 28 }); } imageId = SPR_FLOOR_METAL | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 32, 1, height, 0, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 32, 1 }, { 0, 0, height }); bool hasFence = track_paint_util_has_fence(EDGE_NE, pos, tileElement, ride, session->CurrentRotation); if (hasFence) @@ -310,7 +311,7 @@ static void chairlift_paint_station_se_nw( if (hasFence) { imageId = SPR_FENCE_METAL_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 27, height, 30, 0, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 27 }, { 30, 0, height + 2 }); } track_paint_util_draw_station_covers(session, EDGE_SW, hasFence, stationObj, height); @@ -319,7 +320,7 @@ static void chairlift_paint_station_se_nw( if ((direction == 1 && isStart) || (direction == 3 && isEnd)) { imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 4, 4, 26 }, { 14, 14, height + 4 }); imageId = SPR_CHAIRLIFT_STATION_END_CAP_SE | session->TrackColours[SCHEME_TRACK]; PaintAddImageAsChild(session, imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4); @@ -329,10 +330,10 @@ static void chairlift_paint_station_se_nw( else if ((direction == 3 && isStart) || (direction == 1 && isEnd)) { imageId = SPR_FENCE_METAL_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 28, 1, 27, height, 2, 30, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 28, 1, 27 }, { 2, 30, height + 4 }); imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 4, 4, 26 }, { 14, 14, height + 4 }); imageId = SPR_CHAIRLIFT_STATION_END_CAP_NW | session->TrackColours[SCHEME_TRACK]; PaintAddImageAsChild(session, imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4); @@ -343,13 +344,14 @@ static void chairlift_paint_station_se_nw( if (drawLeftColumn) { imageId = SPR_CHAIRLIFT_STATION_COLUMN_SE_NW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 16, 0, 1, 1, 7, height + 2, 16, 1, height + 2); + PaintAddImageAsParent(session, imageId, { 16, 0, height + 2 }, { 1, 1, 7 }, { 16, 1, height + 2 }); } if (drawRightColumn) { imageId = SPR_CHAIRLIFT_STATION_COLUMN_SE_NW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 16, 30, 1, 1, 7, height + 2, 16, 1, height + 2); // bound offset x is wrong? + PaintAddImageAsParent( + session, imageId, { 16, 30, height + 2 }, { 1, 1, 7 }, { 16, 1, height + 2 }); // bound offset x is wrong? paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT); } @@ -381,13 +383,13 @@ static void chairlift_paint_flat( if (direction & 1) { imageId = SPR_CHAIRLIFT_CABLE_FLAT_SE_NW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 6, 32, 2 }, { 13, 0, height + 28 }); paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT); } else { imageId = SPR_CHAIRLIFT_CABLE_FLAT_SW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 6, 2 }, { 0, 13, height + 28 }); paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT); } @@ -406,25 +408,25 @@ static void chairlift_paint_25_deg_up( { case 0: imageId = SPR_CHAIRLIFT_CABLE_UP_SW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 6, 2 }, { 0, 13, height + 28 }); paint_util_push_tunnel_left(session, height - 8, TUNNEL_SQUARE_7); break; case 1: imageId = SPR_CHAIRLIFT_CABLE_UP_NW_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 6, 32, 2 }, { 13, 0, height + 28 }); paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_8); break; case 2: imageId = SPR_CHAIRLIFT_CABLE_UP_NE_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 6, 2 }, { 0, 13, height + 28 }); paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_8); break; case 3: imageId = SPR_CHAIRLIFT_CABLE_UP_SE_NW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 6, 32, 2 }, { 13, 0, height + 28 }); paint_util_push_tunnel_right(session, height - 8, TUNNEL_SQUARE_7); break; } @@ -444,40 +446,40 @@ static void chairlift_paint_flat_to_25_deg_up( { case 0: imageId = SPR_20508 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 6, 2 }, { 0, 13, height + 28 }); imageId = SPR_20520 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 4, 4, 25 }, { 14, 14, height + 1 }); paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT); break; case 1: imageId = SPR_20509 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 6, 32, 2 }, { 13, 0, height + 28 }); imageId = SPR_20521 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 4, 4, 25 }, { 14, 14, height + 1 }); paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_8); break; case 2: imageId = SPR_20510 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 6, 2 }, { 0, 13, height + 28 }); imageId = SPR_20522 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 4, 4, 25 }, { 14, 14, height + 1 }); paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_8); break; case 3: imageId = SPR_20511 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 6, 32, 2 }, { 13, 0, height + 28 }); imageId = SPR_20523 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 4, 4, 25 }, { 14, 14, height + 1 }); paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT); break; @@ -499,40 +501,40 @@ static void chairlift_paint_25_deg_up_to_flat( { case 0: imageId = SPR_20512 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 6, 2 }, { 0, 13, height + 28 }); imageId = SPR_20524 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 4, 4, 25 }, { 14, 14, height + 1 }); paint_util_push_tunnel_left(session, height - 8, TUNNEL_SQUARE_FLAT); break; case 1: imageId = SPR_20513 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 6, 32, 2 }, { 13, 0, height + 28 }); imageId = SPR_20525 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 4, 4, 25 }, { 14, 14, height + 1 }); paint_util_push_tunnel_right(session, height + 8, TUNNEL_14); break; case 2: imageId = SPR_20514 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 6, 2 }, { 0, 13, height + 28 }); imageId = SPR_20526 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 4, 4, 25 }, { 14, 14, height + 1 }); paint_util_push_tunnel_left(session, height + 8, TUNNEL_14); break; case 3: imageId = SPR_20515 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 6, 32, 2 }, { 13, 0, height + 28 }); imageId = SPR_20527 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 4, 4, 25 }, { 14, 14, height + 1 }); paint_util_push_tunnel_right(session, height - 8, TUNNEL_SQUARE_FLAT); break; @@ -578,50 +580,50 @@ static void chairlift_paint_left_quarter_turn_1_tile( { case 0: imageId = SPR_CHAIRLIFT_CORNER_NW_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 16, 16, 2, height, 16, 0, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 16, 16, 2 }, { 16, 0, height + 28 }); imageId = SPR_20532 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 2, 2, 27, height, 16, 4, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 2, 27 }, { 16, 4, height }); imageId = SPR_20536 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 2, 2, 27, height, 28, 4, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 2, 27 }, { 28, 4, height }); paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT); break; case 1: imageId = SPR_CHAIRLIFT_CORNER_NW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 16, 16, 2, height, 0, 0, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 16, 16, 2 }, { 0, 0, height + 28 }); imageId = SPR_20533 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 2, 2, 27, height, 16, 4, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 2, 27 }, { 16, 4, height }); imageId = SPR_20537 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 2, 2, 27, height, 4, 16, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 2, 27 }, { 4, 16, height }); break; case 2: imageId = SPR_CHAIRLIFT_CORNER_SE_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 16, 16, 2, height, 0, 16, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 16, 16, 2 }, { 0, 16, height + 28 }); imageId = SPR_20534 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 2, 2, 27, height, 4, 16, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 2, 27 }, { 4, 16, height }); imageId = SPR_20538 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 2, 2, 27, height, 16, 28, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 2, 27 }, { 16, 28, height }); paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT); break; case 3: imageId = SPR_CHAIRLIFT_CORNER_SW_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 16, 16, 2, height, 16, 16, height + 28); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 16, 16, 2 }, { 16, 16, height + 28 }); imageId = SPR_20535 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 2, 2, 27, height, 28, 16, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 2, 27 }, { 28, 16, height }); imageId = SPR_20539 | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 2, 2, 27, height, 16, 28, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 2, 27 }, { 16, 28, height }); paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT); paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT); From a12a2b69648aef249dc96e0bfef865522e4ffbf7 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 16:34:39 +0200 Subject: [PATCH 11/39] Refactor uses of PaintAddImageAsParent in MerryGoRound.cpp --- src/openrct2/ride/gentle/MerryGoRound.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/openrct2/ride/gentle/MerryGoRound.cpp b/src/openrct2/ride/gentle/MerryGoRound.cpp index c9551a6c30..90778ee6d2 100644 --- a/src/openrct2/ride/gentle/MerryGoRound.cpp +++ b/src/openrct2/ride/gentle/MerryGoRound.cpp @@ -68,7 +68,8 @@ static void paint_merry_go_round_structure( } uint32_t imageId = (baseImageId + imageOffset) | imageColourFlags; - PaintAddImageAsParent(session, imageId, xOffset, yOffset, 24, 24, 48, height, xOffset + 16, yOffset + 16, height); + PaintAddImageAsParent( + session, imageId, { xOffset, yOffset, height }, { 24, 24, 48 }, { xOffset + 16, yOffset + 16, height }); rct_drawpixelinfo* dpi = &session->DPI; if (dpi->zoom_level <= 0 && ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr) From 4009582f6ddca48b50abf25a373da093349c8384 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 16:47:15 +0200 Subject: [PATCH 12/39] Refactor uses of PaintAddImageAsParent in AirPoweredVerticalCoaster.cpp --- .../ride/coaster/AirPoweredVerticalCoaster.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/openrct2/ride/coaster/AirPoweredVerticalCoaster.cpp b/src/openrct2/ride/coaster/AirPoweredVerticalCoaster.cpp index c9c3d11574..920876083d 100644 --- a/src/openrct2/ride/coaster/AirPoweredVerticalCoaster.cpp +++ b/src/openrct2/ride/coaster/AirPoweredVerticalCoaster.cpp @@ -437,13 +437,13 @@ static void air_powered_vertical_rc_track_banked_right_quarter_turn_5( { uint32_t imageId = SPR_AIR_POWERED_VERTICAL_RC_BANKED_QUARTER_TURN_5_FRONT_NW_SW_PART_4 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 26, height, 0, 27, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 26 }, { 0, 27, height }); } else if (direction == 3 && trackSequence == 0) { uint32_t imageId = SPR_AIR_POWERED_VERTICAL_RC_BANKED_QUARTER_TURN_5_FRONT_SE_NE_PART_0 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 26, height, 27, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 26 }, { 27, 0, height }); } track_paint_util_right_quarter_turn_5_tiles_wooden_supports(session, height, direction, trackSequence); @@ -729,7 +729,7 @@ static void air_powered_vertical_rc_track_vertical_slope_up( { floorImageId = SPR_FLOOR_PLANKS | session->TrackColours[SCHEME_SUPPORTS]; } - PaintAddImageAsParent(session, floorImageId, 0, 0, 26, 26, 126, height, 3, 3, height); + PaintAddImageAsParent(session, floorImageId, { 0, 0, height }, { 26, 26, 126 }, { 3, 3, height }); PaintAddImageAsChildRotated(session, direction, supportsImageId, 0, 0, 26, 26, 126, height, 3, 3, height); } else @@ -913,13 +913,13 @@ static void air_powered_vertical_rc_track_booster( if (direction & 1) { uint32_t imageId = SPR_REVERSE_FREEFALL_RC_FLAT_NW_SE | colour; - PaintAddImageAsParent(session, imageId, 0, 0, 20, 32, 1, height, 6, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 20, 32, 1 }, { 6, 0, height }); paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT); } else { uint32_t imageId = SPR_REVERSE_FREEFALL_RC_FLAT_SW_NE | colour; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 20, 1, height, 0, 6, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 20, 1 }, { 0, 6, height }); paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT); } From 0036652eb5b9ad124e4dba5f7263a28fc6f3fa01 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 16:57:25 +0200 Subject: [PATCH 13/39] Refactor uses of PaintAddImageAsParent in TopSpin.cpp --- src/openrct2/ride/thrill/TopSpin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/ride/thrill/TopSpin.cpp b/src/openrct2/ride/thrill/TopSpin.cpp index 989caa9edc..3487207786 100644 --- a/src/openrct2/ride/thrill/TopSpin.cpp +++ b/src/openrct2/ride/thrill/TopSpin.cpp @@ -91,7 +91,7 @@ static void top_spin_paint_vehicle( // Left back bottom support image_id += 572; PaintAddImageAsParent( - session, image_id, al, cl, lengthX, lengthY, 90, height, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ); + session, image_id, { al, cl, height }, { lengthX, lengthY, 90 }, { boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ }); image_id = session->TrackColours[SCHEME_MISC]; if (image_id == IMAGE_TYPE_REMAP) From 58df44efc377a086e95dbd0104f4d5f8a2348f8f Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 17:00:38 +0200 Subject: [PATCH 14/39] Refactor uses of PaintAddImageAsParent in TrackPaint.cpp --- src/openrct2/ride/TrackPaint.cpp | 60 ++++++++++++++++---------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/openrct2/ride/TrackPaint.cpp b/src/openrct2/ride/TrackPaint.cpp index ab071b9044..9770b4cf8e 100644 --- a/src/openrct2/ride/TrackPaint.cpp +++ b/src/openrct2/ride/TrackPaint.cpp @@ -894,11 +894,11 @@ void track_paint_util_draw_pier( hasFence = track_paint_util_has_fence(EDGE_NE, position, tileElement, ride, session->CurrentRotation); imageId = (hasFence ? SPR_STATION_PIER_EDGE_NE_FENCED : SPR_STATION_PIER_EDGE_NE) | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 6, 32, 1, height, 2, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 6, 32, 1 }, { 2, 0, height }); track_paint_util_draw_station_covers(session, EDGE_NE, hasFence, stationObj, height); imageId = SPR_STATION_PIER_EDGE_SW | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 24, 0, 8, 32, 1, height); + PaintAddImageAsParent(session, imageId, { 24, 0, height }, { 8, 32, 1 }); hasFence = track_paint_util_has_fence(EDGE_SW, position, tileElement, ride, session->CurrentRotation); if (hasFence) @@ -913,11 +913,11 @@ void track_paint_util_draw_pier( hasFence = track_paint_util_has_fence(EDGE_NW, position, tileElement, ride, rotation); imageId = (hasFence ? SPR_STATION_PIER_EDGE_NW_FENCED : SPR_STATION_PIER_EDGE_NW) | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 6, 1, height, 0, 2, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 6, 1 }, { 0, 2, height }); track_paint_util_draw_station_covers(session, EDGE_NW, hasFence, stationObj, height); imageId = SPR_STATION_PIER_EDGE_SE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 24, 32, 8, 1, height); + PaintAddImageAsParent(session, imageId, { 0, 24, height }, { 32, 8, 1 }); hasFence = track_paint_util_has_fence(EDGE_SE, position, tileElement, ride, rotation); if (hasFence) @@ -2003,11 +2003,11 @@ void track_paint_util_spinning_tunnel_paint(paint_session* session, int8_t thick imageId = trackSpritesGhostTrainSpinningTunnel[direction & 1][1][frame] | colourFlags; if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 0, 26, 1, 23, height, 4, 28, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 26, 1, 23 }, { 4, 28, height }); } else { - PaintAddImageAsParent(session, imageId, 0, 0, 1, 26, 23, height, 28, 4, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 26, 23 }, { 28, 4, height }); } } @@ -2027,24 +2027,24 @@ void track_paint_util_onride_photo_small_paint( switch (direction) { case 0: - PaintAddImageAsParent(session, imageId, 26, 0, 1, 1, 19, height); - PaintAddImageAsParent(session, imageId, 26, 31, 1, 1, 19, height); - PaintAddImageAsParent(session, flashImageId, 6, 0, 1, 1, 19, height); + PaintAddImageAsParent(session, imageId, { 26, 0, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, imageId, { 26, 31, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, flashImageId, { 6, 0, height }, { 1, 1, 19 }); break; case 1: - PaintAddImageAsParent(session, imageId, 0, 6, 1, 1, 19, height); - PaintAddImageAsParent(session, imageId, 31, 6, 1, 1, 19, height); - PaintAddImageAsParent(session, flashImageId, 0, 26, 1, 1, 19, height); + PaintAddImageAsParent(session, imageId, { 0, 6, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, imageId, { 31, 6, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, flashImageId, { 0, 26, height }, { 1, 1, 19 }); break; case 2: - PaintAddImageAsParent(session, imageId, 6, 0, 1, 1, 19, height); - PaintAddImageAsParent(session, imageId, 6, 31, 1, 1, 19, height); - PaintAddImageAsParent(session, flashImageId, 26, 31, 1, 1, 19, height); + PaintAddImageAsParent(session, imageId, { 6, 0, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, imageId, { 6, 31, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, flashImageId, { 26, 31, height }, { 1, 1, 19 }); break; case 3: - PaintAddImageAsParent(session, imageId, 0, 26, 1, 1, 19, height); - PaintAddImageAsParent(session, imageId, 31, 26, 1, 1, 19, height); - PaintAddImageAsParent(session, flashImageId, 31, 6, 1, 1, 19, height); + PaintAddImageAsParent(session, imageId, { 0, 26, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, imageId, { 31, 26, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, flashImageId, { 31, 6, height }, { 1, 1, 19 }); break; } } @@ -2065,24 +2065,24 @@ void track_paint_util_onride_photo_paint( switch (direction) { case 0: - PaintAddImageAsParent(session, imageId, 26, 0, 1, 1, 19, height); - PaintAddImageAsParent(session, imageId, 26, 31, 1, 1, 19, height); - PaintAddImageAsParent(session, flashImageId, 6, 0, 1, 1, 19, height); + PaintAddImageAsParent(session, imageId, { 26, 0, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, imageId, { 26, 31, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, flashImageId, { 6, 0, height }, { 1, 1, 19 }); break; case 1: - PaintAddImageAsParent(session, imageId, 0, 6, 1, 1, 19, height); - PaintAddImageAsParent(session, imageId, 31, 6, 1, 1, 19, height); - PaintAddImageAsParent(session, flashImageId, 0, 26, 1, 1, 19, height); + PaintAddImageAsParent(session, imageId, { 0, 6, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, imageId, { 31, 6, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, flashImageId, { 0, 26, height }, { 1, 1, 19 }); break; case 2: - PaintAddImageAsParent(session, imageId, 6, 0, 1, 1, 19, height); - PaintAddImageAsParent(session, imageId, 6, 31, 1, 1, 19, height); - PaintAddImageAsParent(session, flashImageId, 26, 31, 1, 1, 19, height); + PaintAddImageAsParent(session, imageId, { 6, 0, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, imageId, { 6, 31, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, flashImageId, { 26, 31, height }, { 1, 1, 19 }); break; case 3: - PaintAddImageAsParent(session, imageId, 0, 26, 1, 1, 19, height); - PaintAddImageAsParent(session, imageId, 31, 26, 1, 1, 19, height); - PaintAddImageAsParent(session, flashImageId, 31, 6, 1, 1, 19, height); + PaintAddImageAsParent(session, imageId, { 0, 26, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, imageId, { 31, 26, height }, { 1, 1, 19 }); + PaintAddImageAsParent(session, flashImageId, { 31, 6, height }, { 1, 1, 19 }); break; } } From 2aed03ca5f12b15d5034734212cf5fb0a3c0318d Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 17:09:45 +0200 Subject: [PATCH 15/39] Refactor uses of PaintAddImageAsParent in Paint.Path.cpp --- .../paint/tile_element/Paint.Path.cpp | 186 +++++++++--------- 1 file changed, 93 insertions(+), 93 deletions(-) diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 002e186fee..34d78b3d76 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -108,7 +108,7 @@ static void path_bit_lights_paint( imageId |= pathBitImageFlags; - PaintAddImageAsParent(session, imageId, 2, 16, 1, 1, 23, height, 3, 16, height + 2); + PaintAddImageAsParent(session, imageId, { 2, 16, height }, { 1, 1, 23 }, { 3, 16, height + 2 }); } if (!(edges & EDGE_SE)) { @@ -119,7 +119,7 @@ static void path_bit_lights_paint( imageId |= pathBitImageFlags; - PaintAddImageAsParent(session, imageId, 16, 30, 1, 0, 23, height, 16, 29, height + 2); + PaintAddImageAsParent(session, imageId, { 16, 30, height }, { 1, 0, 23 }, { 16, 29, height + 2 }); } if (!(edges & EDGE_SW)) @@ -131,7 +131,7 @@ static void path_bit_lights_paint( imageId |= pathBitImageFlags; - PaintAddImageAsParent(session, imageId, 30, 16, 0, 1, 23, height, 29, 16, height + 2); + PaintAddImageAsParent(session, imageId, { 30, 16, height }, { 0, 1, 23 }, { 29, 16, height + 2 }); } if (!(edges & EDGE_NW)) @@ -143,7 +143,7 @@ static void path_bit_lights_paint( imageId |= pathBitImageFlags; - PaintAddImageAsParent(session, imageId, 16, 2, 1, 1, 23, height, 16, 3, height + 2); + PaintAddImageAsParent(session, imageId, { 16, 2, height }, { 1, 1, 23 }, { 16, 3, height + 2 }); } } @@ -177,7 +177,7 @@ static void path_bit_bins_paint( } if (!(session->ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES) || binIsFull || binsAreVandalised) - PaintAddImageAsParent(session, imageId, 7, 16, 1, 1, 7, height, 7, 16, height + 2); + PaintAddImageAsParent(session, imageId, { 7, 16, height }, { 1, 1, 7 }, { 7, 16, height + 2 }); } if (!(edges & EDGE_SE)) { @@ -198,7 +198,7 @@ static void path_bit_bins_paint( } if (!(session->ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES) || binIsFull || binsAreVandalised) - PaintAddImageAsParent(session, imageId, 16, 25, 1, 1, 7, height, 16, 25, height + 2); + PaintAddImageAsParent(session, imageId, { 16, 25, height }, { 1, 1, 7 }, { 16, 25, height + 2 }); } if (!(edges & EDGE_SW)) @@ -220,7 +220,7 @@ static void path_bit_bins_paint( } if (!(session->ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES) || binIsFull || binsAreVandalised) - PaintAddImageAsParent(session, imageId, 25, 16, 1, 1, 7, height, 25, 16, height + 2); + PaintAddImageAsParent(session, imageId, { 25, 16, height }, { 1, 1, 7 }, { 25, 16, height + 2 }); } if (!(edges & EDGE_NW)) @@ -242,7 +242,7 @@ static void path_bit_bins_paint( } if (!(session->ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES) || binIsFull || binsAreVandalised) - PaintAddImageAsParent(session, imageId, 16, 7, 1, 1, 7, height, 16, 7, height + 2); + PaintAddImageAsParent(session, imageId, { 16, 7, height }, { 1, 1, 7 }, { 16, 7, height + 2 }); } } @@ -262,7 +262,7 @@ static void path_bit_benches_paint( imageId |= pathBitImageFlags; - PaintAddImageAsParent(session, imageId, 7, 16, 0, 16, 7, height, 6, 8, height + 2); + PaintAddImageAsParent(session, imageId, { 7, 16, height }, { 0, 16, 7 }, { 6, 8, height + 2 }); } if (!(edges & EDGE_SE)) { @@ -273,7 +273,7 @@ static void path_bit_benches_paint( imageId |= pathBitImageFlags; - PaintAddImageAsParent(session, imageId, 16, 25, 16, 0, 7, height, 8, 23, height + 2); + PaintAddImageAsParent(session, imageId, { 16, 25, height }, { 16, 0, 7 }, { 8, 23, height + 2 }); } if (!(edges & EDGE_SW)) @@ -285,7 +285,7 @@ static void path_bit_benches_paint( imageId |= pathBitImageFlags; - PaintAddImageAsParent(session, imageId, 25, 16, 0, 16, 7, height, 23, 8, height + 2); + PaintAddImageAsParent(session, imageId, { 25, 16, height }, { 0, 16, 7 }, { 23, 8, height + 2 }); } if (!(edges & EDGE_NW)) @@ -297,7 +297,7 @@ static void path_bit_benches_paint( imageId |= pathBitImageFlags; - PaintAddImageAsParent(session, imageId, 16, 7, 16, 0, 7, height, 8, 6, height + 2); + PaintAddImageAsParent(session, imageId, { 16, 7, height }, { 16, 0, 7 }, { 8, 6, height + 2 }); } } @@ -311,10 +311,10 @@ static void path_bit_jumping_fountains_paint( uint32_t imageId = pathBitEntry->image; imageId |= pathBitImageFlags; - PaintAddImageAsParent(session, imageId + 1, 0, 0, 1, 1, 2, height, 3, 3, height + 2); - PaintAddImageAsParent(session, imageId + 2, 0, 0, 1, 1, 2, height, 3, 29, height + 2); - PaintAddImageAsParent(session, imageId + 3, 0, 0, 1, 1, 2, height, 29, 29, height + 2); - PaintAddImageAsParent(session, imageId + 4, 0, 0, 1, 1, 2, height, 29, 3, height + 2); + PaintAddImageAsParent(session, imageId + 1, { 0, 0, height }, { 1, 1, 2 }, { 3, 3, height + 2 }); + PaintAddImageAsParent(session, imageId + 2, { 0, 0, height }, { 1, 1, 2 }, { 3, 29, height + 2 }); + PaintAddImageAsParent(session, imageId + 3, { 0, 0, height }, { 1, 1, 2 }, { 29, 29, height + 2 }); + PaintAddImageAsParent(session, imageId + 4, { 0, 0, height }, { 1, 1, 2 }, { 29, 3, height + 2 }); } /** @@ -336,20 +336,20 @@ static void sub_6A4101( & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK) { case 0: - PaintAddImageAsParent(session, 22 + base_image_id, 0, 4, 32, 1, 23, height, 0, 4, height + 2); - PaintAddImageAsParent(session, 22 + base_image_id, 0, 28, 32, 1, 23, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 22 + base_image_id, { 0, 4, height }, { 32, 1, 23 }, { 0, 4, height + 2 }); + PaintAddImageAsParent(session, 22 + base_image_id, { 0, 28, height }, { 32, 1, 23 }, { 0, 28, height + 2 }); break; case 1: - PaintAddImageAsParent(session, 21 + base_image_id, 4, 0, 1, 32, 23, height, 4, 0, height + 2); - PaintAddImageAsParent(session, 21 + base_image_id, 28, 0, 1, 32, 23, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 21 + base_image_id, { 4, 0, height }, { 1, 32, 23 }, { 4, 0, height + 2 }); + PaintAddImageAsParent(session, 21 + base_image_id, { 28, 0, height }, { 1, 32, 23 }, { 28, 0, height + 2 }); break; case 2: - PaintAddImageAsParent(session, 23 + base_image_id, 0, 4, 32, 1, 23, height, 0, 4, height + 2); - PaintAddImageAsParent(session, 23 + base_image_id, 0, 28, 32, 1, 23, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 23 + base_image_id, { 0, 4, height }, { 32, 1, 23 }, { 0, 4, height + 2 }); + PaintAddImageAsParent(session, 23 + base_image_id, { 0, 28, height }, { 32, 1, 23 }, { 0, 28, height + 2 }); break; case 3: - PaintAddImageAsParent(session, 20 + base_image_id, 4, 0, 1, 32, 23, height, 4, 0, height + 2); - PaintAddImageAsParent(session, 20 + base_image_id, 28, 0, 1, 32, 23, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 20 + base_image_id, { 4, 0, height }, { 1, 32, 23 }, { 4, 0, height + 2 }); + PaintAddImageAsParent(session, 20 + base_image_id, { 28, 0, height }, { 1, 32, 23 }, { 28, 0, height + 2 }); break; } } @@ -358,52 +358,52 @@ static void sub_6A4101( switch (local_ebp) { case 1: - PaintAddImageAsParent(session, 17 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2); - PaintAddImageAsParent(session, 17 + base_image_id, 0, 28, 28, 1, 7, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 17 + base_image_id, { 0, 4, height }, { 28, 1, 7 }, { 0, 4, height + 2 }); + PaintAddImageAsParent(session, 17 + base_image_id, { 0, 28, height }, { 28, 1, 7 }, { 0, 28, height + 2 }); break; case 2: - PaintAddImageAsParent(session, 18 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2); - PaintAddImageAsParent(session, 18 + base_image_id, 28, 0, 1, 28, 7, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 18 + base_image_id, { 4, 0, height }, { 1, 28, 7 }, { 4, 0, height + 2 }); + PaintAddImageAsParent(session, 18 + base_image_id, { 28, 0, height }, { 1, 28, 7 }, { 28, 0, height + 2 }); break; case 3: - PaintAddImageAsParent(session, 17 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2); + PaintAddImageAsParent(session, 17 + base_image_id, { 0, 4, height }, { 28, 1, 7 }, { 0, 4, height + 2 }); PaintAddImageAsParent( session, 18 + base_image_id, 28, 0, 1, 28, 7, height, 28, 4, height + 2); // bound_box_offset_y seems to be a bug - PaintAddImageAsParent(session, 25 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 25 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 0, 28, height + 2 }); break; case 4: - PaintAddImageAsParent(session, 19 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2); - PaintAddImageAsParent(session, 19 + base_image_id, 0, 28, 28, 1, 7, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 19 + base_image_id, { 0, 4, height }, { 28, 1, 7 }, { 0, 4, height + 2 }); + PaintAddImageAsParent(session, 19 + base_image_id, { 0, 28, height }, { 28, 1, 7 }, { 0, 28, height + 2 }); break; case 5: - PaintAddImageAsParent(session, 15 + base_image_id, 0, 4, 32, 1, 7, height, 0, 4, height + 2); - PaintAddImageAsParent(session, 15 + base_image_id, 0, 28, 32, 1, 7, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 15 + base_image_id, { 0, 4, height }, { 32, 1, 7 }, { 0, 4, height + 2 }); + PaintAddImageAsParent(session, 15 + base_image_id, { 0, 28, height }, { 32, 1, 7 }, { 0, 28, height + 2 }); break; case 6: - PaintAddImageAsParent(session, 18 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2); - PaintAddImageAsParent(session, 19 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2); - PaintAddImageAsParent(session, 26 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2); + PaintAddImageAsParent(session, 18 + base_image_id, { 4, 0, height }, { 1, 28, 7 }, { 4, 0, height + 2 }); + PaintAddImageAsParent(session, 19 + base_image_id, { 0, 4, height }, { 28, 1, 7 }, { 0, 4, height + 2 }); + PaintAddImageAsParent(session, 26 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 28, 28, height + 2 }); break; case 8: - PaintAddImageAsParent(session, 16 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2); - PaintAddImageAsParent(session, 16 + base_image_id, 28, 0, 1, 28, 7, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 16 + base_image_id, { 4, 0, height }, { 1, 28, 7 }, { 4, 0, height + 2 }); + PaintAddImageAsParent(session, 16 + base_image_id, { 28, 0, height }, { 1, 28, 7 }, { 28, 0, height + 2 }); break; case 9: - PaintAddImageAsParent(session, 16 + base_image_id, 28, 0, 1, 28, 7, height, 28, 0, height + 2); - PaintAddImageAsParent(session, 17 + base_image_id, 0, 28, 28, 1, 7, height, 0, 28, height + 2); - PaintAddImageAsParent(session, 24 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2); + PaintAddImageAsParent(session, 16 + base_image_id, { 28, 0, height }, { 1, 28, 7 }, { 28, 0, height + 2 }); + PaintAddImageAsParent(session, 17 + base_image_id, { 0, 28, height }, { 28, 1, 7 }, { 0, 28, height + 2 }); + PaintAddImageAsParent(session, 24 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 0, 0, height + 2 }); break; case 10: - PaintAddImageAsParent(session, 14 + base_image_id, 4, 0, 1, 32, 7, height, 4, 0, height + 2); - PaintAddImageAsParent(session, 14 + base_image_id, 28, 0, 1, 32, 7, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 14 + base_image_id, { 4, 0, height }, { 1, 32, 7 }, { 4, 0, height + 2 }); + PaintAddImageAsParent(session, 14 + base_image_id, { 28, 0, height }, { 1, 32, 7 }, { 28, 0, height + 2 }); break; case 12: - PaintAddImageAsParent(session, 16 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2); + PaintAddImageAsParent(session, 16 + base_image_id, { 4, 0, height }, { 1, 28, 7 }, { 4, 0, height + 2 }); PaintAddImageAsParent( session, 19 + base_image_id, 0, 28, 28, 1, 7, height, 4, 28, height + 2); // bound_box_offset_x seems to be a bug - PaintAddImageAsParent(session, 27 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 27 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 28, 0, height + 2 }); break; default: // purposely left empty @@ -501,20 +501,20 @@ static void sub_6A4101( & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK) { case 0: - PaintAddImageAsParent(session, 8 + base_image_id, 0, 4, 32, 1, 23, height, 0, 4, height + 2); - PaintAddImageAsParent(session, 8 + base_image_id, 0, 28, 32, 1, 23, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 8 + base_image_id, { 0, 4, height }, { 32, 1, 23 }, { 0, 4, height + 2 }); + PaintAddImageAsParent(session, 8 + base_image_id, { 0, 28, height }, { 32, 1, 23 }, { 0, 28, height + 2 }); break; case 1: - PaintAddImageAsParent(session, 7 + base_image_id, 4, 0, 1, 32, 23, height, 4, 0, height + 2); - PaintAddImageAsParent(session, 7 + base_image_id, 28, 0, 1, 32, 23, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 7 + base_image_id, { 4, 0, height }, { 1, 32, 23 }, { 4, 0, height + 2 }); + PaintAddImageAsParent(session, 7 + base_image_id, { 28, 0, height }, { 1, 32, 23 }, { 28, 0, height + 2 }); break; case 2: - PaintAddImageAsParent(session, 9 + base_image_id, 0, 4, 32, 1, 23, height, 0, 4, height + 2); - PaintAddImageAsParent(session, 9 + base_image_id, 0, 28, 32, 1, 23, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 9 + base_image_id, { 0, 4, height }, { 32, 1, 23 }, { 0, 4, height + 2 }); + PaintAddImageAsParent(session, 9 + base_image_id, { 0, 28, height }, { 32, 1, 23 }, { 0, 28, height + 2 }); break; case 3: - PaintAddImageAsParent(session, 6 + base_image_id, 4, 0, 1, 32, 23, height, 4, 0, height + 2); - PaintAddImageAsParent(session, 6 + base_image_id, 28, 0, 1, 32, 23, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 6 + base_image_id, { 4, 0, height }, { 1, 32, 23 }, { 4, 0, height + 2 }); + PaintAddImageAsParent(session, 6 + base_image_id, { 28, 0, height }, { 1, 32, 23 }, { 28, 0, height + 2 }); break; } } @@ -531,128 +531,128 @@ static void sub_6A4101( // purposely left empty break; case 1: - PaintAddImageAsParent(session, 3 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2); - PaintAddImageAsParent(session, 3 + base_image_id, 0, 28, 28, 1, 7, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 3 + base_image_id, { 0, 4, height }, { 28, 1, 7 }, { 0, 4, height + 2 }); + PaintAddImageAsParent(session, 3 + base_image_id, { 0, 28, height }, { 28, 1, 7 }, { 0, 28, height + 2 }); break; case 2: - PaintAddImageAsParent(session, 4 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2); - PaintAddImageAsParent(session, 4 + base_image_id, 28, 0, 1, 28, 7, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 4 + base_image_id, { 4, 0, height }, { 1, 28, 7 }, { 4, 0, height + 2 }); + PaintAddImageAsParent(session, 4 + base_image_id, { 28, 0, height }, { 1, 28, 7 }, { 28, 0, height + 2 }); break; case 4: - PaintAddImageAsParent(session, 5 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2); - PaintAddImageAsParent(session, 5 + base_image_id, 0, 28, 28, 1, 7, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 5 + base_image_id, { 0, 4, height }, { 28, 1, 7 }, { 0, 4, height + 2 }); + PaintAddImageAsParent(session, 5 + base_image_id, { 0, 28, height }, { 28, 1, 7 }, { 0, 28, height + 2 }); break; case 5: - PaintAddImageAsParent(session, 1 + base_image_id, 0, 4, 32, 1, 7, height, 0, 4, height + 2); - PaintAddImageAsParent(session, 1 + base_image_id, 0, 28, 32, 1, 7, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 1 + base_image_id, { 0, 4, height }, { 32, 1, 7 }, { 0, 4, height + 2 }); + PaintAddImageAsParent(session, 1 + base_image_id, { 0, 28, height }, { 32, 1, 7 }, { 0, 28, height + 2 }); break; case 8: - PaintAddImageAsParent(session, 2 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2); - PaintAddImageAsParent(session, 2 + base_image_id, 28, 0, 1, 28, 7, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 2 + base_image_id, { 4, 0, height }, { 1, 28, 7 }, { 4, 0, height + 2 }); + PaintAddImageAsParent(session, 2 + base_image_id, { 28, 0, height }, { 1, 28, 7 }, { 28, 0, height + 2 }); break; case 10: - PaintAddImageAsParent(session, 0 + base_image_id, 4, 0, 1, 32, 7, height, 4, 0, height + 2); - PaintAddImageAsParent(session, 0 + base_image_id, 28, 0, 1, 32, 7, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 0 + base_image_id, { 4, 0, height }, { 1, 32, 7 }, { 4, 0, height + 2 }); + PaintAddImageAsParent(session, 0 + base_image_id, { 28, 0, height }, { 1, 32, 7 }, { 28, 0, height + 2 }); break; case 3: - PaintAddImageAsParent(session, 3 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2); + PaintAddImageAsParent(session, 3 + base_image_id, { 0, 4, height }, { 28, 1, 7 }, { 0, 4, height + 2 }); PaintAddImageAsParent( session, 4 + base_image_id, 28, 0, 1, 28, 7, height, 28, 4, height + 2); // bound_box_offset_y seems to be a bug if (!(drawnCorners & FOOTPATH_CORNER_0)) { - PaintAddImageAsParent(session, 11 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 11 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 0, 28, height + 2 }); } break; case 6: - PaintAddImageAsParent(session, 4 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2); - PaintAddImageAsParent(session, 5 + base_image_id, 0, 4, 28, 1, 7, height, 0, 4, height + 2); + PaintAddImageAsParent(session, 4 + base_image_id, { 4, 0, height }, { 1, 28, 7 }, { 4, 0, height + 2 }); + PaintAddImageAsParent(session, 5 + base_image_id, { 0, 4, height }, { 28, 1, 7 }, { 0, 4, height + 2 }); if (!(drawnCorners & FOOTPATH_CORNER_1)) { - PaintAddImageAsParent(session, 12 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2); + PaintAddImageAsParent(session, 12 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 28, 28, height + 2 }); } break; case 9: - PaintAddImageAsParent(session, 2 + base_image_id, 28, 0, 1, 28, 7, height, 28, 0, height + 2); - PaintAddImageAsParent(session, 3 + base_image_id, 0, 28, 28, 1, 7, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 2 + base_image_id, { 28, 0, height }, { 1, 28, 7 }, { 28, 0, height + 2 }); + PaintAddImageAsParent(session, 3 + base_image_id, { 0, 28, height }, { 28, 1, 7 }, { 0, 28, height + 2 }); if (!(drawnCorners & FOOTPATH_CORNER_3)) { - PaintAddImageAsParent(session, 10 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2); + PaintAddImageAsParent(session, 10 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 0, 0, height + 2 }); } break; case 12: - PaintAddImageAsParent(session, 2 + base_image_id, 4, 0, 1, 28, 7, height, 4, 0, height + 2); + PaintAddImageAsParent(session, 2 + base_image_id, { 4, 0, height }, { 1, 28, 7 }, { 4, 0, height + 2 }); PaintAddImageAsParent( session, 5 + base_image_id, 0, 28, 28, 1, 7, height, 4, 28, height + 2); // bound_box_offset_x seems to be a bug if (!(drawnCorners & FOOTPATH_CORNER_2)) { - PaintAddImageAsParent(session, 13 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 13 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 28, 0, height + 2 }); } break; case 7: - PaintAddImageAsParent(session, 1 + base_image_id, 0, 4, 32, 1, 7, height, 0, 4, height + 2); + PaintAddImageAsParent(session, 1 + base_image_id, { 0, 4, height }, { 32, 1, 7 }, { 0, 4, height + 2 }); if (!(drawnCorners & FOOTPATH_CORNER_0)) { - PaintAddImageAsParent(session, 11 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 11 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 0, 28, height + 2 }); } if (!(drawnCorners & FOOTPATH_CORNER_1)) { - PaintAddImageAsParent(session, 12 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2); + PaintAddImageAsParent(session, 12 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 28, 28, height + 2 }); } break; case 13: - PaintAddImageAsParent(session, 1 + base_image_id, 0, 28, 32, 1, 7, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 1 + base_image_id, { 0, 28, height }, { 32, 1, 7 }, { 0, 28, height + 2 }); if (!(drawnCorners & FOOTPATH_CORNER_2)) { - PaintAddImageAsParent(session, 13 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 13 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 28, 0, height + 2 }); } if (!(drawnCorners & FOOTPATH_CORNER_3)) { - PaintAddImageAsParent(session, 10 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2); + PaintAddImageAsParent(session, 10 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 0, 0, height + 2 }); } break; case 14: - PaintAddImageAsParent(session, 0 + base_image_id, 4, 0, 1, 32, 7, height, 4, 0, height + 2); + PaintAddImageAsParent(session, 0 + base_image_id, { 4, 0, height }, { 1, 32, 7 }, { 4, 0, height + 2 }); if (!(drawnCorners & FOOTPATH_CORNER_1)) { - PaintAddImageAsParent(session, 12 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2); + PaintAddImageAsParent(session, 12 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 28, 28, height + 2 }); } if (!(drawnCorners & FOOTPATH_CORNER_2)) { - PaintAddImageAsParent(session, 13 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 13 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 28, 0, height + 2 }); } break; case 11: - PaintAddImageAsParent(session, 0 + base_image_id, 28, 0, 1, 32, 7, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 0 + base_image_id, { 28, 0, height }, { 1, 32, 7 }, { 28, 0, height + 2 }); if (!(drawnCorners & FOOTPATH_CORNER_0)) { - PaintAddImageAsParent(session, 11 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 11 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 0, 28, height + 2 }); } if (!(drawnCorners & FOOTPATH_CORNER_3)) { - PaintAddImageAsParent(session, 10 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2); + PaintAddImageAsParent(session, 10 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 0, 0, height + 2 }); } break; case 15: if (!(drawnCorners & FOOTPATH_CORNER_0)) { - PaintAddImageAsParent(session, 11 + base_image_id, 0, 0, 4, 4, 7, height, 0, 28, height + 2); + PaintAddImageAsParent(session, 11 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 0, 28, height + 2 }); } if (!(drawnCorners & FOOTPATH_CORNER_1)) { - PaintAddImageAsParent(session, 12 + base_image_id, 0, 0, 4, 4, 7, height, 28, 28, height + 2); + PaintAddImageAsParent(session, 12 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 28, 28, height + 2 }); } if (!(drawnCorners & FOOTPATH_CORNER_2)) { - PaintAddImageAsParent(session, 13 + base_image_id, 0, 0, 4, 4, 7, height, 28, 0, height + 2); + PaintAddImageAsParent(session, 13 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 28, 0, height + 2 }); } if (!(drawnCorners & FOOTPATH_CORNER_3)) { - PaintAddImageAsParent(session, 10 + base_image_id, 0, 0, 4, 4, 7, height, 0, 0, height + 2); + PaintAddImageAsParent(session, 10 + base_image_id, { 0, 0, height }, { 4, 4, 7 }, { 0, 0, height + 2 }); } break; } @@ -937,7 +937,7 @@ void path_paint(paint_session* session, uint16_t height, const TileElement* tile uint32_t imageId = (SPR_HEIGHT_MARKER_BASE + heightMarkerBaseZ / 16) | COLOUR_GREY << 19 | IMAGE_TYPE_REMAP; imageId += get_height_marker_offset(); imageId -= gMapBaseZ; - PaintAddImageAsParent(session, imageId, 16, 16, 1, 1, 0, heightMarkerBaseZ); + PaintAddImageAsParent(session, imageId, { 16, 16, heightMarkerBaseZ }, { 1, 1, 0 }); } PathSurfaceEntry* footpathEntry = tile_element->AsPath()->GetSurfaceEntry(); From 74f0cf8063651f08fed37883cea682746871a1ff Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 17:09:59 +0200 Subject: [PATCH 16/39] Refactor uses of PaintAddImageAsParent in Monorail.cpp --- src/openrct2/ride/transport/Monorail.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/openrct2/ride/transport/Monorail.cpp b/src/openrct2/ride/transport/Monorail.cpp index d564f70c28..eccd89fa0f 100644 --- a/src/openrct2/ride/transport/Monorail.cpp +++ b/src/openrct2/ride/transport/Monorail.cpp @@ -426,11 +426,11 @@ static void paint_monorail_track_flat( if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 6, 32, 20, 3, height); + PaintAddImageAsParent(session, imageId, { 0, 6, height }, { 32, 20, 3 }); } else { - PaintAddImageAsParent(session, imageId, 6, 0, 20, 32, 3, height); + PaintAddImageAsParent(session, imageId, { 6, 0, height }, { 20, 32, 3 }); } if (direction == 0 || direction == 2) @@ -515,11 +515,11 @@ static void paint_monorail_track_25_deg_up( if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 6, 32, 20, 3, height); + PaintAddImageAsParent(session, imageId, { 0, 6, height }, { 32, 20, 3 }); } else { - PaintAddImageAsParent(session, imageId, 6, 0, 20, 32, 3, height); + PaintAddImageAsParent(session, imageId, { 6, 0, height }, { 20, 32, 3 }); } switch (direction) @@ -557,11 +557,11 @@ static void paint_monorail_track_flat_to_25_deg_up( if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 6, 32, 20, 3, height); + PaintAddImageAsParent(session, imageId, { 0, 6, height }, { 32, 20, 3 }); } else { - PaintAddImageAsParent(session, imageId, 6, 0, 20, 32, 3, height); + PaintAddImageAsParent(session, imageId, { 6, 0, height }, { 20, 32, 3 }); } switch (direction) @@ -599,11 +599,11 @@ static void paint_monorail_track_25_deg_up_to_flat( if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 6, 32, 20, 3, height); + PaintAddImageAsParent(session, imageId, { 0, 6, height }, { 32, 20, 3 }); } else { - PaintAddImageAsParent(session, imageId, 6, 0, 20, 32, 3, height); + PaintAddImageAsParent(session, imageId, { 6, 0, height }, { 20, 32, 3 }); } switch (direction) From 91ddb0f5c905b31b1520d1f72b0a29978420966d Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 17:11:11 +0200 Subject: [PATCH 17/39] Refactor uses of PaintAddImageAsParent in GoKarts.cpp --- src/openrct2/ride/thrill/GoKarts.cpp | 78 ++++++++++++++-------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/openrct2/ride/thrill/GoKarts.cpp b/src/openrct2/ride/thrill/GoKarts.cpp index 86e566ecd6..6fbbc33c99 100644 --- a/src/openrct2/ride/thrill/GoKarts.cpp +++ b/src/openrct2/ride/thrill/GoKarts.cpp @@ -132,20 +132,20 @@ static void paint_go_karts_track_flat( if (direction == 0 || direction == 2) { imageId = SPR_GO_KARTS_FLAT_SW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 28, 1, height, 0, 2, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 28, 1 }, { 0, 2, height }); imageId = SPR_GO_KARTS_FLAT_FRONT_SW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 3, height, 0, 29, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 3 }, { 0, 29, height + 2 }); paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT); } else { imageId = SPR_GO_KARTS_FLAT_NW_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 28, 32, 1, height, 2, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 28, 32, 1 }, { 2, 0, height }); imageId = SPR_GO_KARTS_FLAT_FRONT_NW_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 3, height, 29, 0, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 3 }, { 29, 0, height + 2 }); paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT); } @@ -167,21 +167,21 @@ static void paint_go_karts_track_25_deg_up( imageId = go_karts_track_pieces_25_deg_up[direction][0] | session->TrackColours[SCHEME_TRACK]; if (direction == 0 || direction == 2) { - ps = PaintAddImageAsParent(session, imageId, 0, 0, 32, 28, 1, height, 0, 2, height); + ps = PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 28, 1 }, { 0, 2, height }); } else { - ps = PaintAddImageAsParent(session, imageId, 0, 0, 28, 32, 1, height, 2, 0, height); + ps = PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 28, 32, 1 }, { 2, 0, height }); } imageId = go_karts_track_pieces_25_deg_up[direction][1] | session->TrackColours[SCHEME_TRACK]; if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 11, height, 0, 29, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 11 }, { 0, 29, height + 2 }); } else { - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 11, height, 29, 0, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 11 }, { 29, 0, height + 2 }); } session->WoodenSupportsPrependTo = ps; @@ -221,21 +221,21 @@ static void paint_go_karts_track_flat_to_25_deg_up( imageId = go_karts_track_pieces_flat_to_25_deg_up[direction][0] | session->TrackColours[SCHEME_TRACK]; if (direction == 0 || direction == 2) { - ps = PaintAddImageAsParent(session, imageId, 0, 0, 32, 28, 1, height, 0, 2, height); + ps = PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 28, 1 }, { 0, 2, height }); } else { - ps = PaintAddImageAsParent(session, imageId, 0, 0, 28, 32, 1, height, 2, 0, height); + ps = PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 28, 32, 1 }, { 2, 0, height }); } imageId = go_karts_track_pieces_flat_to_25_deg_up[direction][1] | session->TrackColours[SCHEME_TRACK]; if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 11, height, 0, 29, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 11 }, { 0, 29, height + 2 }); } else { - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 11, height, 29, 0, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 11 }, { 29, 0, height + 2 }); } session->WoodenSupportsPrependTo = ps; @@ -275,21 +275,21 @@ static void paint_go_karts_track_25_deg_up_to_flat( imageId = go_karts_track_pieces_25_deg_up_to_flat[direction][0] | session->TrackColours[SCHEME_TRACK]; if (direction == 0 || direction == 2) { - ps = PaintAddImageAsParent(session, imageId, 0, 0, 32, 28, 1, height, 0, 2, height); + ps = PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 28, 1 }, { 0, 2, height }); } else { - ps = PaintAddImageAsParent(session, imageId, 0, 0, 28, 32, 1, height, 2, 0, height); + ps = PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 28, 32, 1 }, { 2, 0, height }); } imageId = go_karts_track_pieces_25_deg_up_to_flat[direction][1] | session->TrackColours[SCHEME_TRACK]; if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 11, height, 0, 29, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 11 }, { 0, 29, height + 2 }); } else { - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 11, height, 29, 0, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 11 }, { 29, 0, height + 2 }); } session->WoodenSupportsPrependTo = ps; @@ -365,11 +365,11 @@ static void paint_go_karts_station( imageId = sprites[direction][0] | session->TrackColours[SCHEME_TRACK]; if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 0, 32, 28, 1, height, 0, 2, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 28, 1 }, { 0, 2, height }); } else { - PaintAddImageAsParent(session, imageId, 0, 0, 28, 32, 1, height, 2, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 28, 32, 1 }, { 2, 0, height }); } if (direction == 0 || direction == 2) @@ -386,13 +386,13 @@ static void paint_go_karts_station( imageId = sprites[direction][1] | session->TrackColours[SCHEME_TRACK]; if (direction == 0 || direction == 2) { - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 3, height, 0, 29, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 3 }, { 0, 29, height + 2 }); paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT); } else { - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 3, height, 29, 0, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 3 }, { 29, 0, height + 2 }); paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT); } @@ -417,34 +417,34 @@ static void paint_go_karts_station( case 0: imageId = (hasGreenLight ? SPR_GO_KARTS_START_POLE_GREEN_SW_NE : SPR_GO_KARTS_START_POLE_RED_SW_NE) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 3, 3, 13, height, 1, 1, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 3, 3, 13 }, { 1, 1, height + 4 }); imageId = (hasGreenLight ? SPR_GO_KARTS_START_LIGHTS_GREEN_SW_NE : SPR_GO_KARTS_START_LIGHTS_RED_SW_NE) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 3, 3, 13, height, 1, 28, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 3, 3, 13 }, { 1, 28, height + 4 }); break; case 1: imageId = SPR_GO_KARTS_START_POLE_NW_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 3, 3, 13, height, 1, 28, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 3, 3, 13 }, { 1, 28, height + 4 }); imageId = SPR_GO_KARTS_START_LIGHTS_NW_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 3, 3, 13, height, 28, 28, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 3, 3, 13 }, { 28, 28, height + 4 }); break; case 2: imageId = SPR_GO_KARTS_START_POLE_NE_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 3, 3, 13, height, 28, 1, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 3, 3, 13 }, { 28, 1, height + 4 }); imageId = SPR_GO_KARTS_START_LIGHTS_NE_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 3, 3, 13, height, 28, 28, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 3, 3, 13 }, { 28, 28, height + 4 }); break; case 3: imageId = (hasGreenLight ? SPR_GO_KARTS_START_POLE_GREEN_SE_NW : SPR_GO_KARTS_START_POLE_RED_SE_NW) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 3, 3, 13, height, 1, 1, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 3, 3, 13 }, { 1, 1, height + 4 }); imageId = (hasGreenLight ? SPR_GO_KARTS_START_LIGHTS_GREEN_SE_NW : SPR_GO_KARTS_START_LIGHTS_RED_SE_NW) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 3, 3, 13, height, 28, 1, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 3, 3, 13 }, { 28, 1, height + 4 }); break; } } @@ -466,40 +466,40 @@ static void paint_go_karts_track_left_quarter_turn_1_tile( { case 0: imageId = SPR_GO_KARTS_FLAT_QUARTER_TURN_1_TILE_NW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 28, 1, height, 0, 2, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 28, 1 }, { 0, 2, height }); imageId = SPR_GO_KARTS_FLAT_QUARTER_TURN_1_TILE_EDGE_A_NW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 1, 3, height, 29, 2, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 1, 3 }, { 29, 2, height + 2 }); imageId = SPR_GO_KARTS_FLAT_QUARTER_TURN_1_TILE_EDGE_B_NW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 16, 1, 3, height, 14, 29, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 16, 1, 3 }, { 14, 29, height + 2 }); break; case 1: imageId = SPR_GO_KARTS_FLAT_QUARTER_TURN_1_TILE_NE_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 30, 30, 1, height, 0, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 30, 30, 1 }, { 0, 0, height }); imageId = SPR_GO_KARTS_FLAT_QUARTER_TURN_1_TILE_EDGE_A_NE_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 16, 1, 3, height, 2, 29, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 16, 1, 3 }, { 2, 29, height + 2 }); imageId = SPR_GO_KARTS_FLAT_QUARTER_TURN_1_TILE_EDGE_B_NE_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 16, 3, height, 29, 2, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 16, 3 }, { 29, 2, height + 2 }); break; case 2: imageId = SPR_GO_KARTS_FLAT_QUARTER_TURN_1_TILE_SE_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 28, 32, 1, height, 2, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 28, 32, 1 }, { 2, 0, height }); imageId = SPR_GO_KARTS_FLAT_QUARTER_TURN_1_TILE_EDGE_A_SE_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 1, 3, height, 2, 2, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 1, 3 }, { 2, 2, height + 2 }); imageId = SPR_GO_KARTS_FLAT_QUARTER_TURN_1_TILE_EDGE_B_SE_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 16, 3, height, 29, 14, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 16, 3 }, { 29, 14, height + 2 }); break; case 3: imageId = SPR_GO_KARTS_FLAT_QUARTER_TURN_1_TILE_SW_NW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 32, 1, height, 0, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 32, 1 }, { 0, 0, height }); imageId = SPR_GO_KARTS_FLAT_QUARTER_TURN_1_TILE_EDGE_A_SW_NW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 1, 3, height, 29, 29, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 1, 3 }, { 29, 29, height + 2 }); // The empty sprite isn't drawn break; From db493d157e358a6b35f985eb5cc8db951a3456cc Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 17:12:07 +0200 Subject: [PATCH 18/39] Refactor uses of PaintAddImageAsParent in MiniGolf.cpp --- src/openrct2/ride/gentle/MiniGolf.cpp | 42 +++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/openrct2/ride/gentle/MiniGolf.cpp b/src/openrct2/ride/gentle/MiniGolf.cpp index 6e81c31d47..f59eac2b46 100644 --- a/src/openrct2/ride/gentle/MiniGolf.cpp +++ b/src/openrct2/ride/gentle/MiniGolf.cpp @@ -492,13 +492,13 @@ static void paint_mini_golf_track_flat( if (direction & 1) { imageId = SPR_MINI_GOLF_FLAT_NW_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 20, 32, 1, height, 6, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 20, 32, 1 }, { 6, 0, height }); paint_util_push_tunnel_right(session, height, TUNNEL_PATH_AND_MINI_GOLF); } else { imageId = SPR_MINI_GOLF_FLAT_SW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 20, 1, height, 0, 6, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 20, 1 }, { 0, 6, height }); paint_util_push_tunnel_left(session, height, TUNNEL_PATH_AND_MINI_GOLF); } @@ -511,18 +511,18 @@ static void paint_mini_golf_track_flat( if (direction & 1) { imageId = SPR_MINI_GOLF_FLAT_FENCE_BACK_NW_SE | session->TrackColours[SCHEME_MISC]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 7, height, 10, 0, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 7 }, { 10, 0, height + 2 }); imageId = SPR_MINI_GOLF_FLAT_FENCE_FRONT_NW_SE | session->TrackColours[SCHEME_MISC]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 7, height, 22, 0, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 7 }, { 22, 0, height + 2 }); } else { imageId = SPR_MINI_GOLF_FLAT_FENCE_BACK_SW_NE | session->TrackColours[SCHEME_MISC]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 7, height, 0, 10, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 7 }, { 0, 10, height + 2 }); imageId = SPR_MINI_GOLF_FLAT_FENCE_FRONT_SW_NE | session->TrackColours[SCHEME_MISC]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 7, height, 0, 22, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 7 }, { 0, 22, height + 2 }); } } @@ -700,7 +700,7 @@ static void paint_mini_golf_station( if (hasFence) { imageId = SPR_MINI_GOLF_FLAT_FENCE_FRONT_NW_SE | session->TrackColours[SCHEME_MISC]; - PaintAddImageAsParent(session, imageId, 10, 0, 1, 32, 7, height, 31, 0, height + 2); + PaintAddImageAsParent(session, imageId, { 10, 0, height }, { 1, 32, 7 }, { 31, 0, height + 2 }); } track_paint_util_draw_station_covers(session, EDGE_NE, hasFence, stationObj, height); @@ -723,7 +723,7 @@ static void paint_mini_golf_station( if (hasFence) { imageId = SPR_MINI_GOLF_FLAT_FENCE_FRONT_SW_NE | session->TrackColours[SCHEME_MISC]; - PaintAddImageAsParent(session, imageId, 0, 10, 32, 1, 7, height, 0, 31, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 10, height }, { 32, 1, 7 }, { 0, 31, height + 2 }); } track_paint_util_draw_station_covers(session, EDGE_NW, hasFence, stationObj, height); @@ -806,11 +806,11 @@ static void paint_mini_golf_track_left_quarter_turn_1_tile( { case 0: imageId = SPR_MINI_GOLF_QUARTER_TURN_1_TILE_FENCE_INSIDE_SW_NW | session->TrackColours[SCHEME_MISC]; - PaintAddImageAsParent(session, imageId, 0, 0, 5, 5, 5, height, 24, 0, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 5, 5, 5 }, { 24, 0, height + 2 }); break; case 2: imageId = SPR_MINI_GOLF_QUARTER_TURN_1_TILE_FENCE_INSIDE_NE_SE | session->TrackColours[SCHEME_MISC]; - PaintAddImageAsParent(session, imageId, 0, 0, 5, 5, 5, height, 0, 24, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 5, 5, 5 }, { 0, 24, height + 2 }); break; } } @@ -936,11 +936,11 @@ static void paint_mini_golf_hole_c( { case 0x01: case 0x20: - PaintAddImageAsParent(session, imageId, 0, 0, 2, 26, 3, height, 30, 3, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 26, 3 }, { 30, 3, height + 4 }); break; case 0x10: case 0x31: - PaintAddImageAsParent(session, imageId, 0, 0, 26, 2, 3, height, 3, 30, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 26, 2, 3 }, { 3, 30, height + 4 }); break; default: PaintAddImageAsParent( @@ -1013,17 +1013,17 @@ static void paint_mini_golf_hole_d( { case 0x01: case 0x32: - PaintAddImageAsParent(session, imageId, 0, 0, 2, 26, 3, height, 30, 3, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 26, 3 }, { 30, 3, height + 4 }); break; case 0x02: - PaintAddImageAsParent(session, imageId, 0, 0, 23, 2, 3, height, 3, 30, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 23, 2, 3 }, { 3, 30, height + 4 }); break; case 0x10: - PaintAddImageAsParent(session, imageId, 0, 0, 2, 24, 3, height, 30, 3, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 24, 3 }, { 30, 3, height + 4 }); break; case 0x20: case 0x31: - PaintAddImageAsParent(session, imageId, 0, 0, 26, 2, 3, height, 3, 30, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 26, 2, 3 }, { 3, 30, height + 4 }); break; default: PaintAddImageAsParent( @@ -1105,18 +1105,18 @@ static void paint_mini_golf_hole_e( switch ((direction << 4) | trackSequence) { case 0x01: - PaintAddImageAsParent(session, imageId, 0, 0, 2, 26, 3, height, 30, 3, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 26, 3 }, { 30, 3, height + 4 }); break; case 0x02: case 0x20: case 0x31: - PaintAddImageAsParent(session, imageId, 0, 0, 26, 2, 3, height, 3, 30, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 26, 2, 3 }, { 3, 30, height + 4 }); break; case 0x10: - PaintAddImageAsParent(session, imageId, 0, 0, 2, 24, 3, height, 30, 3, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 24, 3 }, { 30, 3, height + 4 }); break; case 0x32: - PaintAddImageAsParent(session, imageId, 0, 0, 2, 23, 3, height, 30, 3, height + 4); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 23, 3 }, { 30, 3, height + 4 }); break; default: PaintAddImageAsParent( @@ -1274,5 +1274,5 @@ void vehicle_visual_mini_golf_ball( return; uint32_t image_id = rideEntry->vehicles[0].base_image_id; - PaintAddImageAsParent(session, image_id, 0, 0, 1, 1, 0, z, 0, 0, z + 3); + PaintAddImageAsParent(session, image_id, { 0, 0, z }, { 1, 1, 0 }, { 0, 0, z + 3 }); } From 1d3b56a59ec9db6e77f4801910ab1535cf925127 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 17:47:18 +0200 Subject: [PATCH 19/39] Refactor uses of PaintAddImageAsParent in Supports.cpp --- src/openrct2/paint/Supports.cpp | 38 ++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/openrct2/paint/Supports.cpp b/src/openrct2/paint/Supports.cpp index cc94f12f7d..5e977a3bbf 100644 --- a/src/openrct2/paint/Supports.cpp +++ b/src/openrct2/paint/Supports.cpp @@ -1,4 +1,4 @@ -/***************************************************************************** +/***************************************************************************** * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md @@ -521,9 +521,9 @@ bool wooden_a_supports_paint_setup( { imageId += word_97B3C4[slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]; imageId |= imageColourFlags; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 32, 11, z, 0, 0, z + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, z }, { 32, 32, 11 }, { 0, 0, z + 2 }); - PaintAddImageAsParent(session, imageId + 4, 0, 0, 32, 32, 11, z + 16, 0, 0, z + 16 + 2); + PaintAddImageAsParent(session, imageId + 4, { 0, 0, z + 16 }, { 32, 32, 11 }, { 0, 0, z + 16 + 2 }); hasSupports = true; } @@ -552,7 +552,7 @@ bool wooden_a_supports_paint_setup( imageId += word_97B3C4[slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]; imageId |= imageColourFlags; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 32, 11, z, 0, 0, z + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, z }, { 32, 32, 11 }, { 0, 0, z + 2 }); hasSupports = true; } z += 16; @@ -562,7 +562,7 @@ bool wooden_a_supports_paint_setup( if (drawFlatPiece) { int32_t imageId = WoodenSupportImageIds[supportType].flat | imageColourFlags; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 32, 0, z - 2); + PaintAddImageAsParent(session, imageId, { 0, 0, z - 2 }, { 32, 32, 0 }); hasSupports = true; } @@ -574,7 +574,7 @@ bool wooden_a_supports_paint_setup( // Full support int32_t imageId = WoodenSupportImageIds[supportType].full | imageColourFlags; uint8_t ah = height == 2 ? 23 : 28; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 32, ah, z); + PaintAddImageAsParent(session, imageId, { 0, 0, z }, { 32, 32, ah }); hasSupports = true; z += 32; height -= 2; @@ -584,7 +584,7 @@ bool wooden_a_supports_paint_setup( // Half support int32_t imageId = WoodenSupportImageIds[supportType].half | imageColourFlags; uint8_t ah = height == 1 ? 7 : 12; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 32, ah, z); + PaintAddImageAsParent(session, imageId, { 0, 0, z }, { 32, 32, ah }); hasSupports = true; z += 16; height -= 1; @@ -697,7 +697,8 @@ bool wooden_b_supports_paint_setup( { imageId += word_97B3C4[session->Support.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]; - PaintAddImageAsParent(session, imageId | imageColourFlags, 0, 0, 32, 32, 11, baseHeight, 0, 0, baseHeight + 2); + PaintAddImageAsParent( + session, imageId | imageColourFlags, { 0, 0, baseHeight }, { 32, 32, 11 }, { 0, 0, baseHeight + 2 }); baseHeight += 16; PaintAddImageAsParent(session, (imageId + 4) | imageColourFlags, 0, 0, 32, 32, 3, baseHeight, 0, 0, baseHeight + 2); @@ -726,7 +727,8 @@ bool wooden_b_supports_paint_setup( { imageId += word_97B3C4[session->Support.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]; - PaintAddImageAsParent(session, imageId | imageColourFlags, 0, 0, 32, 32, 3, baseHeight, 0, 0, baseHeight + 2); + PaintAddImageAsParent( + session, imageId | imageColourFlags, { 0, 0, baseHeight }, { 32, 32, 3 }, { 0, 0, baseHeight + 2 }); baseHeight += 16; _9E32B1 = true; @@ -743,7 +745,7 @@ bool wooden_b_supports_paint_setup( else { PaintAddImageAsParent( - session, WoodenSupportImageIds[supportType].flat | imageColourFlags, 0, 0, 32, 32, 0, baseHeight - 2); + session, WoodenSupportImageIds[supportType].flat | imageColourFlags, { 0, 0, baseHeight - 2 }, { 32, 32, 0 }); _9E32B1 = true; } } @@ -885,7 +887,7 @@ bool metal_a_supports_paint_setup( uint32_t image_id = _metalSupportTypeToCrossbeamImages[supportType][ebp]; image_id |= imageColourFlags; - PaintAddImageAsParent(session, image_id, xOffset, yOffset, boundBoxLengthX, boundBoxLengthY, 1, height); + PaintAddImageAsParent(session, image_id, { xOffset, yOffset, height }, { boundBoxLengthX, boundBoxLengthY, 1 }); segment = newSegment; } @@ -904,7 +906,7 @@ bool metal_a_supports_paint_setup( image_id += metal_supports_slope_image_map[supportSegments[segment].slope & TILE_ELEMENT_SURFACE_SLOPE_MASK]; image_id |= imageColourFlags; - PaintAddImageAsParent(session, image_id, xOffset, yOffset, 0, 0, 5, supportSegments[segment].height); + PaintAddImageAsParent(session, image_id, { xOffset, yOffset, supportSegments[segment].height }, { 0, 0, 5 }); height = supportSegments[segment].height + 6; } @@ -928,7 +930,7 @@ bool metal_a_supports_paint_setup( image_id += heightDiff - 1; image_id |= imageColourFlags; - PaintAddImageAsParent(session, image_id, xOffset, yOffset, 0, 0, heightDiff - 1, height); + PaintAddImageAsParent(session, image_id, { xOffset, yOffset, height }, { 0, 0, heightDiff - 1 }); } height += heightDiff; @@ -959,7 +961,7 @@ bool metal_a_supports_paint_setup( if (count == 3 && z == 0x10) image_id++; - PaintAddImageAsParent(session, image_id, xOffset, yOffset, 0, 0, z - 1, height); + PaintAddImageAsParent(session, image_id, { xOffset, yOffset, height }, { 0, 0, z - 1 }); height += z; } @@ -1001,7 +1003,8 @@ bool metal_a_supports_paint_setup( image_id |= imageColourFlags; PaintAddImageAsParent( - session, image_id, xOffset, yOffset, 0, 0, 0, height, boundBoxOffset.x, boundBoxOffset.y, boundBoxOffset.z); + session, image_id, { xOffset, yOffset, height }, { 0, 0, 0 }, + { boundBoxOffset.x, boundBoxOffset.y, boundBoxOffset.z }); height += z; } @@ -1252,7 +1255,8 @@ bool path_a_supports_paint_setup( uint32_t imageId = (supportType * 24) + word_97B3C4[session->Support.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK] + railingEntry->bridge_image; - PaintAddImageAsParent(session, imageId | imageColourFlags, 0, 0, 32, 32, 11, baseHeight, 0, 0, baseHeight + 2); + PaintAddImageAsParent( + session, imageId | imageColourFlags, { 0, 0, baseHeight }, { 32, 32, 11 }, { 0, 0, baseHeight + 2 }); baseHeight += 16; PaintAddImageAsParent(session, (imageId + 4) | imageColourFlags, 0, 0, 32, 32, 11, baseHeight, 0, 0, baseHeight + 2); @@ -1273,7 +1277,7 @@ bool path_a_supports_paint_setup( uint32_t ebx = (supportType * 24) + word_97B3C4[session->Support.slope & TILE_ELEMENT_SURFACE_SLOPE_MASK] + railingEntry->bridge_image; - PaintAddImageAsParent(session, ebx | imageColourFlags, 0, 0, 32, 32, 11, baseHeight, 0, 0, baseHeight + 2); + PaintAddImageAsParent(session, ebx | imageColourFlags, { 0, 0, baseHeight }, { 32, 32, 11 }, { 0, 0, baseHeight + 2 }); hasSupports = true; baseHeight += 16; From 0aa15748f66b34da88260c709b0ab916f5dfc5ff Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 17:48:57 +0200 Subject: [PATCH 20/39] Refactor uses of PaintAddImageAsParent in JuniorRollerCoaster.cpp --- .../ride/coaster/JuniorRollerCoaster.cpp | 92 +++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/src/openrct2/ride/coaster/JuniorRollerCoaster.cpp b/src/openrct2/ride/coaster/JuniorRollerCoaster.cpp index feb8a99dbc..c78eed4ea0 100644 --- a/src/openrct2/ride/coaster/JuniorRollerCoaster.cpp +++ b/src/openrct2/ride/coaster/JuniorRollerCoaster.cpp @@ -1651,7 +1651,7 @@ void junior_rc_paint_station( { // height -= 2 (height - 2) imageId = SPR_STATION_BASE_B_SW_NE | session->TrackColours[SCHEME_MISC]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 28, 1, height - 2, 0, 2, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height - 2 }, { 32, 28, 1 }, { 0, 2, height }); // height += 2 (height) if (tileElement->AsTrack()->GetTrackType() == TrackElemType::EndStation && rideType == RIDE_TYPE_JUNIOR_ROLLER_COASTER) @@ -1673,7 +1673,7 @@ void junior_rc_paint_station( { // height -= 2 (height - 2) imageId = SPR_STATION_BASE_B_NW_SE | session->TrackColours[SCHEME_MISC]; - PaintAddImageAsParent(session, imageId, 0, 0, 28, 32, 1, height - 2, 2, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height - 2 }, { 28, 32, 1 }, { 2, 0, height }); // height += 2 (height) if (tileElement->AsTrack()->GetTrackType() == TrackElemType::EndStation && rideType == RIDE_TYPE_JUNIOR_ROLLER_COASTER) @@ -1897,13 +1897,13 @@ static void junior_rc_flat_to_left_bank_paint_setup( image_id = junior_rc_track_pieces_flat_to_left_bank[direction][0] | session->TrackColours[SCHEME_TRACK]; if (direction & 1) { - PaintAddImageAsParent(session, image_id, 0, 0, 20, 32, 1, height, 6, 0, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 20, 32, 1 }, { 6, 0, height }); paint_util_push_tunnel_right(session, height, 0); } else { - PaintAddImageAsParent(session, image_id, 0, 0, 32, 20, 1, height, 0, 6, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 32, 20, 1 }, { 0, 6, height }); paint_util_push_tunnel_left(session, height, 0); } @@ -1914,11 +1914,11 @@ static void junior_rc_flat_to_left_bank_paint_setup( if (direction & 1) { - PaintAddImageAsParent(session, image_id, 0, 0, 1, 32, 26, height, 27, 0, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 1, 32, 26 }, { 27, 0, height }); } else { - PaintAddImageAsParent(session, image_id, 0, 0, 32, 1, 26, height, 0, 27, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 32, 1, 26 }, { 0, 27, height }); } } @@ -1945,13 +1945,13 @@ static void junior_rc_flat_to_right_bank_paint_setup( image_id = junior_rc_track_pieces_flat_to_right_bank[direction][0] | session->TrackColours[SCHEME_TRACK]; if (direction & 1) { - PaintAddImageAsParent(session, image_id, 0, 0, 20, 32, 1, height, 6, 0, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 20, 32, 1 }, { 6, 0, height }); paint_util_push_tunnel_right(session, height, 0); } else { - PaintAddImageAsParent(session, image_id, 0, 0, 32, 20, 1, height, 0, 6, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 32, 20, 1 }, { 0, 6, height }); paint_util_push_tunnel_left(session, height, 0); } @@ -1962,11 +1962,11 @@ static void junior_rc_flat_to_right_bank_paint_setup( if (direction & 1) { - PaintAddImageAsParent(session, image_id, 0, 0, 1, 32, 26, height, 27, 0, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 1, 32, 26 }, { 27, 0, height }); } else { - PaintAddImageAsParent(session, image_id, 0, 0, 32, 1, 26, height, 0, 27, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 32, 1, 26 }, { 0, 27, height }); } } @@ -2075,12 +2075,12 @@ static void junior_rc_banked_right_quarter_turn_5_tiles_paint_setup( if (direction == 1 && trackSequence == 6) { uint32_t imageId = SPR_JUNIOR_RC_BANKED_QUARTER_TURN_5_TILES_NW_SW_PART_4_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 26, height, 0, 27, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 26 }, { 0, 27, height }); } else if (direction == 3 && trackSequence == 0) { uint32_t imageId = SPR_JUNIOR_RC_BANKED_QUARTER_TURN_5_TILES_SE_NE_PART_0_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 26, height, 27, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 26 }, { 27, 0, height }); } int32_t supportHeight = height; @@ -2173,11 +2173,11 @@ static void junior_rc_left_bank_to_25_deg_up_paint_setup( image_id = junior_rc_track_pieces_left_banked_to_25_deg_up[direction][0] | session->TrackColours[SCHEME_TRACK]; if (direction & 1) { - PaintAddImageAsParent(session, image_id, 0, 0, 20, 32, 1, height, 6, 0, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 20, 32, 1 }, { 6, 0, height }); } else { - PaintAddImageAsParent(session, image_id, 0, 0, 32, 20, 1, height, 0, 6, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 32, 20, 1 }, { 0, 6, height }); } if (junior_rc_track_pieces_left_banked_to_25_deg_up[direction][1] != 0) @@ -2186,11 +2186,11 @@ static void junior_rc_left_bank_to_25_deg_up_paint_setup( if (direction & 1) { - PaintAddImageAsParent(session, image_id, 0, 0, 1, 32, 34, height, 27, 0, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 1, 32, 34 }, { 27, 0, height }); } else { - PaintAddImageAsParent(session, image_id, 0, 0, 32, 1, 34, height, 0, 27, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 32, 1, 34 }, { 0, 27, height }); } } @@ -2233,11 +2233,11 @@ static void junior_rc_right_bank_to_25_deg_up_paint_setup( image_id = junior_rc_track_pieces_right_banked_to_25_deg_up[direction][0] | session->TrackColours[SCHEME_TRACK]; if (direction & 1) { - PaintAddImageAsParent(session, image_id, 0, 0, 20, 32, 1, height, 6, 0, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 20, 32, 1 }, { 6, 0, height }); } else { - PaintAddImageAsParent(session, image_id, 0, 0, 32, 20, 1, height, 0, 6, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 32, 20, 1 }, { 0, 6, height }); } if (junior_rc_track_pieces_right_banked_to_25_deg_up[direction][1] != 0) @@ -2246,11 +2246,11 @@ static void junior_rc_right_bank_to_25_deg_up_paint_setup( if (direction & 1) { - PaintAddImageAsParent(session, image_id, 0, 0, 1, 32, 34, height, 27, 0, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 1, 32, 34 }, { 27, 0, height }); } else { - PaintAddImageAsParent(session, image_id, 0, 0, 32, 1, 34, height, 0, 27, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 32, 1, 34 }, { 0, 27, height }); } } @@ -2306,13 +2306,13 @@ static void junior_rc_25_deg_up_to_left_bank_paint_setup( image_id = junior_rc_track_pieces_25_deg_up_to_left_bank[direction][0] | session->TrackColours[SCHEME_TRACK]; if (direction & 1) { - PaintAddImageAsParent(session, image_id, 0, 0, 20, 32, 1, height, 6, 0, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 20, 32, 1 }, { 6, 0, height }); paint_util_push_tunnel_right(session, tunnelHeight, tunnelType); } else { - PaintAddImageAsParent(session, image_id, 0, 0, 32, 20, 1, height, 0, 6, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 32, 20, 1 }, { 0, 6, height }); paint_util_push_tunnel_left(session, tunnelHeight, tunnelType); } @@ -2323,11 +2323,11 @@ static void junior_rc_25_deg_up_to_left_bank_paint_setup( if (direction & 1) { - PaintAddImageAsParent(session, image_id, 0, 0, 1, 32, 34, height, 27, 0, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 1, 32, 34 }, { 27, 0, height }); } else { - PaintAddImageAsParent(session, image_id, 0, 0, 32, 1, 34, height, 0, 27, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 32, 1, 34 }, { 0, 27, height }); } } @@ -2367,13 +2367,13 @@ static void junior_rc_25_deg_up_to_right_bank_paint_setup( image_id = junior_rc_track_pieces_25_deg_up_to_right_bank[direction][0] | session->TrackColours[SCHEME_TRACK]; if (direction & 1) { - PaintAddImageAsParent(session, image_id, 0, 0, 20, 32, 1, height, 6, 0, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 20, 32, 1 }, { 6, 0, height }); paint_util_push_tunnel_right(session, tunnelHeight, tunnelType); } else { - PaintAddImageAsParent(session, image_id, 0, 0, 32, 20, 1, height, 0, 6, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 32, 20, 1 }, { 0, 6, height }); paint_util_push_tunnel_left(session, tunnelHeight, tunnelType); } @@ -2384,11 +2384,11 @@ static void junior_rc_25_deg_up_to_right_bank_paint_setup( if (direction & 1) { - PaintAddImageAsParent(session, image_id, 0, 0, 1, 32, 34, height, 27, 0, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 1, 32, 34 }, { 27, 0, height }); } else { - PaintAddImageAsParent(session, image_id, 0, 0, 32, 1, 34, height, 0, 27, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 32, 1, 34 }, { 0, 27, height }); } } @@ -3027,12 +3027,12 @@ static void junior_rc_right_quarter_turn_3_tiles_bank_paint_setup( if (direction == 1 && trackSequence == 3) { uint32_t imageId = SPR_JUNIOR_RC_BANKED_QUARTER_TURN_3_TILES_NW_SW_PART_2_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 26, height, 0, 27, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 26 }, { 0, 27, height }); } else if (direction == 3 && trackSequence == 0) { uint32_t imageId = SPR_JUNIOR_RC_BANKED_QUARTER_TURN_3_TILES_SE_NE_PART_0_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 26, height, 27, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 26 }, { 27, 0, height }); } uint8_t supportType[2][4] = { { 1, 0, 0, 2 }, { 2, 0, 0, 1 } }; @@ -3659,13 +3659,13 @@ static void junior_rc_brake_paint_setup( image_id = junior_rc_track_pieces_brake[direction] | session->TrackColours[SCHEME_TRACK]; if (direction & 1) { - PaintAddImageAsParent(session, image_id, 6, 0, 20, 32, 1, height); + PaintAddImageAsParent(session, image_id, { 6, 0, height }, { 20, 32, 1 }); paint_util_push_tunnel_right(session, height, TUNNEL_0); } else { - PaintAddImageAsParent(session, image_id, 0, 6, 32, 20, 1, height); + PaintAddImageAsParent(session, image_id, { 0, 6, height }, { 32, 20, 1 }); paint_util_push_tunnel_left(session, height, TUNNEL_0); } @@ -3695,13 +3695,13 @@ static void junior_rc_block_brake_paint_setup( image_id = junior_rc_track_pieces_block_brake[isBraked][direction] | session->TrackColours[SCHEME_TRACK]; if (direction & 1) { - PaintAddImageAsParent(session, image_id, 6, 0, 20, 32, 1, height); + PaintAddImageAsParent(session, image_id, { 6, 0, height }, { 20, 32, 1 }); paint_util_push_tunnel_right(session, height, TUNNEL_0); } else { - PaintAddImageAsParent(session, image_id, 0, 6, 32, 20, 1, height); + PaintAddImageAsParent(session, image_id, { 0, 6, height }, { 32, 20, 1 }); paint_util_push_tunnel_left(session, height, TUNNEL_0); } @@ -4562,7 +4562,7 @@ static void junior_rc_diag_flat_to_left_bank_paint_setup( { uint32_t imageId = SPR_JUNIOR_RC_DIAG_FLAT_TO_LEFT_BANK_W_E_PART_0_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, -16, -16, 32, 32, 0, height, -16, -16, height + 27); + PaintAddImageAsParent(session, imageId, { -16, -16, height }, { 32, 32, 0 }, { -16, -16, height + 27 }); } if (trackSequence == 3) { @@ -4589,7 +4589,7 @@ static void junior_rc_diag_flat_to_right_bank_paint_setup( { uint32_t imageId = SPR_JUNIOR_RC_DIAG_FLAT_TO_RIGHT_BANK_E_W_PART_0_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, -16, -16, 32, 32, 0, height, -16, -16, height + 27); + PaintAddImageAsParent(session, imageId, { -16, -16, height }, { 32, 32, 0 }, { -16, -16, height + 27 }); } if (trackSequence == 3) { @@ -4616,7 +4616,7 @@ static void junior_rc_diag_left_bank_to_flat_paint_setup( { uint32_t imageId = SPR_JUNIOR_RC_DIAG_FLAT_TO_RIGHT_BANK_E_W_PART_0_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, -16, -16, 32, 32, 0, height, -16, -16, height + 27); + PaintAddImageAsParent(session, imageId, { -16, -16, height }, { 32, 32, 0 }, { -16, -16, height + 27 }); } if (trackSequence == 3) { @@ -4643,7 +4643,7 @@ static void junior_rc_diag_right_bank_to_flat_paint_setup( { uint32_t imageId = SPR_JUNIOR_RC_DIAG_FLAT_TO_LEFT_BANK_W_E_PART_0_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, -16, -16, 32, 32, 0, height, -16, -16, height + 27); + PaintAddImageAsParent(session, imageId, { -16, -16, height }, { 32, 32, 0 }, { -16, -16, height + 27 }); } if (trackSequence == 3) { @@ -4670,7 +4670,7 @@ static void junior_rc_diag_left_bank_to_25_deg_up_paint_setup( { uint32_t imageId = SPR_JUNIOR_RC_DIAG_LEFT_BANK_TO_25_DEG_UP_W_E_PART_0_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, -16, -16, 32, 32, 0, height, -16, -16, height + 35); + PaintAddImageAsParent(session, imageId, { -16, -16, height }, { 32, 32, 0 }, { -16, -16, height + 35 }); } if (trackSequence == 3) { @@ -4697,7 +4697,7 @@ static void junior_rc_diag_right_bank_to_25_deg_up_paint_setup( { uint32_t imageId = SPR_JUNIOR_RC_DIAG_RIGHT_BANK_TO_25_DEG_UP_E_W_PART_0_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, -16, -16, 32, 32, 0, height, -16, -16, height + 35); + PaintAddImageAsParent(session, imageId, { -16, -16, height }, { 32, 32, 0 }, { -16, -16, height + 35 }); } if (trackSequence == 3) { @@ -4724,7 +4724,7 @@ static void junior_rc_diag_25_deg_up_to_left_bank_paint_setup( { uint32_t imageId = SPR_JUNIOR_RC_DIAG_25_DEG_UP_TO_LEFT_BANK_W_E_PART_0_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, -16, -16, 32, 32, 0, height, -16, -16, height + 35); + PaintAddImageAsParent(session, imageId, { -16, -16, height }, { 32, 32, 0 }, { -16, -16, height + 35 }); } if (trackSequence == 3) { @@ -4751,7 +4751,7 @@ static void junior_rc_diag_25_deg_up_to_right_bank_paint_setup( { uint32_t imageId = SPR_JUNIOR_RC_DIAG_25_DEG_UP_TO_RIGHT_BANK_E_W_PART_0_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, -16, -16, 32, 32, 0, height, -16, -16, height + 35); + PaintAddImageAsParent(session, imageId, { -16, -16, height }, { 32, 32, 0 }, { -16, -16, height + 35 }); } if (trackSequence == 3) { @@ -4778,7 +4778,7 @@ static void junior_rc_diag_left_bank_to_25_deg_down_paint_setup( { uint32_t imageId = SPR_JUNIOR_RC_DIAG_25_DEG_UP_TO_RIGHT_BANK_E_W_PART_0_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, -16, -16, 32, 32, 0, height, -16, -16, height + 35); + PaintAddImageAsParent(session, imageId, { -16, -16, height }, { 32, 32, 0 }, { -16, -16, height + 35 }); } if (trackSequence == 3) { @@ -4805,7 +4805,7 @@ static void junior_rc_diag_right_bank_to_25_deg_down_paint_setup( { uint32_t imageId = SPR_JUNIOR_RC_DIAG_25_DEG_UP_TO_LEFT_BANK_W_E_PART_0_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, -16, -16, 32, 32, 0, height, -16, -16, height + 35); + PaintAddImageAsParent(session, imageId, { -16, -16, height }, { 32, 32, 0 }, { -16, -16, height + 35 }); } if (trackSequence == 3) { @@ -4832,7 +4832,7 @@ static void junior_rc_diag_25_deg_down_to_left_bank_paint_setup( { uint32_t imageId = SPR_JUNIOR_RC_DIAG_RIGHT_BANK_TO_25_DEG_UP_E_W_PART_0_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, -16, -16, 32, 32, 0, height, -16, -16, height + 35); + PaintAddImageAsParent(session, imageId, { -16, -16, height }, { 32, 32, 0 }, { -16, -16, height + 35 }); } if (trackSequence == 3) { @@ -4859,7 +4859,7 @@ static void junior_rc_diag_25_deg_down_to_right_bank_paint_setup( { uint32_t imageId = SPR_JUNIOR_RC_DIAG_LEFT_BANK_TO_25_DEG_UP_W_E_PART_0_2 | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, -16, -16, 32, 32, 0, height, -16, -16, height + 35); + PaintAddImageAsParent(session, imageId, { -16, -16, height }, { 32, 32, 0 }, { -16, -16, height + 35 }); } if (trackSequence == 3) { From b7b5cb4f675795fe2f88b38e8d19df8d3ec072b7 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 17:51:44 +0200 Subject: [PATCH 21/39] Refactor uses of PaintAddImageAsParent in RiverRapids.cpp --- src/openrct2/ride/water/RiverRapids.cpp | 120 ++++++++++++------------ 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/src/openrct2/ride/water/RiverRapids.cpp b/src/openrct2/ride/water/RiverRapids.cpp index 183c8d605b..b2b215d6f3 100644 --- a/src/openrct2/ride/water/RiverRapids.cpp +++ b/src/openrct2/ride/water/RiverRapids.cpp @@ -285,21 +285,21 @@ static void paint_river_rapids_track_flat( { imageId = (direction == 1 ? SPR_RIVER_RAPIDS_FLAT_NW_SE : SPR_RIVER_RAPIDS_FLAT_SE_NW) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 24, 32, 11, height, 4, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 24, 32, 11 }, { 4, 0, height }); imageId = (direction == 1 ? SPR_RIVER_RAPIDS_FLAT_FRONT_NW_SE : SPR_RIVER_RAPIDS_FLAT_FRONT_SE_NW) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 3, height, 27, 0, height + 17); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 3 }, { 27, 0, height + 17 }); } else { imageId = (direction == 0 ? SPR_RIVER_RAPIDS_FLAT_SW_NE : SPR_RIVER_RAPIDS_FLAT_NE_SW) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 24, 11, height, 0, 4, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 24, 11 }, { 0, 4, height }); imageId = (direction == 0 ? SPR_RIVER_RAPIDS_FLAT_FRONT_SW_NE : SPR_RIVER_RAPIDS_FLAT_FRONT_NE_SW) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 3, height, 0, 27, height + 17); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 3 }, { 0, 27, height + 17 }); } wooden_a_supports_paint_setup(session, (direction & 1), 0, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); @@ -339,10 +339,10 @@ static void paint_river_rapids_track_25_deg( { case 0: imageId = sprites[direction][0] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 24, 4, height, 0, 4, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 24, 4 }, { 0, 4, height }); imageId = sprites[direction][1] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 34, height, 0, 27, height + 16); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 34 }, { 0, 27, height + 16 }); wooden_a_supports_paint_setup(session, 0, 9, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); paint_util_push_tunnel_left(session, height - 8, TUNNEL_SQUARE_7); @@ -350,11 +350,11 @@ static void paint_river_rapids_track_25_deg( case 1: imageId = sprites[direction][0] | session->TrackColours[SCHEME_TRACK]; - ps = PaintAddImageAsParent(session, imageId, 0, 0, 24, 32, 4, height, 4, 0, height); + ps = PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 24, 32, 4 }, { 4, 0, height }); session->WoodenSupportsPrependTo = ps; imageId = sprites[direction][1] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 34, height, 27, 0, height + 16); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 34 }, { 27, 0, height + 16 }); wooden_a_supports_paint_setup(session, 1, 10, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_8); @@ -362,11 +362,11 @@ static void paint_river_rapids_track_25_deg( case 2: imageId = sprites[direction][0] | session->TrackColours[SCHEME_TRACK]; - ps = PaintAddImageAsParent(session, imageId, 0, 0, 32, 24, 4, height, 0, 4, height); + ps = PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 24, 4 }, { 0, 4, height }); session->WoodenSupportsPrependTo = ps; imageId = sprites[direction][1] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 34, height, 0, 27, height + 16); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 34 }, { 0, 27, height + 16 }); wooden_a_supports_paint_setup(session, 0, 11, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_8); @@ -374,10 +374,10 @@ static void paint_river_rapids_track_25_deg( case 3: imageId = sprites[direction][0] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 24, 32, 4, height, 4, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 24, 32, 4 }, { 4, 0, height }); imageId = sprites[direction][1] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 34, height, 27, 0, height + 16); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 34 }, { 27, 0, height + 16 }); wooden_a_supports_paint_setup(session, 1, 12, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); paint_util_push_tunnel_right(session, height - 8, TUNNEL_SQUARE_7); @@ -398,10 +398,10 @@ static void paint_river_rapids_track_25_deg_to_flat_a( { case 0: imageId = sprites[direction][0] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 24, 4, height, 0, 4, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 24, 4 }, { 0, 4, height }); imageId = sprites[direction][1] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 18, height, 0, 27, height + 16); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 18 }, { 0, 27, height + 16 }); wooden_a_supports_paint_setup(session, 0, 5, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); paint_util_push_tunnel_left(session, height - 8, TUNNEL_SQUARE_FLAT); @@ -409,11 +409,11 @@ static void paint_river_rapids_track_25_deg_to_flat_a( case 1: imageId = sprites[direction][0] | session->TrackColours[SCHEME_TRACK]; - ps = PaintAddImageAsParent(session, imageId, 0, 0, 24, 32, 4, height, 4, 0, height); + ps = PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 24, 32, 4 }, { 4, 0, height }); session->WoodenSupportsPrependTo = ps; imageId = sprites[direction][1] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 18, height, 27, 0, height + 16); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 18 }, { 27, 0, height + 16 }); wooden_a_supports_paint_setup(session, 1, 6, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); paint_util_push_tunnel_right(session, height + 8, TUNNEL_14); @@ -421,11 +421,11 @@ static void paint_river_rapids_track_25_deg_to_flat_a( case 2: imageId = sprites[direction][0] | session->TrackColours[SCHEME_TRACK]; - ps = PaintAddImageAsParent(session, imageId, 0, 0, 32, 24, 4, height, 0, 4, height); + ps = PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 24, 4 }, { 0, 4, height }); session->WoodenSupportsPrependTo = ps; imageId = sprites[direction][1] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 18, height, 0, 27, height + 16); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 18 }, { 0, 27, height + 16 }); wooden_a_supports_paint_setup(session, 0, 7, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); paint_util_push_tunnel_left(session, height + 8, TUNNEL_14); @@ -433,10 +433,10 @@ static void paint_river_rapids_track_25_deg_to_flat_a( case 3: imageId = sprites[direction][0] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 24, 32, 4, height, 4, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 24, 32, 4 }, { 4, 0, height }); imageId = sprites[direction][1] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 18, height, 27, 0, height + 16); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 18 }, { 27, 0, height + 16 }); wooden_a_supports_paint_setup(session, 1, 8, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); paint_util_push_tunnel_right(session, height - 8, TUNNEL_SQUARE_FLAT); @@ -457,10 +457,10 @@ static void paint_river_rapids_track_25_deg_to_flat_b( { case 0: imageId = sprites[direction][0] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 24, 11, height, 0, 4, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 24, 11 }, { 0, 4, height }); imageId = sprites[direction][1] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 26, height, 0, 27, height + 16); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 26 }, { 0, 27, height + 16 }); wooden_a_supports_paint_setup(session, 0, 1, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT); @@ -468,11 +468,11 @@ static void paint_river_rapids_track_25_deg_to_flat_b( case 1: imageId = sprites[direction][0] | session->TrackColours[SCHEME_TRACK]; - ps = PaintAddImageAsParent(session, imageId, 0, 0, 24, 32, 11, height, 4, 0, height); + ps = PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 24, 32, 11 }, { 4, 0, height }); session->WoodenSupportsPrependTo = ps; imageId = sprites[direction][1] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 26, height, 27, 0, height + 16); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 26 }, { 27, 0, height + 16 }); wooden_a_supports_paint_setup(session, 1, 2, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_8); @@ -480,11 +480,11 @@ static void paint_river_rapids_track_25_deg_to_flat_b( case 2: imageId = sprites[direction][0] | session->TrackColours[SCHEME_TRACK]; - ps = PaintAddImageAsParent(session, imageId, 0, 0, 32, 24, 11, height, 0, 4, height); + ps = PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 24, 11 }, { 0, 4, height }); session->WoodenSupportsPrependTo = ps; imageId = sprites[direction][1] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 26, height, 0, 27, height + 16); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 26 }, { 0, 27, height + 16 }); wooden_a_supports_paint_setup(session, 0, 3, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_8); @@ -492,10 +492,10 @@ static void paint_river_rapids_track_25_deg_to_flat_b( case 3: imageId = sprites[direction][0] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 24, 32, 11, height, 4, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 24, 32, 11 }, { 4, 0, height }); imageId = sprites[direction][1] | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 26, height, 27, 0, height + 16); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 26 }, { 27, 0, height + 16 }); wooden_a_supports_paint_setup(session, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT); @@ -566,41 +566,41 @@ static void paint_river_rapids_track_left_quarter_turn_1_tile( { case 0: imageId = SPR_RIVER_RAPIDS_LEFT_QUARTER_TURN_1_TILE_SW_NW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 28, 26, 11, height, 4, 2, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 28, 26, 11 }, { 4, 2, height }); imageId = SPR_RIVER_RAPIDS_LEFT_QUARTER_TURN_1_TILE_FRONT_SW_NW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 2, 1, 7, height, 28, 27, height + 13); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 1, 7 }, { 28, 27, height + 13 }); paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT); break; case 1: imageId = SPR_RIVER_RAPIDS_LEFT_QUARTER_TURN_1_TILE_NW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 28, 28, 11, height, 0, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 28, 28, 11 }, { 0, 0, height }); imageId = SPR_RIVER_RAPIDS_QUARTER_TURN_1_TILE_FRONT_LEFT_NW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 30, 7, height, 27, 1, height + 13); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 30, 7 }, { 27, 1, height + 13 }); imageId = SPR_RIVER_RAPIDS_QUARTER_TURN_1_TILE_FRONT_RIGHT_NW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 30, 1, 7, height, 1, 27, height + 13); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 30, 1, 7 }, { 1, 27, height + 13 }); break; case 2: imageId = SPR_RIVER_RAPIDS_LEFT_QUARTER_TURN_1_TILE_NE_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 26, 28, 11, height, 2, 4, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 26, 28, 11 }, { 2, 4, height }); imageId = SPR_RIVER_RAPIDS_LEFT_QUARTER_TURN_1_TILE_FRONT_NE_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 2, 7, height, 27, 28, height + 13); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 2, 7 }, { 27, 28, height + 13 }); paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT); break; case 3: imageId = SPR_RIVER_RAPIDS_LEFT_QUARTER_TURN_1_TILE_SE_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 28, 28, 11, height, 4, 4, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 28, 28, 11 }, { 4, 4, height }); imageId = SPR_RIVER_RAPIDS_LEFT_QUARTER_TURN_1_TILE_FRONT_SE_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 1, 7, height, 28, 28, height + 13); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 1, 7 }, { 28, 28, height + 13 }); paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT); paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT); @@ -623,10 +623,10 @@ static void paint_river_rapids_track_right_quarter_turn_1_tile( { case 0: imageId = SPR_RIVER_RAPIDS_RIGHT_QUARTER_TURN_1_TILE_SW_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 28, 28, 11, height, 4, 4, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 28, 28, 11 }, { 4, 4, height }); imageId = SPR_RIVER_RAPIDS_RIGHT_QUARTER_TURN_1_TILE_FRONT_SW_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 1, 7, height, 28, 28, height + 13); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 1, 7 }, { 28, 28, height + 13 }); paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT); paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT); @@ -634,31 +634,31 @@ static void paint_river_rapids_track_right_quarter_turn_1_tile( case 1: imageId = SPR_RIVER_RAPIDS_RIGHT_QUARTER_TURN_1_TILE_SE_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 28, 26, 11, height, 4, 2, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 28, 26, 11 }, { 4, 2, height }); imageId = SPR_RIVER_RAPIDS_RIGHT_QUARTER_TURN_1_TILE_FRONT_SE_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 2, 1, 7, height, 28, 27, height + 13); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 2, 1, 7 }, { 28, 27, height + 13 }); paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT); break; case 2: imageId = SPR_RIVER_RAPIDS_RIGHT_QUARTER_TURN_1_TILE_NE_NW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 28, 28, 11, height, 0, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 28, 28, 11 }, { 0, 0, height }); imageId = SPR_RIVER_RAPIDS_QUARTER_TURN_1_TILE_FRONT_LEFT_NW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 30, 7, height, 27, 1, height + 13); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 30, 7 }, { 27, 1, height + 13 }); imageId = SPR_RIVER_RAPIDS_QUARTER_TURN_1_TILE_FRONT_RIGHT_NW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 30, 1, 7, height, 1, 27, height + 13); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 30, 1, 7 }, { 1, 27, height + 13 }); break; case 3: imageId = SPR_RIVER_RAPIDS_RIGHT_QUARTER_TURN_1_TILE_NW_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 26, 28, 11, height, 2, 4, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 26, 28, 11 }, { 2, 4, height }); imageId = SPR_RIVER_RAPIDS_RIGHT_QUARTER_TURN_1_TILE_FRONT_NW_SW | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 28, 7, height, 27, 2, height + 13); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 28, 7 }, { 27, 2, height + 13 }); paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT); break; @@ -682,17 +682,17 @@ static void paint_river_rapids_track_waterfall( { imageId = (direction == 1 ? SPR_RIVER_RAPIDS_WATERFALL_NW_SE : SPR_RIVER_RAPIDS_WATERFALL_SE_NW) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 24, 32, 11, height, 4, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 24, 32, 11 }, { 4, 0, height }); imageId = (SPR_RIVER_RAPIDS_WATERFALL_BASE_NE_FRAME_0 + frameNum) | session->TrackColours[SCHEME_TRACK]; PaintAddImageAsChild(session, imageId, { 0, 0, height }, { 24, 32, 11 }, { 4, 0, height }); imageId = (SPR_RIVER_RAPIDS_WATERFALL_TOP_NE_FRAME_0 + frameNum) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 27, height, 4, 0, height + 17); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 27 }, { 4, 0, height + 17 }); imageId = (direction == 1 ? SPR_RIVER_RAPIDS_WATERFALL_FRONT_NW_SE : SPR_RIVER_RAPIDS_WATERFALL_FRONT_SE_NW) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 27, height, 27, 0, height + 17); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 27 }, { 27, 0, height + 17 }); imageId = (SPR_RIVER_RAPIDS_WATERFALL_SIDE_SW_FRAME_0 + frameNum) | session->TrackColours[SCHEME_TRACK]; PaintAddImageAsChild(session, imageId, { 0, 0, height }, { 1, 32, 27 }, { 27, 0, height + 17 }); @@ -701,17 +701,17 @@ static void paint_river_rapids_track_waterfall( { imageId = (direction == 0 ? SPR_RIVER_RAPIDS_WATERFALL_SW_NE : SPR_RIVER_RAPIDS_WATERFALL_NE_SW) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 24, 11, height, 0, 4, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 24, 11 }, { 0, 4, height }); imageId = (SPR_RIVER_RAPIDS_WATERFALL_BASE_NW_FRAME_0 + frameNum) | session->TrackColours[SCHEME_TRACK]; PaintAddImageAsChild(session, imageId, { 0, 0, height }, { 32, 24, 11 }, { 0, 4, height }); imageId = (SPR_RIVER_RAPIDS_WATERFALL_TOP_NW_FRAME_0 + frameNum) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 27, height, 0, 4, height + 17); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 27 }, { 0, 4, height + 17 }); imageId = (direction == 0 ? SPR_RIVER_RAPIDS_WATERFALL_FRONT_SW_NE : SPR_RIVER_RAPIDS_WATERFALL_FRONT_NE_SW) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 27, height, 0, 27, height + 17); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 27 }, { 0, 27, height + 17 }); imageId = (SPR_RIVER_RAPIDS_WATERFALL_SIDE_SE_FRAME_0 + frameNum) | session->TrackColours[SCHEME_TRACK]; PaintAddImageAsChild(session, imageId, { 0, 0, height }, { 32, 1, 27 }, { 0, 27, height + 17 }); @@ -744,18 +744,18 @@ static void paint_river_rapids_track_rapids( if (direction & 1) { imageId = (SPR_RIVER_RAPIDS_RAPIDS_NW_SE_FRAME_0 + frameNum) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 24, 32, 11, height, 4, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 24, 32, 11 }, { 4, 0, height }); imageId = SPR_RIVER_RAPIDS_RAPIDS_FRONT_NW_SE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 11, height, 27, 0, height + 17); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 11 }, { 27, 0, height + 17 }); } else { imageId = (SPR_RIVER_RAPIDS_RAPIDS_SW_NE_FRAME_0 + frameNum) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 24, 11, height, 0, 4, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 24, 11 }, { 0, 4, height }); imageId = SPR_RIVER_RAPIDS_RAPIDS_FRONT_SW_NE | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 11, height, 0, 27, height + 17); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 11 }, { 0, 27, height + 17 }); } wooden_a_supports_paint_setup(session, (direction & 1), 0, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); @@ -796,27 +796,27 @@ static void paint_river_rapids_track_whirlpool( { imageId = (direction == 1 ? SPR_RIVER_RAPIDS_FLAT_NW_SE : SPR_RIVER_RAPIDS_FLAT_SE_NW) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 24, 32, 11, height, 4, 0, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 24, 32, 11 }, { 4, 0, height }); imageId = (SPR_RIVER_RAPIDS_RAPIDS_WHIRLPOOL_FRAME_0 + frameNum) | session->TrackColours[SCHEME_TRACK]; PaintAddImageAsChild(session, imageId, { 0, 0, height }, { 24, 32, 11 }, { 4, 0, height }); imageId = (direction == 1 ? SPR_RIVER_RAPIDS_FLAT_FRONT_NW_SE : SPR_RIVER_RAPIDS_FLAT_FRONT_SE_NW) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 3, height, 27, 0, height + 17); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 3 }, { 27, 0, height + 17 }); } else { imageId = (direction == 0 ? SPR_RIVER_RAPIDS_FLAT_SW_NE : SPR_RIVER_RAPIDS_FLAT_NE_SW) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 24, 11, height, 0, 4, height); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 24, 11 }, { 0, 4, height }); imageId = (SPR_RIVER_RAPIDS_RAPIDS_WHIRLPOOL_FRAME_0 + frameNum) | session->TrackColours[SCHEME_TRACK]; PaintAddImageAsChild(session, imageId, { 0, 0, height }, { 32, 24, 11 }, { 0, 4, height }); imageId = (direction == 0 ? SPR_RIVER_RAPIDS_FLAT_FRONT_SW_NE : SPR_RIVER_RAPIDS_FLAT_FRONT_NE_SW) | session->TrackColours[SCHEME_TRACK]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 3, height, 0, 27, height + 17); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 3 }, { 0, 27, height + 17 }); } wooden_a_supports_paint_setup(session, (direction & 1), 0, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); From 5b2655fe7e16656d4be3f51b7689f8eb8721e0cc Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 17:52:49 +0200 Subject: [PATCH 22/39] Refactor uses of PaintAddImageAsParent in Maze.cpp --- src/openrct2/ride/gentle/Maze.cpp | 54 ++++++++++++++++--------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/openrct2/ride/gentle/Maze.cpp b/src/openrct2/ride/gentle/Maze.cpp index 318d1994a6..c3a8f15fb0 100644 --- a/src/openrct2/ride/gentle/Maze.cpp +++ b/src/openrct2/ride/gentle/Maze.cpp @@ -54,7 +54,7 @@ static void maze_paint_setup( uint32_t rotation = session->CurrentRotation; // draw ground int32_t image_id = SPR_TERRAIN_DIRT | session->TrackColours[SCHEME_MISC]; - PaintAddImageAsParent(session, image_id, 0, 0, 32, 32, 0, height); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 32, 32, 0 }); wooden_a_supports_paint_setup(session, (rotation & 1) ? 0 : 1, 0, height, session->TrackColours[SCHEME_3], nullptr); @@ -81,92 +81,94 @@ static void maze_paint_setup( image_id = base_image_id + SPR_MAZE_OFFSET_WALL_CENTRE; if (maze_entry & MAZE_ENTRY_FLAG_3) - PaintAddImageAsParent(session, image_id, 2, 2, 10, 10, 9, height, 3, 3, height + 2); + PaintAddImageAsParent(session, image_id, { 2, 2, height }, { 10, 10, 9 }, { 3, 3, height + 2 }); if (maze_entry & MAZE_ENTRY_FLAG_7) - PaintAddImageAsParent(session, image_id, 2, 18, 10, 10, 9, height, 3, 19, height + 2); + PaintAddImageAsParent(session, image_id, { 2, 18, height }, { 10, 10, 9 }, { 3, 19, height + 2 }); if (maze_entry & MAZE_ENTRY_FLAG_11) - PaintAddImageAsParent(session, image_id, 18, 18, 10, 10, 9, height, 19, 19, height + 2); + PaintAddImageAsParent(session, image_id, { 18, 18, height }, { 10, 10, 9 }, { 19, 19, height + 2 }); if (maze_entry & MAZE_ENTRY_FLAG_15) - PaintAddImageAsParent(session, image_id, 18, 2, 10, 10, 9, height, 19, 3, height + 2); + PaintAddImageAsParent(session, image_id, { 18, 2, height }, { 10, 10, 9 }, { 19, 3, height + 2 }); image_id = base_image_id + SPR_MAZE_OFFSET_WALL_TOP_LEFT; if (maze_entry & MAZE_ENTRY_FLAG_0) - PaintAddImageAsParent(session, image_id, 2, 0, 10, 1, 9, height, 3, 1, height + 2); + PaintAddImageAsParent(session, image_id, { 2, 0, height }, { 10, 1, 9 }, { 3, 1, height + 2 }); if (maze_entry & MAZE_ENTRY_FLAG_13) - PaintAddImageAsParent(session, image_id, 18, 0, 10, 1, 9, height, 19, 1, height + 2); + PaintAddImageAsParent(session, image_id, { 18, 0, height }, { 10, 1, 9 }, { 19, 1, height + 2 }); image_id = base_image_id + SPR_MAZE_OFFSET_WALL_BOTTOM_RIGHT; if (maze_entry & MAZE_ENTRY_FLAG_5) - PaintAddImageAsParent(session, image_id, 2, 30, 10, 1, 9, height, 3, 30, height + 2); + PaintAddImageAsParent(session, image_id, { 2, 30, height }, { 10, 1, 9 }, { 3, 30, height + 2 }); if (maze_entry & MAZE_ENTRY_FLAG_8) - PaintAddImageAsParent(session, image_id, 18, 30, 10, 1, 9, height, 19, 30, height + 2); + PaintAddImageAsParent(session, image_id, { 18, 30, height }, { 10, 1, 9 }, { 19, 30, height + 2 }); image_id = base_image_id + SPR_MAZE_OFFSET_WALL_TOP_RIGHT; if (maze_entry & MAZE_ENTRY_FLAG_1) - PaintAddImageAsParent(session, image_id, 0, 2, 1, 10, 9, height, 1, 3, height + 2); + PaintAddImageAsParent(session, image_id, { 0, 2, height }, { 1, 10, 9 }, { 1, 3, height + 2 }); if (maze_entry & MAZE_ENTRY_FLAG_4) - PaintAddImageAsParent(session, image_id, 0, 18, 1, 10, 9, height, 1, 19, height + 2); + PaintAddImageAsParent(session, image_id, { 0, 18, height }, { 1, 10, 9 }, { 1, 19, height + 2 }); image_id = base_image_id + SPR_MAZE_OFFSET_WALL_BOTTOM_LEFT; if (maze_entry & MAZE_ENTRY_FLAG_12) - PaintAddImageAsParent(session, image_id, 30, 2, 1, 10, 9, height, 30, 3, height + 2); + PaintAddImageAsParent(session, image_id, { 30, 2, height }, { 1, 10, 9 }, { 30, 3, height + 2 }); if (maze_entry & MAZE_ENTRY_FLAG_9) - PaintAddImageAsParent(session, image_id, 30, 18, 1, 10, 9, height, 30, 19, height + 2); + PaintAddImageAsParent(session, image_id, { 30, 18, height }, { 1, 10, 9 }, { 30, 19, height + 2 }); image_id = base_image_id + SPR_MAZE_OFFSET_WALL_INNER_NE_SW; if (maze_entry & MAZE_ENTRY_FLAG_2) - PaintAddImageAsParent(session, image_id, 2, 14, 10, 4, 9, height, 3, 14, height + 2); + PaintAddImageAsParent(session, image_id, { 2, 14, height }, { 10, 4, 9 }, { 3, 14, height + 2 }); if (maze_entry & MAZE_ENTRY_FLAG_10) - PaintAddImageAsParent(session, image_id, 18, 14, 10, 4, 9, height, 19, 14, height + 2); + PaintAddImageAsParent(session, image_id, { 18, 14, height }, { 10, 4, 9 }, { 19, 14, height + 2 }); image_id = base_image_id + SPR_MAZE_OFFSET_WALL_INNER_NW_SE; if (maze_entry & MAZE_ENTRY_FLAG_14) - PaintAddImageAsParent(session, image_id, 14, 2, 4, 10, 9, height, 14, 3, height + 2); + PaintAddImageAsParent(session, image_id, { 14, 2, height }, { 4, 10, 9 }, { 14, 3, height + 2 }); if (maze_entry & MAZE_ENTRY_FLAG_6) - PaintAddImageAsParent(session, image_id, 14, 18, 4, 10, 9, height, 14, 19, height + 2); + PaintAddImageAsParent(session, image_id, { 14, 18, height }, { 4, 10, 9 }, { 14, 19, height + 2 }); image_id = base_image_id + SPR_MAZE_OFFSET_COLUMN_CORNER; if (maze_entry & (MAZE_ENTRY_FLAG_0 | MAZE_ENTRY_FLAG_1)) - PaintAddImageAsParent(session, image_id, 0, 0, 1, 1, 9, height, 1, 1, height + 2); + PaintAddImageAsParent(session, image_id, { 0, 0, height }, { 1, 1, 9 }, { 1, 1, height + 2 }); if (maze_entry & (MAZE_ENTRY_FLAG_4 | MAZE_ENTRY_FLAG_5)) - PaintAddImageAsParent(session, image_id, 0, 30, 1, 1, 9, height, 1, 30, height + 2); + PaintAddImageAsParent(session, image_id, { 0, 30, height }, { 1, 1, 9 }, { 1, 30, height + 2 }); if (maze_entry & (MAZE_ENTRY_FLAG_8 | MAZE_ENTRY_FLAG_9)) - PaintAddImageAsParent(session, image_id, 30, 30, 1, 1, 9, height, 30, 30, height + 2); + PaintAddImageAsParent(session, image_id, { 30, 30, height }, { 1, 1, 9 }, { 30, 30, height + 2 }); if (maze_entry & (MAZE_ENTRY_FLAG_12 | MAZE_ENTRY_FLAG_13)) - PaintAddImageAsParent(session, image_id, 30, 0, 1, 1, 9, height, 30, 1, height + 2); + PaintAddImageAsParent(session, image_id, { 30, 0, height }, { 1, 1, 9 }, { 30, 1, height + 2 }); if (maze_entry & (MAZE_ENTRY_FLAG_0 | MAZE_ENTRY_FLAG_13 | MAZE_ENTRY_FLAG_14)) PaintAddImageAsParent( - session, base_image_id + SPR_MAZE_OFFSET_COLUMN_TOP_LEFT, 14, 0, 2, 1, 9, height, 15, 1, height + 2); + session, base_image_id + SPR_MAZE_OFFSET_COLUMN_TOP_LEFT, { 14, 0, height }, { 2, 1, 9 }, { 15, 1, height + 2 }); if (maze_entry & (MAZE_ENTRY_FLAG_5 | MAZE_ENTRY_FLAG_6 | MAZE_ENTRY_FLAG_8)) PaintAddImageAsParent( - session, base_image_id + SPR_MAZE_OFFSET_COLUMN_BOTTOM_RIGHT, 14, 30, 2, 1, 9, height, 15, 30, height + 2); + session, base_image_id + SPR_MAZE_OFFSET_COLUMN_BOTTOM_RIGHT, { 14, 30, height }, { 2, 1, 9 }, + { 15, 30, height + 2 }); if (maze_entry & (MAZE_ENTRY_FLAG_1 | MAZE_ENTRY_FLAG_2 | MAZE_ENTRY_FLAG_4)) PaintAddImageAsParent( - session, base_image_id + SPR_MAZE_OFFSET_COLUMN_TOP_RIGHT, 0, 14, 1, 2, 9, height, 1, 15, height + 2); + session, base_image_id + SPR_MAZE_OFFSET_COLUMN_TOP_RIGHT, { 0, 14, height }, { 1, 2, 9 }, { 1, 15, height + 2 }); if (maze_entry & (MAZE_ENTRY_FLAG_9 | MAZE_ENTRY_FLAG_10 | MAZE_ENTRY_FLAG_12)) PaintAddImageAsParent( - session, base_image_id + SPR_MAZE_OFFSET_COLUMN_BOTTOM_LEFT, 30, 14, 1, 2, 9, height, 30, 15, height + 2); + session, base_image_id + SPR_MAZE_OFFSET_COLUMN_BOTTOM_LEFT, { 30, 14, height }, { 1, 2, 9 }, + { 30, 15, height + 2 }); if (maze_entry & (MAZE_ENTRY_FLAG_2 | MAZE_ENTRY_FLAG_6 | MAZE_ENTRY_FLAG_10 | MAZE_ENTRY_FLAG_14)) { PaintAddImageAsParent( - session, base_image_id + SPR_MAZE_OFFSET_COLUMN_CENTRE, 14, 14, 2, 2, 8, height, 15, 15, height + 2); + session, base_image_id + SPR_MAZE_OFFSET_COLUMN_CENTRE, { 14, 14, height }, { 2, 2, 8 }, { 15, 15, height + 2 }); paint_util_set_segment_support_height(session, SEGMENT_C4, height + 12, 0x20); } From 79e627b2dafc97f0f5be8adee9f9c9b86cf708e9 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 8 Mar 2021 18:01:48 +0200 Subject: [PATCH 23/39] Refactor uses of PaintAddImageAsParent in TrackPaint.cpp --- src/openrct2/ride/TrackPaint.cpp | 165 ++++++++++++++++++------------- 1 file changed, 97 insertions(+), 68 deletions(-) diff --git a/src/openrct2/ride/TrackPaint.cpp b/src/openrct2/ride/TrackPaint.cpp index 9770b4cf8e..be5851b84c 100644 --- a/src/openrct2/ride/TrackPaint.cpp +++ b/src/openrct2/ride/TrackPaint.cpp @@ -251,7 +251,7 @@ void track_paint_util_paint_floor( imageId = floorSprites[3]; } - PaintAddImageAsParent(session, imageId | colourFlags, 0, 0, 32, 32, 1, height, 0, 0, height); + PaintAddImageAsParent(session, imageId | colourFlags, { 0, 0, height }, { 32, 32, 1 }, { 0, 0, height }); } void track_paint_util_paint_fences( @@ -273,12 +273,12 @@ void track_paint_util_paint_fences( if (edges & EDGE_SE && track_paint_util_has_fence(EDGE_SE, position, tileElement, ride, rotation)) { imageId = fenceSprites[1] | colourFlags; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 1, 7, height, 0, 30, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 32, 1, 7 }, { 0, 30, height + 2 }); } if (edges & EDGE_SW && track_paint_util_has_fence(EDGE_SW, position, tileElement, ride, rotation)) { imageId = fenceSprites[2] | colourFlags; - PaintAddImageAsParent(session, imageId, 0, 0, 1, 32, 7, height, 30, 0, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 1, 32, 7 }, { 30, 0, height + 2 }); } } @@ -363,7 +363,7 @@ static void track_paint_util_draw_station_impl( imageId = (hasFence ? SPR_STATION_PLATFORM_FENCED_SW_NE : SPR_STATION_PLATFORM_SW_NE) | session->TrackColours[SCHEME_SUPPORTS]; } - PaintAddImageAsParent(session, imageId, 0, 0, 32, 8, 1, height + fenceOffsetA); + PaintAddImageAsParent(session, imageId, { 0, 0, height + fenceOffsetA }, { 32, 8, 1 }); // height -= 5 (height) track_paint_util_draw_station_covers(session, EDGE_NW, hasFence, stationObj, coverHeight); // height += 5 (height + 5) @@ -381,7 +381,7 @@ static void track_paint_util_draw_station_impl( { imageId = SPR_STATION_PLATFORM_SW_NE | session->TrackColours[SCHEME_SUPPORTS]; } - PaintAddImageAsParent(session, imageId, 0, 24, 32, 8, 1, height + fenceOffsetA); + PaintAddImageAsParent(session, imageId, { 0, 24, height + fenceOffsetA }, { 32, 8, 1 }); // height += 2 (height + 7) hasFence = track_paint_util_has_fence(EDGE_SE, position, tileElement, ride, session->CurrentRotation); @@ -399,19 +399,19 @@ static void track_paint_util_draw_station_impl( { imageId = SPR_STATION_FENCE_SW_NE | session->TrackColours[SCHEME_SUPPORTS]; } - PaintAddImageAsParent(session, imageId, 0, 31, 32, 1, 7, height + fenceOffsetB); + PaintAddImageAsParent(session, imageId, { 0, 31, height + fenceOffsetB }, { 32, 1, 7 }); } else if (tileElement->AsTrack()->GetTrackType() == TrackElemType::BeginStation && direction == 0) { // Addition: draw only small fence if there is an entrance/exit at the beginning imageId = SPR_STATION_FENCE_SMALL_NW_SE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 31, 23, 1, 8, 7, height + fenceOffsetB); + PaintAddImageAsParent(session, imageId, { 31, 23, height + fenceOffsetB }, { 1, 8, 7 }); } else if (tileElement->AsTrack()->GetTrackType() == TrackElemType::EndStation && direction == 2) { // Addition: draw only small fence if there is an entrance/exit at the end imageId = SPR_STATION_LIGHT_BACK_NE_SW | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 31, 23, 1, 8, 7, height + fenceOffsetB); + PaintAddImageAsParent(session, imageId, { 31, 23, height + fenceOffsetB }, { 1, 8, 7 }); } // height -= 7 (height) track_paint_util_draw_station_covers(session, EDGE_SE, hasFence, stationObj, coverHeight); @@ -420,12 +420,12 @@ static void track_paint_util_draw_station_impl( if (tileElement->AsTrack()->GetTrackType() == TrackElemType::BeginStation && direction == 0) { imageId = SPR_STATION_FENCE_SMALL_NW_SE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 31, 0, 1, 8, 7, height + fenceOffsetB); + PaintAddImageAsParent(session, imageId, { 31, 0, height + fenceOffsetB }, { 1, 8, 7 }); } else if (tileElement->AsTrack()->GetTrackType() == TrackElemType::EndStation && direction == 2) { imageId = SPR_STATION_LIGHT_BACK_NE_SW | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 31, 0, 1, 8, 7, height + fenceOffsetB); + PaintAddImageAsParent(session, imageId, { 31, 0, height + fenceOffsetB }, { 1, 8, 7 }); } } else if (direction == 1 || direction == 3) @@ -458,7 +458,7 @@ static void track_paint_util_draw_station_impl( imageId = (hasFence ? SPR_STATION_PLATFORM_FENCED_NW_SE : SPR_STATION_PLATFORM_NW_SE) | session->TrackColours[SCHEME_SUPPORTS]; } - PaintAddImageAsParent(session, imageId, 0, 0, 8, 32, 1, height + fenceOffsetA); + PaintAddImageAsParent(session, imageId, { 0, 0, height + fenceOffsetA }, { 8, 32, 1 }); // height -= 5 (height) track_paint_util_draw_station_covers(session, EDGE_NE, hasFence, stationObj, coverHeight); // height += 5 (height + 5) @@ -476,7 +476,7 @@ static void track_paint_util_draw_station_impl( { imageId = SPR_STATION_PLATFORM_NW_SE | session->TrackColours[SCHEME_SUPPORTS]; } - PaintAddImageAsParent(session, imageId, 24, 0, 8, 32, 1, height + fenceOffsetA); + PaintAddImageAsParent(session, imageId, { 24, 0, height + fenceOffsetA }, { 8, 32, 1 }); // height += 2 (height + 7) hasFence = track_paint_util_has_fence(EDGE_SW, position, tileElement, ride, session->CurrentRotation); @@ -494,19 +494,19 @@ static void track_paint_util_draw_station_impl( { imageId = SPR_STATION_FENCE_NW_SE | session->TrackColours[SCHEME_SUPPORTS]; } - PaintAddImageAsParent(session, imageId, 31, 0, 1, 32, 7, height + fenceOffsetB); + PaintAddImageAsParent(session, imageId, { 31, 0, height + fenceOffsetB }, { 1, 32, 7 }); } else if (tileElement->AsTrack()->GetTrackType() == TrackElemType::BeginStation && direction == 3) { // Addition: draw only small fence if there is an entrance/exit at the beginning imageId = SPR_STATION_FENCE_SMALL_SW_NE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 23, 31, 8, 1, 7, height + fenceOffsetB); + PaintAddImageAsParent(session, imageId, { 23, 31, height + fenceOffsetB }, { 8, 1, 7 }); } else if (tileElement->AsTrack()->GetTrackType() == TrackElemType::EndStation && direction == 1) { // Addition: draw only small fence if there is an entrance/exit at the end imageId = SPR_STATION_LIGHT_BACK_NW_SE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 23, 31, 8, 1, 7, height + fenceOffsetB); + PaintAddImageAsParent(session, imageId, { 23, 31, height + fenceOffsetB }, { 8, 1, 7 }); } // height -= 7 (height) @@ -516,12 +516,12 @@ static void track_paint_util_draw_station_impl( if (tileElement->AsTrack()->GetTrackType() == TrackElemType::BeginStation && direction == 3) { imageId = SPR_STATION_FENCE_SMALL_SW_NE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 31, 8, 1, 7, height + fenceOffsetB); + PaintAddImageAsParent(session, imageId, { 0, 31, height + fenceOffsetB }, { 8, 1, 7 }); } else if (tileElement->AsTrack()->GetTrackType() == TrackElemType::EndStation && direction == 1) { imageId = SPR_STATION_LIGHT_BACK_NW_SE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 31, 8, 1, 7, height + fenceOffsetB); + PaintAddImageAsParent(session, imageId, { 0, 31, height + fenceOffsetB }, { 8, 1, 7 }); } } } @@ -571,7 +571,7 @@ void track_paint_util_draw_station_inverted( imageId = (hasFence ? SPR_STATION_PLATFORM_FENCED_SW_NE : SPR_STATION_PLATFORM_SW_NE) | session->TrackColours[SCHEME_SUPPORTS]; } - PaintAddImageAsParent(session, imageId, 0, 0, 32, 8, 1, height + 6); + PaintAddImageAsParent(session, imageId, { 0, 0, height + 6 }, { 32, 8, 1 }); // height -= 5 (height) track_paint_util_draw_station_covers_2(session, EDGE_NW, hasFence, stationObj, height, stationVariant); // height += 5 (height + 5) @@ -589,7 +589,7 @@ void track_paint_util_draw_station_inverted( { imageId = SPR_STATION_PLATFORM_SW_NE | session->TrackColours[SCHEME_SUPPORTS]; } - PaintAddImageAsParent(session, imageId, 0, 24, 32, 8, 1, height + 6); + PaintAddImageAsParent(session, imageId, { 0, 24, height + 6 }, { 32, 8, 1 }); // height += 2 (height + 7) hasFence = track_paint_util_has_fence(EDGE_SE, position, tileElement, ride, session->CurrentRotation); @@ -607,19 +607,19 @@ void track_paint_util_draw_station_inverted( { imageId = SPR_STATION_INVERTED_FENCE_SW_NE | session->TrackColours[SCHEME_SUPPORTS]; } - PaintAddImageAsParent(session, imageId, 0, 31, 32, 1, 7, height + 8); + PaintAddImageAsParent(session, imageId, { 0, 31, height + 8 }, { 32, 1, 7 }); } else if (tileElement->AsTrack()->GetTrackType() == TrackElemType::BeginStation && direction == 0) { // Addition: draw only small fence if there is an entrance/exit at the beginning imageId = SPR_STATION_FENCE_SMALL_NW_SE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 31, 23, 1, 8, 7, height + 8); + PaintAddImageAsParent(session, imageId, { 31, 23, height + 8 }, { 1, 8, 7 }); } else if (tileElement->AsTrack()->GetTrackType() == TrackElemType::EndStation && direction == 2) { // Addition: draw only small fence if there is an entrance/exit at the end imageId = SPR_STATION_LIGHT_BACK_NE_SW | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 31, 23, 1, 8, 7, height + 8); + PaintAddImageAsParent(session, imageId, { 31, 23, height + 8 }, { 1, 8, 7 }); } // height -= 7 (height) track_paint_util_draw_station_covers_2(session, EDGE_SE, hasFence, stationObj, height, stationVariant); @@ -628,12 +628,12 @@ void track_paint_util_draw_station_inverted( if (tileElement->AsTrack()->GetTrackType() == TrackElemType::BeginStation && direction == 0) { imageId = SPR_STATION_FENCE_SMALL_NW_SE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 31, 0, 1, 8, 7, height + 8); + PaintAddImageAsParent(session, imageId, { 31, 0, height + 8 }, { 1, 8, 7 }); } else if (tileElement->AsTrack()->GetTrackType() == TrackElemType::EndStation && direction == 2) { imageId = SPR_STATION_LIGHT_BACK_NE_SW | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 31, 0, 1, 8, 7, height + 8); + PaintAddImageAsParent(session, imageId, { 31, 0, height + 8 }, { 1, 8, 7 }); } } else if (direction == 1 || direction == 3) @@ -666,7 +666,7 @@ void track_paint_util_draw_station_inverted( imageId = (hasFence ? SPR_STATION_PLATFORM_FENCED_NW_SE : SPR_STATION_PLATFORM_NW_SE) | session->TrackColours[SCHEME_SUPPORTS]; } - PaintAddImageAsParent(session, imageId, 0, 0, 8, 32, 1, height + 6); + PaintAddImageAsParent(session, imageId, { 0, 0, height + 6 }, { 8, 32, 1 }); // height -= 5 (height) track_paint_util_draw_station_covers_2(session, EDGE_NE, hasFence, stationObj, height, stationVariant); // height += 5 (height + 5) @@ -684,7 +684,7 @@ void track_paint_util_draw_station_inverted( { imageId = SPR_STATION_PLATFORM_NW_SE | session->TrackColours[SCHEME_SUPPORTS]; } - PaintAddImageAsParent(session, imageId, 24, 0, 8, 32, 1, height + 6); + PaintAddImageAsParent(session, imageId, { 24, 0, height + 6 }, { 8, 32, 1 }); // height += 2 (height + 7) hasFence = track_paint_util_has_fence(EDGE_SW, position, tileElement, ride, session->CurrentRotation); @@ -702,19 +702,19 @@ void track_paint_util_draw_station_inverted( { imageId = SPR_STATION_INVERTED_FENCE_NW_SE | session->TrackColours[SCHEME_SUPPORTS]; } - PaintAddImageAsParent(session, imageId, 31, 0, 1, 32, 7, height + 8); + PaintAddImageAsParent(session, imageId, { 31, 0, height + 8 }, { 1, 32, 7 }); } else if (tileElement->AsTrack()->GetTrackType() == TrackElemType::BeginStation && direction == 3) { // Addition: draw only small fence if there is an entrance/exit at the beginning imageId = SPR_STATION_FENCE_SMALL_SW_NE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 23, 31, 8, 1, 7, height + 8); + PaintAddImageAsParent(session, imageId, { 23, 31, height + 8 }, { 8, 1, 7 }); } else if (tileElement->AsTrack()->GetTrackType() == TrackElemType::EndStation && direction == 1) { // Addition: draw only small fence if there is an entrance/exit at the end imageId = SPR_STATION_LIGHT_BACK_NW_SE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 23, 31, 8, 1, 7, height + 8); + PaintAddImageAsParent(session, imageId, { 23, 31, height + 8 }, { 8, 1, 7 }); } // height -= 7 (height) @@ -724,12 +724,12 @@ void track_paint_util_draw_station_inverted( if (tileElement->AsTrack()->GetTrackType() == TrackElemType::BeginStation && direction == 3) { imageId = SPR_STATION_FENCE_SMALL_SW_NE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 31, 8, 1, 7, height + 8); + PaintAddImageAsParent(session, imageId, { 0, 31, height + 8 }, { 8, 1, 7 }); } else if (tileElement->AsTrack()->GetTrackType() == TrackElemType::EndStation && direction == 1) { imageId = SPR_STATION_LIGHT_BACK_NW_SE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 31, 8, 1, 7, height + 8); + PaintAddImageAsParent(session, imageId, { 0, 31, height + 8 }, { 8, 1, 7 }); } } } @@ -847,17 +847,17 @@ void track_paint_util_draw_station_platform( bool hasFence = track_paint_util_has_fence(EDGE_NE, position, tileElement, ride, session->CurrentRotation); uint32_t imageId = (hasFence ? SPR_STATION_NARROW_EDGE_FENCED_NE : SPR_STATION_NARROW_EDGE_NE) | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 8, 32, 1, height + zOffset); + PaintAddImageAsParent(session, imageId, { 0, 0, height + zOffset }, { 8, 32, 1 }); track_paint_util_draw_station_covers(session, EDGE_NE, hasFence, stationObj, height); imageId = SPR_STATION_NARROW_EDGE_SW | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 24, 0, 8, 32, 1, height + zOffset); + PaintAddImageAsParent(session, imageId, { 24, 0, height + zOffset }, { 8, 32, 1 }); hasFence = track_paint_util_has_fence(EDGE_SW, position, tileElement, ride, session->CurrentRotation); if (hasFence) { imageId = SPR_STATION_FENCE_NW_SE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 31, 0, 1, 32, 7, height + zOffset + 2); + PaintAddImageAsParent(session, imageId, { 31, 0, height + zOffset + 2 }, { 1, 32, 7 }); } track_paint_util_draw_station_covers(session, EDGE_SW, hasFence, stationObj, height); } @@ -866,17 +866,17 @@ void track_paint_util_draw_station_platform( bool hasFence = track_paint_util_has_fence(EDGE_NW, position, tileElement, ride, session->CurrentRotation); uint32_t imageId = (hasFence ? SPR_STATION_NARROW_EDGE_FENCED_NW : SPR_STATION_NARROW_EDGE_NW) | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 0, 32, 8, 1, height + zOffset); + PaintAddImageAsParent(session, imageId, { 0, 0, height + zOffset }, { 32, 8, 1 }); track_paint_util_draw_station_covers(session, EDGE_NW, hasFence, stationObj, height); imageId = SPR_STATION_NARROW_EDGE_SE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 24, 32, 8, 1, height + zOffset); + PaintAddImageAsParent(session, imageId, { 0, 24, height + zOffset }, { 32, 8, 1 }); hasFence = track_paint_util_has_fence(EDGE_SE, position, tileElement, ride, session->CurrentRotation); if (hasFence) { imageId = SPR_STATION_FENCE_SW_NE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 31, 32, 1, 7, height + zOffset + 2); + PaintAddImageAsParent(session, imageId, { 0, 31, height + zOffset + 2 }, { 32, 1, 7 }); } track_paint_util_draw_station_covers(session, EDGE_SE, hasFence, stationObj, height); } @@ -904,7 +904,7 @@ void track_paint_util_draw_pier( if (hasFence) { imageId = SPR_STATION_PIER_FENCE_SW | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 31, 0, 1, 32, 7, height + 2); + PaintAddImageAsParent(session, imageId, { 31, 0, height + 2 }, { 1, 32, 7 }); } track_paint_util_draw_station_covers(session, EDGE_SW, hasFence, stationObj, height); } @@ -923,7 +923,7 @@ void track_paint_util_draw_pier( if (hasFence) { imageId = SPR_STATION_PIER_FENCE_SE | session->TrackColours[SCHEME_SUPPORTS]; - PaintAddImageAsParent(session, imageId, 0, 31, 32, 1, 7, height + 2); + PaintAddImageAsParent(session, imageId, { 0, 31, height + 2 }, { 32, 1, 7 }); } track_paint_util_draw_station_covers(session, EDGE_SE, hasFence, stationObj, height); } @@ -1654,13 +1654,16 @@ void track_paint_util_right_quarter_turn_3_tiles_paint_2_with_height_offset( switch (trackSequence) { case 0: - PaintAddImageAsParent(session, imageId, 0, 0, 32, 20, thickness, height, 0, 6, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 32, 20, thickness }, { 0, 6, height + heightOffset }); break; case 2: - PaintAddImageAsParent(session, imageId, 0, 0, 16, 16, thickness, height, 16, 16, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 16, 16, thickness }, { 16, 16, height + heightOffset }); break; case 3: - PaintAddImageAsParent(session, imageId, 0, 0, 20, 32, thickness, height, 6, 0, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 20, 32, thickness }, { 6, 0, height + heightOffset }); break; } break; @@ -1669,13 +1672,16 @@ void track_paint_util_right_quarter_turn_3_tiles_paint_2_with_height_offset( switch (trackSequence) { case 0: - PaintAddImageAsParent(session, imageId, 0, 0, 20, 32, thickness, height, 6, 0, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 20, 32, thickness }, { 6, 0, height + heightOffset }); break; case 2: - PaintAddImageAsParent(session, imageId, 0, 0, 16, 16, thickness, height, 16, 0, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 16, 16, thickness }, { 16, 0, height + heightOffset }); break; case 3: - PaintAddImageAsParent(session, imageId, 0, 0, 32, 20, thickness, height, 0, 6, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 32, 20, thickness }, { 0, 6, height + heightOffset }); break; } break; @@ -1684,13 +1690,16 @@ void track_paint_util_right_quarter_turn_3_tiles_paint_2_with_height_offset( switch (trackSequence) { case 0: - PaintAddImageAsParent(session, imageId, 0, 0, 32, 20, thickness, height, 0, 6, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 32, 20, thickness }, { 0, 6, height + heightOffset }); break; case 2: - PaintAddImageAsParent(session, imageId, 0, 0, 16, 16, thickness, height, 0, 0, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 16, 16, thickness }, { 0, 0, height + heightOffset }); break; case 3: - PaintAddImageAsParent(session, imageId, 0, 0, 20, 32, thickness, height, 6, 0, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 20, 32, thickness }, { 6, 0, height + heightOffset }); break; } break; @@ -1699,13 +1708,16 @@ void track_paint_util_right_quarter_turn_3_tiles_paint_2_with_height_offset( switch (trackSequence) { case 0: - PaintAddImageAsParent(session, imageId, 0, 0, 20, 32, thickness, height, 6, 0, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 20, 32, thickness }, { 6, 0, height + heightOffset }); break; case 2: - PaintAddImageAsParent(session, imageId, 0, 0, 16, 16, thickness, height, 0, 16, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 16, 16, thickness }, { 0, 16, height + heightOffset }); break; case 3: - PaintAddImageAsParent(session, imageId, 0, 0, 32, 20, thickness, height, 0, 6, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 32, 20, thickness }, { 0, 6, height + heightOffset }); break; } break; @@ -1847,13 +1859,16 @@ void track_paint_util_left_quarter_turn_3_tiles_paint_with_height_offset( switch (trackSequence) { case 0: - PaintAddImageAsParent(session, imageId, 0, 0, 32, 20, thickness, height, 0, 6, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 32, 20, thickness }, { 0, 6, height + heightOffset }); break; case 2: - PaintAddImageAsParent(session, imageId, 0, 0, 16, 16, thickness, height, 16, 0, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 16, 16, thickness }, { 16, 0, height + heightOffset }); break; case 3: - PaintAddImageAsParent(session, imageId, 0, 0, 20, 32, thickness, height, 6, 0, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 20, 32, thickness }, { 6, 0, height + heightOffset }); break; } break; @@ -1862,13 +1877,16 @@ void track_paint_util_left_quarter_turn_3_tiles_paint_with_height_offset( switch (trackSequence) { case 0: - PaintAddImageAsParent(session, imageId, 0, 0, 20, 32, thickness, height, 6, 0, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 20, 32, thickness }, { 6, 0, height + heightOffset }); break; case 2: - PaintAddImageAsParent(session, imageId, 0, 0, 16, 16, thickness, height, 0, 0, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 16, 16, thickness }, { 0, 0, height + heightOffset }); break; case 3: - PaintAddImageAsParent(session, imageId, 0, 0, 32, 20, thickness, height, 0, 6, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 32, 20, thickness }, { 0, 6, height + heightOffset }); break; } break; @@ -1877,13 +1895,16 @@ void track_paint_util_left_quarter_turn_3_tiles_paint_with_height_offset( switch (trackSequence) { case 0: - PaintAddImageAsParent(session, imageId, 0, 0, 32, 20, thickness, height, 0, 6, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 32, 20, thickness }, { 0, 6, height + heightOffset }); break; case 2: - PaintAddImageAsParent(session, imageId, 0, 0, 16, 16, thickness, height, 0, 16, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 16, 16, thickness }, { 0, 16, height + heightOffset }); break; case 3: - PaintAddImageAsParent(session, imageId, 0, 0, 20, 32, thickness, height, 6, 0, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 20, 32, thickness }, { 6, 0, height + heightOffset }); break; } break; @@ -1892,13 +1913,16 @@ void track_paint_util_left_quarter_turn_3_tiles_paint_with_height_offset( switch (trackSequence) { case 0: - PaintAddImageAsParent(session, imageId, 0, 0, 20, 32, thickness, height, 6, 0, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 20, 32, thickness }, { 6, 0, height + heightOffset }); break; case 2: - PaintAddImageAsParent(session, imageId, 0, 0, 16, 16, thickness, height, 16, 16, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 16, 16, thickness }, { 16, 16, height + heightOffset }); break; case 3: - PaintAddImageAsParent(session, imageId, 0, 0, 32, 20, thickness, height, 0, 6, height + heightOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 32, 20, thickness }, { 0, 6, height + heightOffset }); break; } break; @@ -1938,16 +1962,20 @@ void track_paint_util_left_quarter_turn_1_tile_paint( switch (direction) { case 0: - PaintAddImageAsParent(session, imageId, 0, 0, 26, 24, thickness, height, 6, 2, height + boundBoxZOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 26, 24, thickness }, { 6, 2, height + boundBoxZOffset }); break; case 1: - PaintAddImageAsParent(session, imageId, 0, 0, 26, 26, thickness, height, 0, 0, height + boundBoxZOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 26, 26, thickness }, { 0, 0, height + boundBoxZOffset }); break; case 2: - PaintAddImageAsParent(session, imageId, 0, 0, 24, 26, thickness, height, 2, 6, height + boundBoxZOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 24, 26, thickness }, { 2, 6, height + boundBoxZOffset }); break; case 3: - PaintAddImageAsParent(session, imageId, 0, 0, 24, 24, thickness, height, 6, 6, height + boundBoxZOffset); + PaintAddImageAsParent( + session, imageId, { 0, 0, height }, { 24, 24, thickness }, { 6, 6, height + boundBoxZOffset }); break; } } @@ -2162,7 +2190,8 @@ void track_paint(paint_session* session, Direction direction, int32_t height, co uint32_t imageId = SPRITE_ID_PALETTE_COLOUR_1(COLOUR_LIGHT_BLUE) | (0x1689 + get_height_marker_offset()); auto heightNum = (height + 8) / 16 - gMapBaseZ; - PaintAddImageAsParent(session, imageId + heightNum, 16, 16, 1, 1, 0, height + ax + 3, 1000, 1000, 2047); + PaintAddImageAsParent( + session, imageId + heightNum, { 16, 16, height + ax + 3 }, { 1, 1, 0 }, { 1000, 1000, 2047 }); } } From a35d221afac83b64cd9b7f33253e141d3f642cf5 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 9 Mar 2021 04:08:08 +0200 Subject: [PATCH 24/39] Remove unnecessary construction of CoordsXYZ in Supports.cpp --- src/openrct2/paint/Supports.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/openrct2/paint/Supports.cpp b/src/openrct2/paint/Supports.cpp index 5e977a3bbf..c36cd3aef7 100644 --- a/src/openrct2/paint/Supports.cpp +++ b/src/openrct2/paint/Supports.cpp @@ -1,4 +1,4 @@ -/***************************************************************************** +/***************************************************************************** * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md @@ -1002,9 +1002,7 @@ bool metal_a_supports_paint_setup( image_id += z - 1; image_id |= imageColourFlags; - PaintAddImageAsParent( - session, image_id, { xOffset, yOffset, height }, { 0, 0, 0 }, - { boundBoxOffset.x, boundBoxOffset.y, boundBoxOffset.z }); + PaintAddImageAsParent(session, image_id, { xOffset, yOffset, height }, { 0, 0, 0 }, boundBoxOffset); height += z; } From 2ec5cca3a2aa288cd7d378a17641147c94ead1f4 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 9 Mar 2021 04:17:10 +0200 Subject: [PATCH 25/39] Fix TestPaint --- test/testpaint/PaintIntercept.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/testpaint/PaintIntercept.cpp b/test/testpaint/PaintIntercept.cpp index 1067c70dd2..f5f0ec2df3 100644 --- a/test/testpaint/PaintIntercept.cpp +++ b/test/testpaint/PaintIntercept.cpp @@ -369,6 +369,15 @@ paint_struct* PaintAddImageAsParent( bound_box_offset_x, bound_box_offset_y, bound_box_offset_z, session->CurrentRotation); } +paint_struct* PaintAddImageAsParent( + paint_session* session, uint32_t image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxSize, + const CoordsXYZ& boundBoxOffset) +{ + return PaintAddImageAsParent( + session, image_id, offset.x, offset.y, boundBoxSize.x, boundBoxSize.y, boundBoxSize.z, offset.z, boundBoxOffset.x, + boundBoxOffset.y, boundBoxOffset.z); +} + paint_struct* PaintAddImageAsChild( paint_session* session, uint32_t image_id, const CoordsXYZ& offset, const CoordsXYZ& boundBoxLength, const CoordsXYZ& boundBoxOffset) From e289e215033ddd1a3040786f4d608df9f405e249 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 21 May 2021 18:34:47 +0300 Subject: [PATCH 26/39] Address code review --- .../paint/tile_element/Paint.Surface.cpp | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/openrct2/paint/tile_element/Paint.Surface.cpp b/src/openrct2/paint/tile_element/Paint.Surface.cpp index ab7e0d2574..ba9c54808e 100644 --- a/src/openrct2/paint/tile_element/Paint.Surface.cpp +++ b/src/openrct2/paint/tile_element/Paint.Surface.cpp @@ -657,8 +657,7 @@ static void viewport_surface_draw_tile_side_bottom( if (curHeight != cornerHeight1 && curHeight != cornerHeight2) { uint32_t image_id = base_image_id + image_offset; - PaintAddImageAsParent( - session, image_id, { offset.x, offset.y, curHeight * COORDS_Z_PER_TINY_Z }, { bounds.x, bounds.y, 15 }); + PaintAddImageAsParent(session, image_id, { offset, curHeight * COORDS_Z_PER_TINY_Z }, { bounds, 15 }); curHeight++; } } @@ -682,8 +681,7 @@ static void viewport_surface_draw_tile_side_bottom( } const uint32_t image_id = base_image_id + image_offset; - PaintAddImageAsParent( - session, image_id, { offset.x, offset.y, curHeight * COORDS_Z_PER_TINY_Z }, { bounds.x, bounds.y, 15 }); + PaintAddImageAsParent(session, image_id, { offset, curHeight * COORDS_Z_PER_TINY_Z }, { bounds, 15 }); return; } @@ -698,9 +696,7 @@ static void viewport_surface_draw_tile_side_bottom( if (isWater || curHeight != tunnelArray[tunnelIndex].height) { - PaintAddImageAsParent( - session, base_image_id, { offset.x, offset.y, curHeight * COORDS_Z_PER_TINY_Z }, - { bounds.x, bounds.y, 15 }); + PaintAddImageAsParent(session, base_image_id, { offset, curHeight * COORDS_Z_PER_TINY_Z }, { bounds, 15 }); curHeight++; continue; @@ -729,8 +725,8 @@ static void viewport_surface_draw_tile_side_bottom( uint32_t image_id = get_tunnel_image(edgeStyle, tunnelType) + (edge == EDGE_BOTTOMRIGHT ? 2 : 0); PaintAddImageAsParent( - session, image_id, offset.x, offset.y, tunnelBounds.x, tunnelBounds.y, boundBoxLength - 1, zOffset, 0, 0, - boundBoxOffsetZ); + session, image_id, { offset, zOffset }, { tunnelBounds.x, tunnelBounds.y, boundBoxLength - 1 }, + { 0, 0, boundBoxOffsetZ }); boundBoxOffsetZ = curHeight * COORDS_Z_PER_TINY_Z; boundBoxLength = _tunnelHeights[tunnelType][1] * 16; @@ -743,8 +739,9 @@ static void viewport_surface_draw_tile_side_bottom( image_id = get_tunnel_image(edgeStyle, tunnelType) + (edge == EDGE_BOTTOMRIGHT ? 2 : 0) + 1; PaintAddImageAsParent( - session, image_id, offset.x, offset.y, tunnelBounds.x, tunnelBounds.y, boundBoxLength - 1, - curHeight * COORDS_Z_PER_TINY_Z, tunnelTopBoundBoxOffset.x, tunnelTopBoundBoxOffset.y, boundBoxOffsetZ); + session, image_id, { offset, curHeight * COORDS_Z_PER_TINY_Z }, + { tunnelBounds.x, tunnelBounds.y, boundBoxLength - 1 }, + { tunnelTopBoundBoxOffset.x, tunnelTopBoundBoxOffset.y, boundBoxOffsetZ }); curHeight += _tunnelHeights[tunnelType][0]; tunnelIndex++; @@ -893,8 +890,7 @@ static void viewport_surface_draw_tile_side_top( while (cur_height < cornerHeight1 && cur_height < neighbourCornerHeight1) { - PaintAddImageAsParent( - session, base_image_id, { offset.x, offset.y, cur_height * COORDS_Z_PER_TINY_Z }, { bounds.x, bounds.y, 15 }); + PaintAddImageAsParent(session, base_image_id, { offset, cur_height * COORDS_Z_PER_TINY_Z }, { bounds, 15 }); cur_height++; } @@ -910,8 +906,7 @@ static void viewport_surface_draw_tile_side_top( } const uint32_t image_id = base_image_id + image_offset; - PaintAddImageAsParent( - session, image_id, { offset.x, offset.y, cur_height * COORDS_Z_PER_TINY_Z }, { bounds.x, bounds.y, 15 }); + PaintAddImageAsParent(session, image_id, { offset, cur_height * COORDS_Z_PER_TINY_Z }, { bounds, 15 }); } /** @@ -1395,9 +1390,8 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c } PaintAddImageAsParent( - session, image_id, { fenceData.offset.x, fenceData.offset.y, local_height }, - { fenceData.box_size.x, fenceData.box_size.y, 9 }, - { fenceData.box_offset.x, fenceData.box_offset.y, local_height + 1 }); + session, image_id, { fenceData.offset, local_height }, { fenceData.box_size, 9 }, + { fenceData.box_offset, local_height + 1 }); } } From 051a09d2b7da478fd382543c3c4a7229a822279c Mon Sep 17 00:00:00 2001 From: Ted John Date: Thu, 8 Apr 2021 21:05:34 +0100 Subject: [PATCH 27/39] Update map tile loop to support large maps. --- src/openrct2/rct2/S6Importer.cpp | 4 ++-- src/openrct2/world/Map.cpp | 33 ++++++++++++++++++-------------- src/openrct2/world/Map.h | 3 +-- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 03fd04e4d9..e1d075c976 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -459,8 +459,8 @@ public: // pad_13CE730 // rct1_scenario_flags - gWidePathTileLoopX = _s6.wide_path_tile_loop_x; - gWidePathTileLoopY = _s6.wide_path_tile_loop_y; + gWidePathTileLoopPosition.x = _s6.wide_path_tile_loop_x; + gWidePathTileLoopPosition.y = _s6.wide_path_tile_loop_y; // pad_13CE778 // Fix and set dynamic variables diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index eb0f789c4f..1d70a4e1e8 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -90,8 +90,7 @@ uint8_t gMapSelectArrowDirection; uint8_t gMapGroundFlags; -uint16_t gWidePathTileLoopX; -uint16_t gWidePathTileLoopY; +TileCoordsXY gWidePathTileLoopPosition; uint16_t gGrassSceneryTileLoopPosition; int16_t gMapSizeUnits; @@ -273,8 +272,7 @@ void map_init(int32_t size) } gGrassSceneryTileLoopPosition = 0; - gWidePathTileLoopX = 0; - gWidePathTileLoopY = 0; + gWidePathTileLoopPosition = {}; gMapSizeUnits = size * 32 - 32; gMapSizeMinus2 = size * 32 - 2; gMapSize = size; @@ -599,8 +597,8 @@ void map_update_path_wide_flags() // Presumably update_path_wide_flags is too computationally expensive to call for every // tile every update, so gWidePathTileLoopX and gWidePathTileLoopY store the x and y // progress. A maximum of 128 calls is done per update. - uint16_t x = gWidePathTileLoopX; - uint16_t y = gWidePathTileLoopY; + auto x = gWidePathTileLoopPosition.x; + auto y = gWidePathTileLoopPosition.y; for (int32_t i = 0; i < 128; i++) { footpath_update_path_wide_flags({ x, y }); @@ -617,8 +615,8 @@ void map_update_path_wide_flags() } } } - gWidePathTileLoopX = x; - gWidePathTileLoopY = y; + gWidePathTileLoopPosition.x = x; + gWidePathTileLoopPosition.y = y; } /** @@ -1484,7 +1482,7 @@ void map_update_tiles() if (gScreenFlags & ignoreScreenFlags) return; - // Update 43 more tiles + // Update 43 more tiles (for each 256x256 block) for (int32_t j = 0; j < 43; j++) { int32_t x = 0; @@ -1499,12 +1497,19 @@ void map_update_tiles() interleaved_xy >>= 1; } - auto mapPos = TileCoordsXY{ x, y }.ToCoordsXY(); - auto* surfaceElement = map_get_surface_element_at(mapPos); - if (surfaceElement != nullptr) + // Repeat for each 256x256 block on the map + for (int32_t blockY = 0; blockY < gMapSize; blockY += 256) { - surfaceElement->UpdateGrassLength(mapPos); - scenery_update_tile(mapPos); + for (int32_t blockX = 0; blockX < gMapSize; blockX += 256) + { + auto mapPos = TileCoordsXY{ blockX + x, blockY + y }.ToCoordsXY(); + auto* surfaceElement = map_get_surface_element_at(mapPos); + if (surfaceElement != nullptr) + { + surfaceElement->UpdateGrassLength(mapPos); + scenery_update_tile(mapPos); + } + } } gGrassSceneryTileLoopPosition++; diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index c1cf6f6b31..a9dddc5495 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -98,8 +98,7 @@ enum extern const std::array CoordsDirectionDelta; extern const TileCoordsXY TileDirectionDelta[]; -extern uint16_t gWidePathTileLoopX; -extern uint16_t gWidePathTileLoopY; +extern TileCoordsXY gWidePathTileLoopPosition; extern uint16_t gGrassSceneryTileLoopPosition; extern int16_t gMapSizeUnits; From 81d7c3f02b6370520c5c41d2dee878326fc2341f Mon Sep 17 00:00:00 2001 From: Ted John Date: Fri, 9 Apr 2021 02:09:08 +0100 Subject: [PATCH 28/39] Make tile elements dynamic and resizeable --- src/openrct2/interface/InteractiveConsole.cpp | 4 +- src/openrct2/network/NetworkBase.cpp | 1 - src/openrct2/rct1/S4Importer.cpp | 44 +-- src/openrct2/rct2/S6Importer.cpp | 35 +-- src/openrct2/ride/TrackDesign.cpp | 83 ++--- src/openrct2/world/Map.cpp | 284 ++++++++++-------- src/openrct2/world/Map.h | 25 +- src/openrct2/world/MapGen.cpp | 2 - test/tests/PlayTests.cpp | 1 - test/tests/S6ImportExportTests.cpp | 1 - 10 files changed, 235 insertions(+), 245 deletions(-) diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index be76cf1240..d4bcb31c38 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1247,8 +1247,8 @@ static int32_t cc_remove_park_fences(InteractiveConsole& console, [[maybe_unused static int32_t cc_show_limits(InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) { - map_reorganise_elements(); - int32_t tileElementCount = gNextFreeTileElement - gTileElements - 1; + const auto& tileElements = GetTileElements(); + int32_t tileElementCount = tileElements.size(); int32_t rideCount = ride_get_count(); int32_t spriteCount = 0; diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 5a500559e5..a4ee899bba 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -2770,7 +2770,6 @@ bool NetworkBase::LoadMap(IStream* stream) bool NetworkBase::SaveMap(IStream* stream, const std::vector& objects) const { bool result = false; - map_reorganise_elements(); viewport_set_saved_view(); try { diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 11dab91d4e..2ba5a6db61 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1483,38 +1483,44 @@ private: // Build tile pointer cache (needed to get the first element at a certain location) auto tilePointerIndex = TilePointerIndex(RCT1_MAX_MAP_SIZE, _s4.tile_elements); - TileElement* dstElement = gTileElements; - + std::vector tileElements; for (TileCoordsXY coords = { 0, 0 }; coords.y < MAXIMUM_MAP_SIZE_TECHNICAL; coords.y++) { for (coords.x = 0; coords.x < MAXIMUM_MAP_SIZE_TECHNICAL; coords.x++) { if (coords.x >= RCT1_MAX_MAP_SIZE || coords.y >= RCT1_MAX_MAP_SIZE) { - dstElement->ClearAs(TILE_ELEMENT_TYPE_SURFACE); - dstElement->SetLastForTile(true); - dstElement++; - continue; + auto& dstElement = tileElements.emplace_back(); + dstElement.ClearAs(TILE_ELEMENT_TYPE_SURFACE); + dstElement.SetLastForTile(true); } - - // This is the equivalent of map_get_first_element_at(x, y), but on S4 data. - RCT12TileElement* srcElement = tilePointerIndex.GetFirstElementAt(coords); - do + else { - if (srcElement->base_height == RCT12_MAX_ELEMENT_HEIGHT) - continue; + // This is the equivalent of map_get_first_element_at(x, y), but on S4 data. + RCT12TileElement* srcElement = tilePointerIndex.GetFirstElementAt(coords); + do + { + if (srcElement->base_height == RCT12_MAX_ELEMENT_HEIGHT) + continue; - auto numAddedElements = ImportTileElement(dstElement, srcElement); - dstElement += numAddedElements; - } while (!(srcElement++)->IsLastForTile()); + // Reserve 8 elements for import + auto originalSize = tileElements.size(); + tileElements.resize(originalSize + 16); + auto dstElement = tileElements.data() + originalSize; + auto numAddedElements = ImportTileElement(dstElement, srcElement); + tileElements.resize(originalSize + numAddedElements); + } while (!(srcElement++)->IsLastForTile()); - // Set last element flag in case the original last element was never added - (dstElement - 1)->SetLastForTile(true); + // Set last element flag in case the original last element was never added + if (tileElements.size() > 0) + { + tileElements.back().SetLastForTile(true); + } + } } } - map_update_tile_pointers(); - + SetTileElements(std::move(tileElements)); FixEntrancePositions(); } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index e1d075c976..b53146b107 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -465,7 +465,6 @@ public: // Fix and set dynamic variables map_strip_ghost_flag_from_elements(); - map_update_tile_pointers(); game_convert_strings_to_utf8(); map_count_remaining_land_rights(); determine_ride_entrance_and_exit_locations(); @@ -1040,16 +1039,16 @@ public: // Build tile pointer cache (needed to get the first element at a certain location) auto tilePointerIndex = TilePointerIndex(RCT2_MAXIMUM_MAP_SIZE_TECHNICAL, _s6.tile_elements); - TileElement* dstElement = gTileElements; + std::vector tileElements; for (TileCoordsXY coords = { 0, 0 }; coords.y < MAXIMUM_MAP_SIZE_TECHNICAL; coords.y++) { for (coords.x = 0; coords.x < MAXIMUM_MAP_SIZE_TECHNICAL; coords.x++) { if (coords.x >= RCT2_MAXIMUM_MAP_SIZE_TECHNICAL || coords.y >= RCT2_MAXIMUM_MAP_SIZE_TECHNICAL) { - dstElement->ClearAs(TILE_ELEMENT_TYPE_SURFACE); - dstElement->SetLastForTile(true); - dstElement++; + auto& dstElement = tileElements.emplace_back(); + dstElement.ClearAs(TILE_ELEMENT_TYPE_SURFACE); + dstElement.SetLastForTile(true); continue; } @@ -1057,17 +1056,18 @@ public: // This might happen with damaged parks. Make sure there is *something* to avoid crashes. if (srcElement == nullptr) { - dstElement->ClearAs(TILE_ELEMENT_TYPE_SURFACE); - dstElement->SetLastForTile(true); - dstElement++; + auto& dstElement = tileElements.emplace_back(); + dstElement.ClearAs(TILE_ELEMENT_TYPE_SURFACE); + dstElement.SetLastForTile(true); continue; } do { + auto& dstElement = tileElements.emplace_back(); if (srcElement->base_height == RCT12_MAX_ELEMENT_HEIGHT) { - std::memcpy(dstElement, srcElement, sizeof(*srcElement)); + std::memcpy(&dstElement, srcElement, sizeof(*srcElement)); } else { @@ -1076,19 +1076,20 @@ public: if (tileElementType == RCT12TileElementType::Corrupt || tileElementType == RCT12TileElementType::EightCarsCorrupt14 || tileElementType == RCT12TileElementType::EightCarsCorrupt15) - std::memcpy(dstElement, srcElement, sizeof(*srcElement)); + std::memcpy(&dstElement, srcElement, sizeof(*srcElement)); else - ImportTileElement(dstElement, srcElement); + ImportTileElement(&dstElement, srcElement); } - - dstElement++; } while (!(srcElement++)->IsLastForTile()); + + // Set last element flag in case the original last element was never added + if (tileElements.size() > 0) + { + tileElements.back().SetLastForTile(true); + } } } - - gNextFreeTileElementPointerIndex = _s6.next_free_tile_element_pointer_index; - - map_update_tile_pointers(); + SetTileElements(std::move(tileElements)); } void ImportTileElement(TileElement* dst, const RCT12TileElement* src) diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index f63e7c30a9..496b2c1e45 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -96,10 +96,6 @@ static bool _trackDesignPlaceStateHasScenery = false; static bool _trackDesignPlaceStatePlaceScenery = true; static bool _trackDesignPlaceIsReplay = false; -static std::unique_ptr track_design_preview_backup_map(); - -static void track_design_preview_restore_map(map_backup* backup); - static void track_design_preview_clear_map(); rct_string_id TrackDesign::CreateTrackDesign(const Ride& ride) @@ -1985,12 +1981,7 @@ static bool track_design_place_preview(TrackDesign* td6, money32* cost, Ride** o */ void track_design_draw_preview(TrackDesign* td6, uint8_t* pixels) { - // Make a copy of the map - auto mapBackup = track_design_preview_backup_map(); - if (mapBackup == nullptr) - { - return; - } + StashMap(); track_design_preview_clear_map(); if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) @@ -2004,7 +1995,7 @@ void track_design_draw_preview(TrackDesign* td6, uint8_t* pixels) if (!track_design_place_preview(td6, &cost, &ride, &flags)) { std::fill_n(pixels, TRACK_PREVIEW_IMAGE_SIZE * 4, 0x00); - track_design_preview_restore_map(mapBackup.get()); + UnstashMap(); return; } td6->cost = cost; @@ -2087,43 +2078,7 @@ void track_design_draw_preview(TrackDesign* td6, uint8_t* pixels) } ride->Delete(); - track_design_preview_restore_map(mapBackup.get()); -} - -/** - * Create a backup of the map as it will be cleared for drawing the track - * design preview. - * rct2: 0x006D1C68 - */ -static std::unique_ptr track_design_preview_backup_map() -{ - auto backup = std::make_unique(); - if (backup != nullptr) - { - std::memcpy(backup->tile_elements, gTileElements, sizeof(backup->tile_elements)); - std::memcpy(backup->tile_pointers, gTileElementTilePointers, sizeof(backup->tile_pointers)); - backup->next_free_tile_element = gNextFreeTileElement; - backup->map_size_units = gMapSizeUnits; - backup->map_size_units_minus_2 = gMapSizeMinus2; - backup->map_size = gMapSize; - backup->current_rotation = get_current_rotation(); - } - return backup; -} - -/** - * Restores the map from a backup. - * rct2: 0x006D2378 - */ -static void track_design_preview_restore_map(map_backup* backup) -{ - std::memcpy(gTileElements, backup->tile_elements, sizeof(backup->tile_elements)); - std::memcpy(gTileElementTilePointers, backup->tile_pointers, sizeof(backup->tile_pointers)); - gNextFreeTileElement = backup->next_free_tile_element; - gMapSizeUnits = backup->map_size_units; - gMapSizeMinus2 = backup->map_size_units_minus_2; - gMapSize = backup->map_size; - gCurrentRotation = backup->current_rotation; + UnstashMap(); } /** @@ -2132,26 +2087,30 @@ static void track_design_preview_restore_map(map_backup* backup) */ static void track_design_preview_clear_map() { - // These values were previously allocated in backup map but - // it seems more fitting to place in this function + auto numTiles = MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL; + gMapSizeUnits = 255 * COORDS_XY_STEP; gMapSizeMinus2 = (264 * 32) - 2; gMapSize = 256; - for (int32_t i = 0; i < MAX_TILE_TILE_ELEMENT_POINTERS; i++) + // Reserve ~8 elements per tile + std::vector tileElements; + tileElements.reserve(numTiles * 8); + + for (int32_t i = 0; i < numTiles; i++) { - TileElement* tile_element = &gTileElements[i]; - tile_element->ClearAs(TILE_ELEMENT_TYPE_SURFACE); - tile_element->SetLastForTile(true); - tile_element->AsSurface()->SetSlope(TILE_ELEMENT_SLOPE_FLAT); - tile_element->AsSurface()->SetWaterHeight(0); - tile_element->AsSurface()->SetSurfaceStyle(0); - tile_element->AsSurface()->SetEdgeStyle(0); - tile_element->AsSurface()->SetGrassLength(GRASS_LENGTH_CLEAR_0); - tile_element->AsSurface()->SetOwnership(OWNERSHIP_OWNED); - tile_element->AsSurface()->SetParkFences(0); + auto* element = &tileElements.emplace_back(); + element->ClearAs(TILE_ELEMENT_TYPE_SURFACE); + element->SetLastForTile(true); + element->AsSurface()->SetSlope(TILE_ELEMENT_SLOPE_FLAT); + element->AsSurface()->SetWaterHeight(0); + element->AsSurface()->SetSurfaceStyle(0); + element->AsSurface()->SetEdgeStyle(0); + element->AsSurface()->SetGrassLength(GRASS_LENGTH_CLEAR_0); + element->AsSurface()->SetOwnership(OWNERSHIP_OWNED); + element->AsSurface()->SetParkFences(0); } - map_update_tile_pointers(); + SetTileElements(std::move(tileElements)); } bool track_design_are_entrance_and_exit_placed() diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 1d70a4e1e8..2979ebd270 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -81,6 +81,8 @@ const std::array CoordsDirectionDelta = { const TileCoordsXY TileDirectionDelta[] = { { -1, 0 }, { 0, +1 }, { +1, 0 }, { 0, -1 }, { -1, +1 }, { +1, +1 }, { +1, -1 }, { -1, -1 } }; +constexpr size_t MIN_TILE_ELEMENTS = 1024; + uint16_t gMapSelectFlags; uint16_t gMapSelectType; CoordsXY gMapSelectPositionA; @@ -99,14 +101,9 @@ int16_t gMapSize; int16_t gMapSizeMaxXY; int16_t gMapBaseZ; -TileElement gTileElements[MAX_TILE_ELEMENTS_WITH_SPARE_ROOM]; -TileElement* gTileElementTilePointers[MAX_TILE_TILE_ELEMENT_POINTERS]; std::vector gMapSelectionTiles; std::vector gPeepSpawns; -TileElement* gNextFreeTileElement; -uint32_t gNextFreeTileElementPointerIndex; - bool gLandMountainMode; bool gLandPaintMode; bool gClearSmallScenery; @@ -118,6 +115,114 @@ uint16_t gLandRemainingConstructionSales; bool gMapLandRightsUpdateSuccess; +static TilePointerIndex _tileIndex; +static std::vector _tileElements; +static TilePointerIndex _tileIndexStash; +static std::vector _tileElementsStash; +static int32_t _mapSizeUnitsStash; +static int32_t _mapSizeMinus2Stash; +static int32_t _mapSizeStash; +static int32_t _currentRotationStash; + +void StashMap() +{ + _tileIndexStash = std::move(_tileIndex); + _tileElementsStash = std::move(_tileElements); + _mapSizeUnitsStash = gMapSizeUnits; + _mapSizeMinus2Stash = gMapSizeMinus2; + _mapSizeStash = gMapSize; + _currentRotationStash = gCurrentRotation; +} + +void UnstashMap() +{ + _tileIndex = std::move(_tileIndexStash); + _tileElements = std::move(_tileElementsStash); + gMapSizeUnits = _mapSizeUnitsStash; + gMapSizeMinus2 = _mapSizeMinus2Stash; + gMapSize = _mapSizeStash; + gCurrentRotation = _currentRotationStash; +} + +const std::vector& GetTileElements() +{ + return _tileElements; +} + +void SetTileElements(std::vector&& tileElements) +{ + _tileElements = std::move(tileElements); + _tileIndex = TilePointerIndex(MAXIMUM_MAP_SIZE_TECHNICAL, _tileElements.data()); +} + +static void ReorganiseTileElements(size_t capacity) +{ + context_setcurrentcursor(CursorID::ZZZ); + + std::vector newElements; + newElements.reserve(std::max(MIN_TILE_ELEMENTS, capacity)); + for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++) + { + for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++) + { + const auto* element = map_get_first_element_at(TileCoordsXY{ x, y }.ToCoordsXY()); + if (element == nullptr) + { + auto& newElement = newElements.emplace_back(); + newElement.ClearAs(TILE_ELEMENT_TYPE_SURFACE); + newElement.SetLastForTile(true); + newElement.base_height = 14; + newElement.clearance_height = 14; + newElement.AsSurface()->SetWaterHeight(0); + newElement.AsSurface()->SetSlope(TILE_ELEMENT_SLOPE_FLAT); + newElement.AsSurface()->SetGrassLength(GRASS_LENGTH_CLEAR_0); + newElement.AsSurface()->SetOwnership(OWNERSHIP_UNOWNED); + newElement.AsSurface()->SetParkFences(0); + newElement.AsSurface()->SetSurfaceStyle(0); + newElement.AsSurface()->SetEdgeStyle(0); + } + else + { + do + { + newElements.push_back(*element); + } while (!(element++)->IsLastForTile()); + } + } + } + + SetTileElements(std::move(newElements)); +} + +void ReorganiseTileElements() +{ + ReorganiseTileElements(_tileElements.size()); +} + +bool map_check_free_elements_and_reorganise(size_t numElements) +{ + auto freeElements = _tileElements.capacity() - _tileElements.size(); + if (freeElements >= numElements) + { + return true; + } + else + { + auto newCapacity = std::min(MAX_TILE_ELEMENTS, _tileElements.capacity() * 2); + if (newCapacity - _tileElements.size() < numElements) + { + // Limit reached + gGameCommandErrorText = STR_ERR_LANDSCAPE_DATA_AREA_FULL; + return false; + } + else + { + ReorganiseTileElements(newCapacity); + return true; + } + } +} + static void clear_elements_at(const CoordsXY& loc); static ScreenCoordsXY translate_3d_to_2d(int32_t rotation, const CoordsXY& pos); @@ -173,7 +278,7 @@ TileElement* map_get_first_element_at(const CoordsXY& elementPos) return nullptr; } auto tileElementPos = TileCoordsXY{ elementPos }; - return gTileElementTilePointers[tileElementPos.x + tileElementPos.y * MAXIMUM_MAP_SIZE_TECHNICAL]; + return _tileIndex.GetFirstElementAt(tileElementPos); } TileElement* map_get_nth_element_at(const CoordsXY& coords, int32_t n) @@ -210,7 +315,7 @@ void map_set_tile_element(const TileCoordsXY& tilePos, TileElement* elements) log_error("Trying to access element outside of range"); return; } - gTileElementTilePointers[tilePos.x + tilePos.y * MAXIMUM_MAP_SIZE_TECHNICAL] = elements; + _tileIndex.SetTile(tilePos, elements); } SurfaceElement* map_get_surface_element_at(const CoordsXY& coords) @@ -253,23 +358,26 @@ BannerElement* map_get_banner_element_at(const CoordsXYZ& bannerPos, uint8_t pos */ void map_init(int32_t size) { - gNextFreeTileElementPointerIndex = 0; + auto numTiles = MAXIMUM_MAP_SIZE_TECHNICAL * MAXIMUM_MAP_SIZE_TECHNICAL; - for (int32_t i = 0; i < MAX_TILE_TILE_ELEMENT_POINTERS; i++) + std::vector tileElements; + tileElements.resize(numTiles); + for (int32_t i = 0; i < numTiles; i++) { - TileElement* tile_element = &gTileElements[i]; - tile_element->ClearAs(TILE_ELEMENT_TYPE_SURFACE); - tile_element->SetLastForTile(true); - tile_element->base_height = 14; - tile_element->clearance_height = 14; - tile_element->AsSurface()->SetWaterHeight(0); - tile_element->AsSurface()->SetSlope(TILE_ELEMENT_SLOPE_FLAT); - tile_element->AsSurface()->SetGrassLength(GRASS_LENGTH_CLEAR_0); - tile_element->AsSurface()->SetOwnership(OWNERSHIP_UNOWNED); - tile_element->AsSurface()->SetParkFences(0); - tile_element->AsSurface()->SetSurfaceStyle(0); - tile_element->AsSurface()->SetEdgeStyle(0); + auto* element = &tileElements[i]; + element->ClearAs(TILE_ELEMENT_TYPE_SURFACE); + element->SetLastForTile(true); + element->base_height = 14; + element->clearance_height = 14; + element->AsSurface()->SetWaterHeight(0); + element->AsSurface()->SetSlope(TILE_ELEMENT_SLOPE_FLAT); + element->AsSurface()->SetGrassLength(GRASS_LENGTH_CLEAR_0); + element->AsSurface()->SetOwnership(OWNERSHIP_UNOWNED); + element->AsSurface()->SetParkFences(0); + element->AsSurface()->SetSurfaceStyle(0); + element->AsSurface()->SetEdgeStyle(0); } + SetTileElements(std::move(tileElements)); gGrassSceneryTileLoopPosition = 0; gWidePathTileLoopPosition = {}; @@ -278,7 +386,6 @@ void map_init(int32_t size) gMapSize = size; gMapSizeMaxXY = size * 32 - 33; gMapBaseZ = 7; - map_update_tile_pointers(); map_remove_out_of_range_elements(); AutoCreateMapAnimations(); @@ -338,40 +445,12 @@ void map_count_remaining_land_rights() */ void map_strip_ghost_flag_from_elements() { - for (auto& element : gTileElements) + for (auto& element : _tileElements) { element.SetGhost(false); } } -/** - * - * rct2: 0x0068AFFD - */ -void map_update_tile_pointers() -{ - int32_t i, x, y; - - for (i = 0; i < MAX_TILE_TILE_ELEMENT_POINTERS; i++) - { - gTileElementTilePointers[i] = TILE_UNDEFINED_TILE_ELEMENT; - } - - TileElement* tileElement = gTileElements; - TileElement** tile = gTileElementTilePointers; - for (y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++) - { - for (x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++) - { - *tile++ = tileElement; - while (!(tileElement++)->IsLastForTile()) - ; - } - } - - gNextFreeTileElement = tileElement; -} - /** * Return the absolute height of an element, given its (x,y) coordinates * @@ -925,9 +1004,9 @@ void tile_element_remove(TileElement* tileElement) (tileElement - 1)->SetLastForTile(true); tileElement->base_height = MAX_ELEMENT_HEIGHT; - if ((tileElement + 1) == gNextFreeTileElement) + if ((tileElement + 1) == &_tileElements[_tileElements.size()]) { - gNextFreeTileElement--; + _tileElements.pop_back(); } } @@ -1029,77 +1108,28 @@ void map_invalidate_selection_rect() viewports_invalidate(left, top, right, bottom); } -/** - * - * rct2: 0x0068B111 - */ -void map_reorganise_elements() +static size_t CountElementsOnTile(const CoordsXY& loc) { - context_setcurrentcursor(CursorID::ZZZ); - - auto newTileElements = std::make_unique(MAX_TILE_ELEMENTS_WITH_SPARE_ROOM); - TileElement* newElementsPtr = newTileElements.get(); - - if (newTileElements == nullptr) + size_t count = 0; + auto* element = _tileIndex.GetFirstElementAt(TileCoordsXY(loc)); + do { - log_fatal("Unable to allocate memory for map elements."); - return; - } - - for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++) - { - for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++) - { - TileElement* startElement = map_get_first_element_at(TileCoordsXY{ x, y }.ToCoordsXY()); - if (startElement == nullptr) - continue; - TileElement* endElement = startElement; - while (!(endElement++)->IsLastForTile()) - ; - - const auto numElements = static_cast(endElement - startElement); - std::memcpy(newElementsPtr, startElement, numElements * sizeof(TileElement)); - newElementsPtr += numElements; - } - } - - const auto numElements = static_cast(newElementsPtr - newTileElements.get()); - std::memcpy(gTileElements, newTileElements.get(), numElements * sizeof(TileElement)); - std::memset(gTileElements + numElements, 0, (MAX_TILE_ELEMENTS_WITH_SPARE_ROOM - numElements) * sizeof(TileElement)); - - map_update_tile_pointers(); + count++; + } while (!(element++)->IsLastForTile()); + return count; } -/** - * - * rct2: 0x0068B044 - * Returns true on space available for more elements - * Reorganises the map elements to check for space - */ -bool map_check_free_elements_and_reorganise(int32_t numElements) +static TileElement* AllocateTileElements(size_t count) { - if (numElements != 0) + if (!map_check_free_elements_and_reorganise(count)) { - auto tileElementEnd = &gTileElements[MAX_TILE_ELEMENTS]; - - // Check if is there is room for the required number of elements - auto newTileElementEnd = gNextFreeTileElement + numElements; - if (newTileElementEnd > tileElementEnd) - { - // Defragment the map element list - map_reorganise_elements(); - - // Check if there is any room again - newTileElementEnd = gNextFreeTileElement + numElements; - if (newTileElementEnd > tileElementEnd) - { - // Not enough spare elements left :'( - gGameCommandErrorText = STR_ERR_LANDSCAPE_DATA_AREA_FULL; - return false; - } - } + log_error("Cannot insert new element"); + return nullptr; } - return true; + + auto oldSize = _tileElements.size(); + _tileElements.resize(_tileElements.size() + count); + return &_tileElements[oldSize]; } /** @@ -1109,21 +1139,16 @@ bool map_check_free_elements_and_reorganise(int32_t numElements) TileElement* tile_element_insert(const CoordsXYZ& loc, int32_t occupiedQuadrants, TileElementType type) { const auto& tileLoc = TileCoordsXYZ(loc); - TileElement *originalTileElement, *newTileElement, *insertedElement; - bool isLastForTile = false; - if (!map_check_free_elements_and_reorganise(1)) - { - log_error("Cannot insert new element"); - return nullptr; - } - - newTileElement = gNextFreeTileElement; - originalTileElement = gTileElementTilePointers[tileLoc.y * MAXIMUM_MAP_SIZE_TECHNICAL + tileLoc.x]; + auto numElementsOnTileOld = CountElementsOnTile(loc); + auto numElementsOnTileNew = numElementsOnTileOld + 1; + auto* newTileElement = AllocateTileElements(numElementsOnTileNew); + auto* originalTileElement = _tileIndex.GetFirstElementAt(tileLoc); // Set tile index pointer to point to new element block - gTileElementTilePointers[tileLoc.y * MAXIMUM_MAP_SIZE_TECHNICAL + tileLoc.x] = newTileElement; + _tileIndex.SetTile(tileLoc, newTileElement); + bool isLastForTile = false; if (originalTileElement == nullptr) { isLastForTile = true; @@ -1150,7 +1175,7 @@ TileElement* tile_element_insert(const CoordsXYZ& loc, int32_t occupiedQuadrants } // Insert new map element - insertedElement = newTileElement; + auto* insertedElement = newTileElement; newTileElement->type = 0; newTileElement->SetType(static_cast(type)); newTileElement->SetBaseZ(loc.z); @@ -1176,7 +1201,6 @@ TileElement* tile_element_insert(const CoordsXYZ& loc, int32_t occupiedQuadrants } while (!((newTileElement - 1)->IsLastForTile())); } - gNextFreeTileElement = newTileElement; return insertedElement; } diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index a9dddc5495..707453b588 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -116,15 +116,9 @@ extern uint8_t gMapSelectArrowDirection; extern uint8_t gMapGroundFlags; -extern TileElement gTileElements[MAX_TILE_ELEMENTS_WITH_SPARE_ROOM]; -extern TileElement* gTileElementTilePointers[MAX_TILE_TILE_ELEMENT_POINTERS]; - extern std::vector gMapSelectionTiles; extern std::vector gPeepSpawns; -extern TileElement* gNextFreeTileElement; -extern uint32_t gNextFreeTileElementPointerIndex; - // Used in the land tool window to enable mountain tool / land smoothing extern bool gLandMountainMode; // Used in the land tool window to allow dragging and changing land styles @@ -146,9 +140,11 @@ extern const uint8_t tile_element_raise_styles[9][32]; template class TilePointerIndex { std::vector TilePointers; - uint16_t MapSize; + uint16_t MapSize{}; public: + TilePointerIndex() = default; + explicit TilePointerIndex(const uint16_t mapSize, T* tileElements) { MapSize = mapSize; @@ -171,13 +167,23 @@ public: { return TilePointers[coords.x + (coords.y * MapSize)]; } + + void SetTile(TileCoordsXY coords, T* tileElement) + { + TilePointers[coords.x + (coords.y * MapSize)] = tileElement; + } }; +void ReorganiseTileElements(); +const std::vector& GetTileElements(); +void SetTileElements(std::vector&& tileElements); +void StashMap(); +void UnstashMap(); + void map_init(int32_t size); void map_count_remaining_land_rights(); void map_strip_ghost_flag_from_elements(); -void map_update_tile_pointers(); TileElement* map_get_first_element_at(const CoordsXY& elementPos); TileElement* map_get_nth_element_at(const CoordsXY& coords, int32_t n); void map_set_tile_element(const TileCoordsXY& tilePos, TileElement* elements); @@ -210,8 +216,7 @@ void tile_element_remove(TileElement* tileElement); void map_remove_all_rides(); void map_invalidate_map_selection_tiles(); void map_invalidate_selection_rect(); -void map_reorganise_elements(); -bool map_check_free_elements_and_reorganise(int32_t num_elements); +bool map_check_free_elements_and_reorganise(size_t num_elements); TileElement* tile_element_insert(const CoordsXYZ& loc, int32_t occupiedQuadrants, TileElementType type); template T* TileElementInsert(const CoordsXYZ& loc, int32_t occupiedQuadrants) diff --git a/src/openrct2/world/MapGen.cpp b/src/openrct2/world/MapGen.cpp index d6753302c8..cefb0081e6 100644 --- a/src/openrct2/world/MapGen.cpp +++ b/src/openrct2/world/MapGen.cpp @@ -231,8 +231,6 @@ void mapgen_generate(mapgen_settings* settings) // Place the trees if (settings->trees != 0) mapgen_place_trees(); - - map_reorganise_elements(); } static void mapgen_place_tree(int32_t type, const CoordsXY& loc) diff --git a/test/tests/PlayTests.cpp b/test/tests/PlayTests.cpp index 3b41fb0bfb..da1ca52753 100644 --- a/test/tests/PlayTests.cpp +++ b/test/tests/PlayTests.cpp @@ -54,7 +54,6 @@ static std::unique_ptr localStartGame(const std::string& parkPath) reset_all_sprite_quadrant_placements(); scenery_set_default_placement_configuration(); load_palette(); - map_reorganise_elements(); EntityTweener::Get().Reset(); AutoCreateMapAnimations(); fix_invalid_vehicle_sprite_sizes(); diff --git a/test/tests/S6ImportExportTests.cpp b/test/tests/S6ImportExportTests.cpp index 7044adfa16..3f27396092 100644 --- a/test/tests/S6ImportExportTests.cpp +++ b/test/tests/S6ImportExportTests.cpp @@ -75,7 +75,6 @@ static void GameInit(bool retainSpatialIndices) reset_all_sprite_quadrant_placements(); scenery_set_default_placement_configuration(); load_palette(); - map_reorganise_elements(); EntityTweener::Get().Reset(); AutoCreateMapAnimations(); fix_invalid_vehicle_sprite_sizes(); From c9777535d6ee7d5092744ba463e3d65dc5d8be1b Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sun, 30 May 2021 09:09:47 +0100 Subject: [PATCH 29/39] Fix export --- src/openrct2/interface/InteractiveConsole.cpp | 4 ++-- src/openrct2/rct2/S6Exporter.cpp | 20 +++++++++++-------- src/openrct2/rct2/S6Exporter.h | 2 +- src/openrct2/world/Map.cpp | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index d4bcb31c38..cc5741263f 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1248,7 +1248,7 @@ static int32_t cc_remove_park_fences(InteractiveConsole& console, [[maybe_unused static int32_t cc_show_limits(InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) { const auto& tileElements = GetTileElements(); - int32_t tileElementCount = tileElements.size(); + const auto tileElementCount = tileElements.size(); int32_t rideCount = ride_get_count(); int32_t spriteCount = 0; @@ -1270,7 +1270,7 @@ static int32_t cc_show_limits(InteractiveConsole& console, [[maybe_unused]] cons } console.WriteFormatLine("Sprites: %d/%d", spriteCount, MAX_ENTITIES); - console.WriteFormatLine("Map Elements: %d/%d", tileElementCount, MAX_TILE_ELEMENTS); + console.WriteFormatLine("Map Elements: %zu/%d", tileElementCount, MAX_TILE_ELEMENTS); console.WriteFormatLine("Banners: %d/%zu", bannerCount, MAX_BANNERS); console.WriteFormatLine("Rides: %d/%d", rideCount, MAX_RIDES); console.WriteFormatLine("Staff: %d/%d", staffCount, STAFF_MAX_COUNT); diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 281f246c10..f292ccc43a 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -194,8 +194,7 @@ void S6Exporter::Export() _s6.scenario_srand_0 = state.s0; _s6.scenario_srand_1 = state.s1; - // Map elements must be reorganised prior to saving otherwise save may be invalid - map_reorganise_elements(); + ReorganiseTileElements(); ExportTileElements(); ExportEntities(); ExportParkName(); @@ -419,8 +418,8 @@ void S6Exporter::Export() // pad_13CE730 // rct1_scenario_flags - _s6.wide_path_tile_loop_x = gWidePathTileLoopX; - _s6.wide_path_tile_loop_y = gWidePathTileLoopY; + _s6.wide_path_tile_loop_x = gWidePathTileLoopPosition.x; + _s6.wide_path_tile_loop_y = gWidePathTileLoopPosition.y; // pad_13CE778 String::Set(_s6.scenario_filename, sizeof(_s6.scenario_filename), gScenarioFileName); @@ -1580,10 +1579,16 @@ void S6Exporter::ExportMapAnimations() void S6Exporter::ExportTileElements() { + const auto& tileElements = GetTileElements(); for (uint32_t index = 0; index < RCT2_MAX_TILE_ELEMENTS; index++) { - auto src = &gTileElements[index]; auto dst = &_s6.tile_elements[index]; + if (index >= tileElements.size()) + { + dst = {}; + continue; + } + auto src = &tileElements[index]; if (src->base_height == MAX_ELEMENT_HEIGHT) { std::memcpy(dst, src, sizeof(*dst)); @@ -1598,10 +1603,10 @@ void S6Exporter::ExportTileElements() ExportTileElement(dst, src); } } - _s6.next_free_tile_element_pointer_index = gNextFreeTileElementPointerIndex; + _s6.next_free_tile_element_pointer_index = static_cast(tileElements.size()); } -void S6Exporter::ExportTileElement(RCT12TileElement* dst, TileElement* src) +void S6Exporter::ExportTileElement(RCT12TileElement* dst, const TileElement* src) { // Todo: allow for changing definition of OpenRCT2 tile element types - replace with a map uint8_t tileElementType = src->GetType(); @@ -1852,7 +1857,6 @@ int32_t scenario_save(const utf8* path, int32_t flags) window_close_construction_windows(); } - map_reorganise_elements(); viewport_set_saved_view(); bool result = false; diff --git a/src/openrct2/rct2/S6Exporter.h b/src/openrct2/rct2/S6Exporter.h index 96485063c5..bc673854b7 100644 --- a/src/openrct2/rct2/S6Exporter.h +++ b/src/openrct2/rct2/S6Exporter.h @@ -73,7 +73,7 @@ private: void ExportMapAnimations(); void ExportTileElements(); - void ExportTileElement(RCT12TileElement* dst, TileElement* src); + void ExportTileElement(RCT12TileElement* dst, const TileElement* src); std::optional AllocateUserString(std::string_view value); void ExportUserStrings(); diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 2979ebd270..6492ca40fe 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1004,7 +1004,7 @@ void tile_element_remove(TileElement* tileElement) (tileElement - 1)->SetLastForTile(true); tileElement->base_height = MAX_ELEMENT_HEIGHT; - if ((tileElement + 1) == &_tileElements[_tileElements.size()]) + if (tileElement == &_tileElements.back()) { _tileElements.pop_back(); } From c7c634e825b544d57e3ffc9338e84b4c46e30fae Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sat, 5 Jun 2021 21:19:06 +0100 Subject: [PATCH 30/39] Readd comment --- src/openrct2/rct2/S6Exporter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index f292ccc43a..231659f58d 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -194,6 +194,7 @@ void S6Exporter::Export() _s6.scenario_srand_0 = state.s0; _s6.scenario_srand_1 = state.s1; + // Map elements must be reorganised prior to saving otherwise save may be invalid ReorganiseTileElements(); ExportTileElements(); ExportEntities(); From c1c9353dd2dd3e9d242cadd773dd24b9097d773d Mon Sep 17 00:00:00 2001 From: OpenRCT2 git bot Date: Sun, 6 Jun 2021 05:00:05 +0000 Subject: [PATCH 31/39] Merge Localisation/master into OpenRCT2/develop --- data/language/de-DE.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/data/language/de-DE.txt b/data/language/de-DE.txt index 6984cbbe00..9e5b5c57fc 100644 --- a/data/language/de-DE.txt +++ b/data/language/de-DE.txt @@ -3680,6 +3680,18 @@ STR_6437 :Unsichtbar STR_6438 :U STR_6439 :Kachelinspektor: Unsichtbarkeit umschalten STR_6440 :Transparentes Wasser +STR_6441 :Mindestens ein Nicht-Warteschlangenfußwegbelagsobjekt muss ausgewählt sein. +STR_6442 :Mindestens ein Warteschlangenfußwegbelagsobjekt muss ausgewählt sein. +STR_6443 :Mindestens ein Fußweggeländerobjekt muss ausgewählt sein. +STR_6444 :Fußwegbelage +STR_6445 :Fußweggeländer +STR_6446 :{WINDOW_COLOUR_2}Belagsname: {BLACK}{STRINGID} +STR_6447 :{WINDOW_COLOUR_2}Geländername: {BLACK}{STRINGID} +STR_6448 :Nicht unterstütztes Objektformat +STR_6449 :{WINDOW_COLOUR_2}Titel: +STR_6450 :{BLACK}„{STRING}“ +STR_6451 :{BLACK}„{STRING}“ - {STRING} +STR_6452 :{WINDOW_COLOUR_2}Verkauft: {BLACK}{STRING} ############# # Scenarios # From b2c0c3e24685a72ba6b9d88c4927b9fd8c21e366 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sun, 6 Jun 2021 08:28:07 +0100 Subject: [PATCH 32/39] Handle reaching tile element limits more gracefully --- src/openrct2/actions/BannerPlaceAction.cpp | 4 ++-- src/openrct2/actions/FootpathPlaceAction.cpp | 2 +- .../actions/FootpathPlaceFromTrackAction.cpp | 2 +- .../actions/LargeSceneryPlaceAction.cpp | 20 ++++++++++++++-- .../actions/LargeSceneryPlaceAction.h | 1 + src/openrct2/actions/MazePlaceTrackAction.cpp | 4 ++-- src/openrct2/actions/MazeSetTrackAction.cpp | 4 ++-- .../actions/PlaceParkEntranceAction.cpp | 24 ++++++++++++++++++- .../actions/PlaceParkEntranceAction.h | 3 +++ src/openrct2/actions/PlacePeepSpawnAction.cpp | 6 ----- .../actions/RideEntranceExitPlaceAction.cpp | 4 ++-- .../actions/SmallSceneryPlaceAction.cpp | 2 +- src/openrct2/actions/TrackPlaceAction.cpp | 17 ++++++++++++- src/openrct2/actions/TrackPlaceAction.h | 3 +++ src/openrct2/actions/WallPlaceAction.cpp | 4 ++-- src/openrct2/world/Map.cpp | 14 ++++++++++- src/openrct2/world/Map.h | 2 +- src/openrct2/world/TileInspector.cpp | 4 ++-- 18 files changed, 93 insertions(+), 27 deletions(-) diff --git a/src/openrct2/actions/BannerPlaceAction.cpp b/src/openrct2/actions/BannerPlaceAction.cpp index 92b7a1e872..3f982a71de 100644 --- a/src/openrct2/actions/BannerPlaceAction.cpp +++ b/src/openrct2/actions/BannerPlaceAction.cpp @@ -55,7 +55,7 @@ GameActions::Result::Ptr BannerPlaceAction::Query() const res->Expenditure = ExpenditureType::Landscaping; res->ErrorTitle = STR_CANT_POSITION_THIS_HERE; - if (!map_check_free_elements_and_reorganise(1)) + if (!MapCheckCapacityAndReorganise(_loc)) { log_error("No free map elements."); return MakeResult(GameActions::Status::NoFreeElements, STR_CANT_POSITION_THIS_HERE); @@ -118,7 +118,7 @@ GameActions::Result::Ptr BannerPlaceAction::Execute() const res->Expenditure = ExpenditureType::Landscaping; res->ErrorTitle = STR_CANT_POSITION_THIS_HERE; - if (!map_check_free_elements_and_reorganise(1)) + if (!MapCheckCapacityAndReorganise(_loc)) { log_error("No free map elements."); return MakeResult(GameActions::Status::NoFreeElements, STR_CANT_POSITION_THIS_HERE); diff --git a/src/openrct2/actions/FootpathPlaceAction.cpp b/src/openrct2/actions/FootpathPlaceAction.cpp index 7e0373f93e..2662388e1d 100644 --- a/src/openrct2/actions/FootpathPlaceAction.cpp +++ b/src/openrct2/actions/FootpathPlaceAction.cpp @@ -216,7 +216,7 @@ GameActions::Result::Ptr FootpathPlaceAction::ElementInsertQuery(GameActions::Re { bool entrancePath = false, entranceIsSamePath = false; - if (!map_check_free_elements_and_reorganise(1)) + if (!MapCheckCapacityAndReorganise(_loc)) { return MakeResult(GameActions::Status::NoFreeElements, STR_CANT_BUILD_FOOTPATH_HERE); } diff --git a/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp b/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp index ea9407091c..fa89fd0aed 100644 --- a/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp +++ b/src/openrct2/actions/FootpathPlaceFromTrackAction.cpp @@ -100,7 +100,7 @@ GameActions::Result::Ptr FootpathPlaceFromTrackAction::ElementInsertQuery(GameAc { bool entrancePath = false, entranceIsSamePath = false; - if (!map_check_free_elements_and_reorganise(1)) + if (!MapCheckCapacityAndReorganise(_loc)) { return MakeResult(GameActions::Status::NoFreeElements, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE); } diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.cpp b/src/openrct2/actions/LargeSceneryPlaceAction.cpp index f489835930..ef01934c08 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.cpp +++ b/src/openrct2/actions/LargeSceneryPlaceAction.cpp @@ -142,7 +142,7 @@ GameActions::Result::Ptr LargeSceneryPlaceAction::Query() const } } - if (!map_check_free_elements_and_reorganise(totalNumTiles)) + if (!CheckMapCapacity(sceneryEntry->tiles, totalNumTiles)) { log_error("No free map elements available"); return std::make_unique(GameActions::Status::NoFreeElements); @@ -240,7 +240,7 @@ GameActions::Result::Ptr LargeSceneryPlaceAction::Execute() const res->Position.z = maxHeight; - if (!map_check_free_elements_and_reorganise(totalNumTiles)) + if (!CheckMapCapacity(sceneryEntry->tiles, totalNumTiles)) { log_error("No free map elements available"); return std::make_unique(GameActions::Status::NoFreeElements); @@ -340,6 +340,22 @@ int16_t LargeSceneryPlaceAction::GetTotalNumTiles(rct_large_scenery_tile* tiles) return totalNumTiles; } +bool LargeSceneryPlaceAction::CheckMapCapacity(rct_large_scenery_tile* tiles, int16_t numTiles) const +{ + for (rct_large_scenery_tile* tile = tiles; tile->x_offset != -1; tile++) + { + auto curTile = CoordsXY{ tile->x_offset, tile->y_offset }.Rotate(_loc.direction); + + curTile.x += _loc.x; + curTile.y += _loc.y; + if (!MapCheckCapacityAndReorganise(curTile, numTiles)) + { + return false; + } + } + return true; +} + int16_t LargeSceneryPlaceAction::GetMaxSurfaceHeight(rct_large_scenery_tile* tiles) const { int16_t maxHeight = -1; diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.h b/src/openrct2/actions/LargeSceneryPlaceAction.h index 2aa7d264df..e96ea00278 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.h +++ b/src/openrct2/actions/LargeSceneryPlaceAction.h @@ -50,6 +50,7 @@ public: private: int16_t GetTotalNumTiles(rct_large_scenery_tile * tiles) const; + bool CheckMapCapacity(rct_large_scenery_tile * tiles, int16_t numTiles) const; int16_t GetMaxSurfaceHeight(rct_large_scenery_tile * tiles) const; void SetNewLargeSceneryElement(LargeSceneryElement & sceneryElement, uint8_t tileNum) const; }; diff --git a/src/openrct2/actions/MazePlaceTrackAction.cpp b/src/openrct2/actions/MazePlaceTrackAction.cpp index 71b18401c2..0b5f7d356e 100644 --- a/src/openrct2/actions/MazePlaceTrackAction.cpp +++ b/src/openrct2/actions/MazePlaceTrackAction.cpp @@ -39,7 +39,7 @@ GameActions::Result::Ptr MazePlaceTrackAction::Query() const res->Position = _loc + CoordsXYZ{ 8, 8, 0 }; res->Expenditure = ExpenditureType::RideConstruction; res->ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE; - if (!map_check_free_elements_and_reorganise(1)) + if (!MapCheckCapacityAndReorganise(_loc)) { res->Error = GameActions::Status::NoFreeElements; res->ErrorMessage = STR_TILE_ELEMENT_LIMIT_REACHED; @@ -137,7 +137,7 @@ GameActions::Result::Ptr MazePlaceTrackAction::Execute() const return res; } - if (!map_check_free_elements_and_reorganise(1)) + if (!MapCheckCapacityAndReorganise(_loc)) { res->Error = GameActions::Status::NoFreeElements; res->ErrorMessage = STR_NONE; diff --git a/src/openrct2/actions/MazeSetTrackAction.cpp b/src/openrct2/actions/MazeSetTrackAction.cpp index 3c5af361ed..322811c418 100644 --- a/src/openrct2/actions/MazeSetTrackAction.cpp +++ b/src/openrct2/actions/MazeSetTrackAction.cpp @@ -51,7 +51,7 @@ GameActions::Result::Ptr MazeSetTrackAction::Query() const res->Position = _loc + CoordsXYZ{ 8, 8, 0 }; res->Expenditure = ExpenditureType::RideConstruction; res->ErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE; - if (!map_check_free_elements_and_reorganise(1)) + if (!MapCheckCapacityAndReorganise(_loc)) { res->Error = GameActions::Status::NoFreeElements; res->ErrorMessage = STR_TILE_ELEMENT_LIMIT_REACHED; @@ -159,7 +159,7 @@ GameActions::Result::Ptr MazeSetTrackAction::Execute() const return res; } - if (!map_check_free_elements_and_reorganise(1)) + if (!MapCheckCapacityAndReorganise(_loc)) { res->Error = GameActions::Status::NoFreeElements; res->ErrorMessage = STR_NONE; diff --git a/src/openrct2/actions/PlaceParkEntranceAction.cpp b/src/openrct2/actions/PlaceParkEntranceAction.cpp index 4a4220937e..19ae8ead8f 100644 --- a/src/openrct2/actions/PlaceParkEntranceAction.cpp +++ b/src/openrct2/actions/PlaceParkEntranceAction.cpp @@ -51,7 +51,7 @@ GameActions::Result::Ptr PlaceParkEntranceAction::Query() const res->Expenditure = ExpenditureType::LandPurchase; res->Position = { _loc.x, _loc.y, _loc.z }; - if (!map_check_free_elements_and_reorganise(3)) + if (!CheckMapCapacity(3)) { return std::make_unique( GameActions::Status::NoFreeElements, STR_CANT_BUILD_PARK_ENTRANCE_HERE, STR_NONE); @@ -170,3 +170,25 @@ GameActions::Result::Ptr PlaceParkEntranceAction::Execute() const return res; } + +bool PlaceParkEntranceAction::CheckMapCapacity(int16_t numTiles) const +{ + CoordsXYZ entranceLoc = _loc; + for (uint8_t index = 0; index < 3; index++) + { + if (index == 1) + { + entranceLoc += CoordsDirectionDelta[(_loc.direction - 1) & 0x3]; + } + else if (index == 2) + { + entranceLoc.x += CoordsDirectionDelta[(_loc.direction + 1) & 0x3].x * 2; + entranceLoc.y += CoordsDirectionDelta[(_loc.direction + 1) & 0x3].y * 2; + } + if (!MapCheckCapacityAndReorganise(entranceLoc, numTiles)) + { + return false; + } + } + return true; +} diff --git a/src/openrct2/actions/PlaceParkEntranceAction.h b/src/openrct2/actions/PlaceParkEntranceAction.h index 5c251c2bc5..88d149cbda 100644 --- a/src/openrct2/actions/PlaceParkEntranceAction.h +++ b/src/openrct2/actions/PlaceParkEntranceAction.h @@ -26,4 +26,7 @@ public: void Serialise(DataSerialiser & stream) override; GameActions::Result::Ptr Query() const override; GameActions::Result::Ptr Execute() const override; + +private: + bool CheckMapCapacity(int16_t numTiles) const; }; diff --git a/src/openrct2/actions/PlacePeepSpawnAction.cpp b/src/openrct2/actions/PlacePeepSpawnAction.cpp index c332f27ef8..9af4289dd1 100644 --- a/src/openrct2/actions/PlacePeepSpawnAction.cpp +++ b/src/openrct2/actions/PlacePeepSpawnAction.cpp @@ -47,12 +47,6 @@ GameActions::Result::Ptr PlacePeepSpawnAction::Query() const res->Expenditure = ExpenditureType::LandPurchase; res->Position = _location; - if (!map_check_free_elements_and_reorganise(3)) - { - return std::make_unique( - GameActions::Status::NoFreeElements, STR_ERR_CANT_PLACE_PEEP_SPAWN_HERE, STR_NONE); - } - if (!LocationValid(_location) || _location.x <= 16 || _location.y <= 16 || _location.x >= (gMapSizeUnits - 16) || _location.y >= (gMapSizeUnits - 16)) { diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp b/src/openrct2/actions/RideEntranceExitPlaceAction.cpp index 5cefc1f8b1..991d263acc 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp +++ b/src/openrct2/actions/RideEntranceExitPlaceAction.cpp @@ -50,7 +50,7 @@ GameActions::Result::Ptr RideEntranceExitPlaceAction::Query() const { auto errorTitle = _isExit ? STR_CANT_BUILD_MOVE_EXIT_FOR_THIS_RIDE_ATTRACTION : STR_CANT_BUILD_MOVE_ENTRANCE_FOR_THIS_RIDE_ATTRACTION; - if (!map_check_free_elements_and_reorganise(1)) + if (!MapCheckCapacityAndReorganise(_loc)) { return MakeResult(GameActions::Status::NoFreeElements, errorTitle); } @@ -217,7 +217,7 @@ GameActions::Result::Ptr RideEntranceExitPlaceAction::TrackPlaceQuery(const Coor { auto errorTitle = isExit ? STR_CANT_BUILD_MOVE_EXIT_FOR_THIS_RIDE_ATTRACTION : STR_CANT_BUILD_MOVE_ENTRANCE_FOR_THIS_RIDE_ATTRACTION; - if (!map_check_free_elements_and_reorganise(1)) + if (!MapCheckCapacityAndReorganise(loc)) { return MakeResult(GameActions::Status::NoFreeElements, errorTitle); } diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.cpp b/src/openrct2/actions/SmallSceneryPlaceAction.cpp index 169dd77ae1..346f10249b 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.cpp +++ b/src/openrct2/actions/SmallSceneryPlaceAction.cpp @@ -111,7 +111,7 @@ GameActions::Result::Ptr SmallSceneryPlaceAction::Query() const res->Position.z = surfaceHeight; } - if (!map_check_free_elements_and_reorganise(1)) + if (!MapCheckCapacityAndReorganise(_loc)) { return std::make_unique(GameActions::Status::NoFreeElements); } diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp index 914f585842..09953a419e 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/TrackPlaceAction.cpp @@ -169,7 +169,7 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const numElements++; } - if (!map_check_free_elements_and_reorganise(numElements)) + if (!CheckMapCapacity(numElements)) { log_warning("Not enough free map elements to place track."); return std::make_unique(GameActions::Status::NoFreeElements, STR_TILE_ELEMENT_LIMIT_REACHED); @@ -650,3 +650,18 @@ GameActions::Result::Ptr TrackPlaceAction::Execute() const res->Cost = cost + ((price / 2) * 10); return res; } + +bool TrackPlaceAction::CheckMapCapacity(int16_t numTiles) const +{ + for (const rct_preview_track* trackBlock = TrackBlocks[_trackType]; trackBlock->index != 0xFF; trackBlock++) + { + auto rotatedTrack = CoordsXY{ trackBlock->x, trackBlock->y }.Rotate(_origin.direction); + + auto tileCoords = CoordsXY{ _origin.x, _origin.y } + rotatedTrack; + if (!MapCheckCapacityAndReorganise(tileCoords, numTiles)) + { + return false; + } + } + return true; +} diff --git a/src/openrct2/actions/TrackPlaceAction.h b/src/openrct2/actions/TrackPlaceAction.h index 507bcc7558..8692372f16 100644 --- a/src/openrct2/actions/TrackPlaceAction.h +++ b/src/openrct2/actions/TrackPlaceAction.h @@ -47,4 +47,7 @@ public: void Serialise(DataSerialiser & stream) override; GameActions::Result::Ptr Query() const override; GameActions::Result::Ptr Execute() const override; + +private: + bool CheckMapCapacity(int16_t numTiles) const; }; diff --git a/src/openrct2/actions/WallPlaceAction.cpp b/src/openrct2/actions/WallPlaceAction.cpp index 9fcfb94436..c014e3bd87 100644 --- a/src/openrct2/actions/WallPlaceAction.cpp +++ b/src/openrct2/actions/WallPlaceAction.cpp @@ -290,7 +290,7 @@ GameActions::Result::Ptr WallPlaceAction::Query() const } } - if (!map_check_free_elements_and_reorganise(1)) + if (!MapCheckCapacityAndReorganise(_loc)) { return MakeResult(GameActions::Status::NoFreeElements, STR_TILE_ELEMENT_LIMIT_REACHED); } @@ -361,7 +361,7 @@ GameActions::Result::Ptr WallPlaceAction::Execute() const } } - if (!map_check_free_elements_and_reorganise(1)) + if (!MapCheckCapacityAndReorganise(_loc)) { return MakeResult(GameActions::Status::NoFreeElements, STR_TILE_ELEMENT_LIMIT_REACHED); } diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 6492ca40fe..9faa1da254 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -199,7 +199,7 @@ void ReorganiseTileElements() ReorganiseTileElements(_tileElements.size()); } -bool map_check_free_elements_and_reorganise(size_t numElements) +static bool map_check_free_elements_and_reorganise(size_t numElements) { auto freeElements = _tileElements.capacity() - _tileElements.size(); if (freeElements >= numElements) @@ -223,6 +223,14 @@ bool map_check_free_elements_and_reorganise(size_t numElements) } } +static size_t CountElementsOnTile(const CoordsXY& loc); + +bool MapCheckCapacityAndReorganise(const CoordsXY& loc, size_t numElements) +{ + auto numElementsOnTile = CountElementsOnTile(loc); + return map_check_free_elements_and_reorganise(numElementsOnTile + numElements); +} + static void clear_elements_at(const CoordsXY& loc); static ScreenCoordsXY translate_3d_to_2d(int32_t rotation, const CoordsXY& pos); @@ -1144,6 +1152,10 @@ TileElement* tile_element_insert(const CoordsXYZ& loc, int32_t occupiedQuadrants auto numElementsOnTileNew = numElementsOnTileOld + 1; auto* newTileElement = AllocateTileElements(numElementsOnTileNew); auto* originalTileElement = _tileIndex.GetFirstElementAt(tileLoc); + if (newTileElement == nullptr) + { + return nullptr; + } // Set tile index pointer to point to new element block _tileIndex.SetTile(tileLoc, newTileElement); diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index 707453b588..06ed8182c8 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -216,7 +216,7 @@ void tile_element_remove(TileElement* tileElement); void map_remove_all_rides(); void map_invalidate_map_selection_tiles(); void map_invalidate_selection_rect(); -bool map_check_free_elements_and_reorganise(size_t num_elements); +bool MapCheckCapacityAndReorganise(const CoordsXY& loc, size_t numElements = 1); TileElement* tile_element_insert(const CoordsXYZ& loc, int32_t occupiedQuadrants, TileElementType type); template T* TileElementInsert(const CoordsXYZ& loc, int32_t occupiedQuadrants) diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index 957cca4de0..6c61929a79 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -94,7 +94,7 @@ namespace OpenRCT2::TileInspector GameActionResultPtr InsertCorruptElementAt(const CoordsXY& loc, int16_t elementIndex, bool isExecuting) { // Make sure there is enough space for the new element - if (!map_check_free_elements_and_reorganise(1)) + if (!!MapCheckCapacityAndReorganise(loc)) return std::make_unique(GameActions::Status::NoFreeElements, STR_NONE); if (isExecuting) @@ -359,7 +359,7 @@ namespace OpenRCT2::TileInspector GameActionResultPtr PasteElementAt(const CoordsXY& loc, TileElement element, bool isExecuting) { // Make sure there is enough space for the new element - if (!map_check_free_elements_and_reorganise(1)) + if (!!MapCheckCapacityAndReorganise(loc)) { return std::make_unique(GameActions::Status::NoFreeElements, STR_NONE); } From cf7b277d89095a49312d591efaf87f2fd206ae39 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 7 Jun 2021 03:33:08 -0500 Subject: [PATCH 33/39] Close #13765: Refactor Changelog window into class --- src/openrct2-ui/windows/Changelog.cpp | 528 +++++++++++++------------- 1 file changed, 274 insertions(+), 254 deletions(-) diff --git a/src/openrct2-ui/windows/Changelog.cpp b/src/openrct2-ui/windows/Changelog.cpp index 7e5cbeb216..a600a26b06 100644 --- a/src/openrct2-ui/windows/Changelog.cpp +++ b/src/openrct2-ui/windows/Changelog.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2020 OpenRCT2 developers + * Copyright (c) 2014-2021 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -41,7 +41,7 @@ static constexpr const rct_string_id WINDOW_TITLE = STR_CHANGELOG_TITLE; constexpr int32_t MIN_WW = 300; constexpr int32_t MIN_WH = 250; -static rct_widget window_changelog_widgets[] = { +static rct_widget _windowChangelogWidgets[] = { WINDOW_SHIM(WINDOW_TITLE, WW, WH), MakeWidget({0, 14}, {500, 382}, WindowWidgetType::Resize, WindowColour::Secondary ), // content panel MakeWidget({3, 16}, {495, 366}, WindowWidgetType::Scroll, WindowColour::Secondary, SCROLL_BOTH ), // scroll area @@ -49,265 +49,285 @@ static rct_widget window_changelog_widgets[] = { { WIDGETS_END }, }; -static void window_changelog_close(rct_window *w); -static void window_changelog_mouseup(rct_window *w, rct_widgetindex widgetIndex); -static void window_changelog_resize(rct_window *w); -static void window_changelog_scrollgetsize(rct_window *w, int32_t scrollIndex, int32_t *width, int32_t *height); -static void window_changelog_invalidate(rct_window *w); -static void window_changelog_paint(rct_window *w, rct_drawpixelinfo *dpi); -static void window_changelog_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex); - -static rct_window_event_list window_changelog_events([](auto& events) -{ - events.close = &window_changelog_close; - events.mouse_up = &window_changelog_mouseup; - events.resize = &window_changelog_resize; - events.get_scroll_size = &window_changelog_scrollgetsize; - events.invalidate = &window_changelog_invalidate; - events.paint = &window_changelog_paint; - events.scroll_paint = &window_changelog_scrollpaint; -}); // clang-format on -static void window_new_version_process_info(); -static void window_changelog_dispose_data(); -static bool window_changelog_read_file(); +class ChangelogWindow final : public Window +{ + const NewVersionInfo* _newVersionInfo; + std::vector _changelogLines; + int32_t _changelogLongestLineWidth = 0; + int _personality = 0; -static const NewVersionInfo* _newVersionInfo; -static std::vector _changelogLines; -static int32_t _changelogLongestLineWidth = 0; -static int _persnality = 0; +public: + /** + * @brief Retrieves the changelog contents. + */ + const std::string GetChangelogText() + { + auto path = GetChangelogPath(); +#if defined(_WIN32) && !defined(__MINGW32__) + auto pathW = String::ToWideChar(path); + auto fs = std::ifstream(pathW, std::ios::in); +#else + auto fs = std::ifstream(path, std::ios::in); +#endif + if (!fs.is_open()) + { + throw std::runtime_error("Unable to open " + path); + } + return std::string((std::istreambuf_iterator(fs)), std::istreambuf_iterator()); + } + + /** + * @brief Set the Changelog Window's Personality, should be called just after creation. Returns true on success + * + * @param personality + */ + bool SetPersonality(int personality) + { + switch (personality) + { + case WV_NEW_VERSION_INFO: + if (!GetContext()->HasNewVersionInfo()) + { + return false; + } + _personality = WV_NEW_VERSION_INFO; + NewVersionProcessInfo(); + enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_OPEN_URL); + widgets[WIDX_OPEN_URL].type = WindowWidgetType::Button; + return true; + + case WV_CHANGELOG: + if (!ReadChangelogFile()) + { + return false; + } + enabled_widgets = (1 << WIDX_CLOSE); + _personality = WV_CHANGELOG; + return true; + + default: + log_error("Invalid personality for changelog window: %d", personality); + return false; + } + } + + void OnOpen() override + { + widgets = _windowChangelogWidgets; + + WindowInitScrollWidgets(this); + min_width = MIN_WW; + min_height = MIN_WH; + max_width = MIN_WW; + max_height = MIN_WH; + } + + void OnResize() override + { + int32_t screenWidth = context_get_width(); + int32_t screenHeight = context_get_height(); + + max_width = (screenWidth * 4) / 5; + max_height = (screenHeight * 4) / 5; + + min_width = MIN_WW; + min_height = MIN_WH; + + auto download_button_width = widgets[WIDX_OPEN_URL].width(); + widgets[WIDX_OPEN_URL].left = (width - download_button_width) / 2; + widgets[WIDX_OPEN_URL].right = widgets[WIDX_OPEN_URL].left + download_button_width; + + if (width < min_width) + { + Invalidate(); + width = min_width; + } + if (height < min_height) + { + Invalidate(); + height = min_height; + } + } + + void OnPrepareDraw() override + { + widgets[WIDX_BACKGROUND].right = width - 1; + widgets[WIDX_BACKGROUND].bottom = height - 1; + widgets[WIDX_TITLE].right = width - 2; + widgets[WIDX_CLOSE].left = width - 13; + widgets[WIDX_CLOSE].right = width - 3; + widgets[WIDX_CONTENT_PANEL].right = width - 1; + widgets[WIDX_CONTENT_PANEL].bottom = height - 1; + widgets[WIDX_SCROLL].right = width - 3; + widgets[WIDX_SCROLL].bottom = height - 22; + widgets[WIDX_OPEN_URL].bottom = height - 5; + widgets[WIDX_OPEN_URL].top = height - 19; + } + + void OnMouseUp(rct_widgetindex widgetIndex) override + { + switch (widgetIndex) + { + case WIDX_CLOSE: + Close(); + break; + case WIDX_OPEN_URL: + if (_newVersionInfo) + { + GetContext()->GetUiContext()->OpenURL(_newVersionInfo->url); + } + else + { + log_error("Cannot open URL: NewVersionInfo for ChangelogWindow is undefined!"); + } + break; + } + } + + void OnScrollDraw(int32_t scrollIndex, rct_drawpixelinfo& dpi) override + { + const int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM); + + ScreenCoordsXY screenCoords(3, 3 - lineHeight); + for (const auto& line : _changelogLines) + { + screenCoords.y += lineHeight; + if (screenCoords.y + lineHeight < dpi.y || screenCoords.y >= dpi.y + dpi.height) + continue; + + gfx_draw_string(&dpi, screenCoords, line.c_str(), { colours[0] }); + } + } + + ScreenSize OnScrollGetSize(int32_t scrollIndex) override + { + return ScreenSize( + _changelogLongestLineWidth + 4, + static_cast(_changelogLines.size()) * font_get_line_height(FontSpriteBase::MEDIUM)); + } + + // TODO: This probably should be a utility function defined elsewhere for reusability + /** + * @brief Reimplementation of Window's GetCentrePositionForNewWindow for ChangelogWindow. + * + * @return ScreenCoordsXY + */ + static ScreenCoordsXY GetCentrePositionForNewWindow(int32_t width, int32_t height) + { + auto uiContext = GetContext()->GetUiContext(); + auto screenWidth = uiContext->GetWidth(); + auto screenHeight = uiContext->GetHeight(); + return ScreenCoordsXY{ (screenWidth - width) / 2, std::max(TOP_TOOLBAR_HEIGHT + 1, (screenHeight - height) / 2) }; + } + +private: + /** + * @brief Converts NewVersionInfo into changelog lines + * + */ + void NewVersionProcessInfo() + { + _newVersionInfo = GetContext()->GetNewVersionInfo(); + if (_newVersionInfo != nullptr) + { + char version_info[256]; + + const char* version_info_ptr = _newVersionInfo->name.c_str(); + format_string(version_info, 256, STR_NEW_RELEASE_VERSION_INFO, &version_info_ptr); + + _changelogLines.emplace_back(version_info); + _changelogLines.emplace_back(""); + + ProcessChangelogText(_newVersionInfo->changelog); + } + else + { + log_error("ChangelogWindow: Could not process NewVersionInfo, result was undefined"); + } + } + + /** + * @brief Get the absolute path for the changelog file + * + * @return std::string + */ + std::string GetChangelogPath() + { + auto env = GetContext()->GetPlatformEnvironment(); + return env->GetFilePath(PATHID::CHANGELOG); + } + + /** + * @brief Attempts to read the changelog file, returns true on success + * + */ + bool ReadChangelogFile() + { + std::string _changelogText; + try + { + _changelogText = GetChangelogText(); + } + catch (const std::bad_alloc&) + { + log_error("Unable to allocate memory for changelog.txt"); + return false; + } + catch (const std::exception&) + { + log_error("Unable to read changelog.txt"); + return false; + } + + ProcessChangelogText(_changelogText); + return true; + } + + /** + * @brief Ingests a string of text and splits it into lines for the changelog and updates the longest line width for + * scrolling purposes + * + * @param text + */ + void ProcessChangelogText(const std::string& text) + { + std::string::size_type pos = 0; + std::string::size_type prev = 0; + while ((pos = text.find("\n", prev)) != std::string::npos) + { + _changelogLines.push_back(text.substr(prev, pos - prev)); + prev = pos + 1; + } + + // To get the last substring (or only, if delimiter is not found) + _changelogLines.push_back(text.substr(prev)); + + _changelogLongestLineWidth = 0; + for (const auto& line : _changelogLines) + { + int32_t linewidth = gfx_get_string_width(line.c_str(), FontSpriteBase::MEDIUM); + _changelogLongestLineWidth = std::max(linewidth, _changelogLongestLineWidth); + } + } +}; rct_window* window_changelog_open(int personality) { - rct_window* window; - - window = window_bring_to_front_by_class(WC_CHANGELOG); - if (window != nullptr) + auto* window = window_bring_to_front_by_class(WC_CHANGELOG); + if (window == nullptr) { - return window; + // Create a new centred window + int32_t screenWidth = context_get_width(); + int32_t screenHeight = context_get_height(); + int32_t width = (screenWidth * 4) / 5; + int32_t height = (screenHeight * 4) / 5; + + auto pos = ChangelogWindow::GetCentrePositionForNewWindow(width, height); + auto* newWindow = WindowCreate(WC_CHANGELOG, pos, width, height, WF_RESIZABLE); + newWindow->SetPersonality(personality); + return newWindow; } - - uint64_t enabled_widgets{}; - - window_changelog_widgets[WIDX_OPEN_URL].type = WindowWidgetType::Placeholder; - switch (personality) - { - case WV_NEW_VERSION_INFO: - if (!GetContext()->HasNewVersionInfo()) - { - return nullptr; - } - - _persnality = WV_NEW_VERSION_INFO; - window_new_version_process_info(); - enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_OPEN_URL); - window_changelog_widgets[WIDX_OPEN_URL].type = WindowWidgetType::Button; - break; - - case WV_CHANGELOG: - if (!window_changelog_read_file()) - { - return nullptr; - } - - _persnality = WV_CHANGELOG; - enabled_widgets = (1 << WIDX_CLOSE); - break; - - default: - log_error("Invalid personality for changelog window: %d", personality); - return nullptr; - } - - int32_t screenWidth = context_get_width(); - int32_t screenHeight = context_get_height(); - - window = WindowCreateCentred( - screenWidth * 4 / 5, screenHeight * 4 / 5, &window_changelog_events, WC_CHANGELOG, WF_RESIZABLE); - window->widgets = window_changelog_widgets; - window->enabled_widgets = enabled_widgets; - - WindowInitScrollWidgets(window); - window->min_width = MIN_WW; - window->min_height = MIN_WH; - window->max_width = MIN_WW; - window->max_height = MIN_WH; - return window; } - -static void window_changelog_close([[maybe_unused]] rct_window* w) -{ - window_changelog_dispose_data(); -} - -static void window_changelog_mouseup(rct_window* w, rct_widgetindex widgetIndex) -{ - switch (widgetIndex) - { - case WIDX_CLOSE: - window_close(w); - break; - case WIDX_OPEN_URL: - GetContext()->GetUiContext()->OpenURL(_newVersionInfo->url); - break; - } -} - -static void window_changelog_resize(rct_window* w) -{ - int32_t screenWidth = context_get_width(); - int32_t screenHeight = context_get_height(); - - w->max_width = (screenWidth * 4) / 5; - w->max_height = (screenHeight * 4) / 5; - - w->min_width = MIN_WW; - w->min_height = MIN_WH; - - auto download_button_width = window_changelog_widgets[WIDX_OPEN_URL].width(); - window_changelog_widgets[WIDX_OPEN_URL].left = (w->width - download_button_width) / 2; - window_changelog_widgets[WIDX_OPEN_URL].right = window_changelog_widgets[WIDX_OPEN_URL].left + download_button_width; - - if (w->width < w->min_width) - { - w->Invalidate(); - w->width = w->min_width; - } - if (w->height < w->min_height) - { - w->Invalidate(); - w->height = w->min_height; - } -} - -static void window_changelog_scrollgetsize( - [[maybe_unused]] rct_window* w, [[maybe_unused]] int32_t scrollIndex, int32_t* width, int32_t* height) -{ - *width = _changelogLongestLineWidth + 4; - - const int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM); - *height = static_cast(_changelogLines.size() * lineHeight); -} - -static void window_changelog_invalidate(rct_window* w) -{ - window_changelog_widgets[WIDX_BACKGROUND].right = w->width - 1; - window_changelog_widgets[WIDX_BACKGROUND].bottom = w->height - 1; - window_changelog_widgets[WIDX_TITLE].right = w->width - 2; - window_changelog_widgets[WIDX_CLOSE].left = w->width - 13; - window_changelog_widgets[WIDX_CLOSE].right = w->width - 3; - window_changelog_widgets[WIDX_CONTENT_PANEL].right = w->width - 1; - window_changelog_widgets[WIDX_CONTENT_PANEL].bottom = w->height - 1; - window_changelog_widgets[WIDX_SCROLL].right = w->width - 3; - window_changelog_widgets[WIDX_SCROLL].bottom = w->height - 22; - window_changelog_widgets[WIDX_OPEN_URL].bottom = w->height - 5; - window_changelog_widgets[WIDX_OPEN_URL].top = w->height - 19; -} - -static void window_changelog_paint(rct_window* w, rct_drawpixelinfo* dpi) -{ - WindowDrawWidgets(w, dpi); -} - -static void window_changelog_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, [[maybe_unused]] int32_t scrollIndex) -{ - const int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM); - - ScreenCoordsXY screenCoords(3, 3 - lineHeight); - for (const auto& line : _changelogLines) - { - screenCoords.y += lineHeight; - if (screenCoords.y + lineHeight < dpi->y || screenCoords.y >= dpi->y + dpi->height) - continue; - - gfx_draw_string(dpi, screenCoords, line.c_str(), { w->colours[0] }); - } -} - -static void window_changelog_process_changelog_text(const std::string& text) -{ - std::string::size_type pos = 0; - std::string::size_type prev = 0; - while ((pos = text.find("\n", prev)) != std::string::npos) - { - _changelogLines.push_back(text.substr(prev, pos - prev)); - prev = pos + 1; - } - - // To get the last substring (or only, if delimiter is not found) - _changelogLines.push_back(text.substr(prev)); - - _changelogLongestLineWidth = 0; - for (const auto& line : _changelogLines) - { - auto width = gfx_get_string_width(line.c_str(), FontSpriteBase::MEDIUM); - _changelogLongestLineWidth = std::max(width, _changelogLongestLineWidth); - } -} - -static void window_new_version_process_info() -{ - _newVersionInfo = GetContext()->GetNewVersionInfo(); - - char version_info[256]; - - const char* version_info_ptr = _newVersionInfo->name.c_str(); - format_string(version_info, 256, STR_NEW_RELEASE_VERSION_INFO, &version_info_ptr); - - _changelogLines.emplace_back(version_info); - _changelogLines.emplace_back(""); - - window_changelog_process_changelog_text(_newVersionInfo->changelog); -} - -static void window_changelog_dispose_data() -{ - _changelogLines.clear(); - _changelogLines.shrink_to_fit(); -} - -static std::string GetChangelogPath() -{ - auto env = GetContext()->GetPlatformEnvironment(); - return env->GetFilePath(PATHID::CHANGELOG); -} - -static std::string GetChangelogText() -{ - auto path = GetChangelogPath(); -#if defined(_WIN32) && !defined(__MINGW32__) - auto pathW = String::ToWideChar(path); - auto fs = std::ifstream(pathW, std::ios::in); -#else - auto fs = std::ifstream(path, std::ios::in); -#endif - if (!fs.is_open()) - { - throw std::runtime_error("Unable to open " + path); - } - return std::string((std::istreambuf_iterator(fs)), std::istreambuf_iterator()); -} - -static bool window_changelog_read_file() -{ - std::string _changelogText; - try - { - _changelogText = GetChangelogText(); - } - catch (const std::bad_alloc&) - { - log_error("Unable to allocate memory for changelog.txt"); - return false; - } - catch (const std::exception&) - { - log_error("Unable to read changelog.txt"); - return false; - } - - window_changelog_process_changelog_text(_changelogText); - return true; -} From 1d84bdca88c0bd995caf85111096fe0a2271002a Mon Sep 17 00:00:00 2001 From: Jamie Quigley Date: Mon, 7 Jun 2021 13:40:27 +0100 Subject: [PATCH 34/39] Refactor PATH_BIT_DRAW_TYPE_LIGHTS to use strong enum (#14837) * Refactor PATH_BIT_DRAW_TYPE to use strong enum * Rename PathBitDrawType members to be singular * Remove whitespace and add trailing comma --- src/openrct2/object/FootpathItemObject.cpp | 14 +++++++------- src/openrct2/paint/tile_element/Paint.Path.cpp | 10 +++++----- src/openrct2/world/Scenery.h | 13 +++++++------ 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/openrct2/object/FootpathItemObject.cpp b/src/openrct2/object/FootpathItemObject.cpp index 973f10764d..cb8405f0eb 100644 --- a/src/openrct2/object/FootpathItemObject.cpp +++ b/src/openrct2/object/FootpathItemObject.cpp @@ -24,7 +24,7 @@ void FootpathItemObject::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStre { stream->Seek(6, OpenRCT2::STREAM_SEEK_CURRENT); _legacyType.flags = stream->ReadValue(); - _legacyType.draw_type = stream->ReadValue(); + _legacyType.draw_type = static_cast(stream->ReadValue()); _legacyType.tool_id = static_cast(stream->ReadValue()); _legacyType.price = stream->ReadValue(); _legacyType.scenery_tab_id = OBJECT_ENTRY_INDEX_NULL; @@ -85,17 +85,17 @@ void FootpathItemObject::DrawPreview(rct_drawpixelinfo* dpi, int32_t width, int3 gfx_draw_sprite(dpi, _legacyType.image, screenCoords - ScreenCoordsXY{ 22, 24 }, 0); } -static uint8_t ParseDrawType(const std::string& s) +static PathBitDrawType ParseDrawType(const std::string& s) { if (s == "lamp") - return PATH_BIT_DRAW_TYPE_LIGHTS; + return PathBitDrawType::Light; if (s == "bin") - return PATH_BIT_DRAW_TYPE_BINS; + return PathBitDrawType::Bin; if (s == "bench") - return PATH_BIT_DRAW_TYPE_BENCHES; + return PathBitDrawType::Bench; if (s == "fountain") - return PATH_BIT_DRAW_TYPE_JUMPING_FOUNTAINS; - return PATH_BIT_DRAW_TYPE_LIGHTS; + return PathBitDrawType::JumpingFountain; + return PathBitDrawType::Light; } void FootpathItemObject::ReadJson(IReadObjectContext* context, json_t& root) diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 34d78b3d76..0819818634 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -709,7 +709,7 @@ static void sub_6A3F61( } else if ( (session->ViewFlags & VIEWPORT_FLAG_HIGHLIGHT_PATH_ISSUES) && !(tile_element->AsPath()->IsBroken()) - && !(pathAddEntry->draw_type == PATH_BIT_DRAW_TYPE_BINS)) + && pathAddEntry->draw_type != PathBitDrawType::Bin) { paintScenery = false; } @@ -717,22 +717,22 @@ static void sub_6A3F61( { switch (pathAddEntry->draw_type) { - case PATH_BIT_DRAW_TYPE_LIGHTS: + case PathBitDrawType::Light: path_bit_lights_paint( session, pathAddEntry, tile_element, height, static_cast(connectedEdges), sceneryImageFlags); break; - case PATH_BIT_DRAW_TYPE_BINS: + case PathBitDrawType::Bin: path_bit_bins_paint( session, pathAddEntry, tile_element, height, static_cast(connectedEdges), sceneryImageFlags); break; - case PATH_BIT_DRAW_TYPE_BENCHES: + case PathBitDrawType::Bench: path_bit_benches_paint( session, pathAddEntry, tile_element, height, static_cast(connectedEdges), sceneryImageFlags); break; - case PATH_BIT_DRAW_TYPE_JUMPING_FOUNTAINS: + case PathBitDrawType::JumpingFountain: path_bit_jumping_fountains_paint(session, pathAddEntry, height, sceneryImageFlags, dpi); break; } diff --git a/src/openrct2/world/Scenery.h b/src/openrct2/world/Scenery.h index 45e2278890..4a780962e1 100644 --- a/src/openrct2/world/Scenery.h +++ b/src/openrct2/world/Scenery.h @@ -138,11 +138,12 @@ struct WallSceneryEntry : SceneryEntryBase ObjectEntryIndex scenery_tab_id; uint8_t scrolling_mode; }; +enum class PathBitDrawType : uint8_t; struct PathBitEntry : SceneryEntryBase { uint16_t flags; - uint8_t draw_type; + PathBitDrawType draw_type; CursorID tool_id; int16_t price; ObjectEntryIndex scenery_tab_id; @@ -181,12 +182,12 @@ enum PATH_BIT_FLAG_IS_QUEUE_SCREEN = 1 << 8 }; -enum +enum class PathBitDrawType : uint8_t { - PATH_BIT_DRAW_TYPE_LIGHTS, - PATH_BIT_DRAW_TYPE_BINS, - PATH_BIT_DRAW_TYPE_BENCHES, - PATH_BIT_DRAW_TYPE_JUMPING_FOUNTAINS + Light, + Bin, + Bench, + JumpingFountain, }; enum From 8e01bd46cebce8513f37dfebd613032101e02980 Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Mon, 7 Jun 2021 17:44:38 +0200 Subject: [PATCH 35/39] Remove LocationXY(Z)16 (#14834) --- src/openrct2/object/LargeSceneryObject.cpp | 17 ++--- src/openrct2/object/LargeSceneryObject.h | 6 +- src/openrct2/paint/Paint.h | 6 +- .../paint/tile_element/Paint.LargeScenery.cpp | 69 ++++++++++--------- .../paint/tile_element/Paint.Path.cpp | 8 +-- .../paint/tile_element/Paint.SmallScenery.cpp | 8 +-- .../paint/tile_element/Paint.Surface.cpp | 13 ++-- .../paint/tile_element/Paint.Wall.cpp | 14 ++-- src/openrct2/world/Location.hpp | 15 ---- src/openrct2/world/Scenery.h | 36 +++++++++- 10 files changed, 104 insertions(+), 88 deletions(-) diff --git a/src/openrct2/object/LargeSceneryObject.cpp b/src/openrct2/object/LargeSceneryObject.cpp index 8129597814..87da9feb8b 100644 --- a/src/openrct2/object/LargeSceneryObject.cpp +++ b/src/openrct2/object/LargeSceneryObject.cpp @@ -42,8 +42,9 @@ void LargeSceneryObject::ReadLegacy(IReadObjectContext* context, OpenRCT2::IStre if (_legacyType.flags & LARGE_SCENERY_FLAG_3D_TEXT) { - _3dFont = std::make_unique(); - stream->Read(_3dFont.get()); + rct_large_scenery_text _3dFontLegacy = {}; + stream->Read(&_3dFontLegacy); + _3dFont = std::make_unique(_3dFontLegacy); _legacyType.text = _3dFont.get(); } @@ -207,11 +208,11 @@ std::vector LargeSceneryObject::ReadJsonTiles(json_t& jT return tiles; } -std::unique_ptr LargeSceneryObject::ReadJson3dFont(json_t& j3dFont) +std::unique_ptr LargeSceneryObject::ReadJson3dFont(json_t& j3dFont) { Guard::Assert(j3dFont.is_object(), "LargeSceneryObject::ReadJson3dFont expects parameter j3dFont to be object"); - auto font = std::make_unique(); + auto font = std::make_unique(); auto jOffsets = j3dFont["offsets"]; if (jOffsets.is_array()) @@ -222,7 +223,7 @@ std::unique_ptr LargeSceneryObject::ReadJson3dFont(json_ } font->max_width = Json::GetNumber(j3dFont["maxWidth"]); - font->num_images = Json::GetNumber(j3dFont["numImages"]); + font->num_images = Json::GetNumber(j3dFont["numImages"]); font->flags = Json::GetFlags( j3dFont, @@ -242,14 +243,14 @@ std::unique_ptr LargeSceneryObject::ReadJson3dFont(json_ return font; } -std::vector LargeSceneryObject::ReadJsonOffsets(json_t& jOffsets) +std::vector LargeSceneryObject::ReadJsonOffsets(json_t& jOffsets) { - std::vector offsets; + std::vector offsets; for (auto& jOffset : jOffsets) { if (jOffset.is_object()) { - LocationXY16 offset = {}; + CoordsXY offset = {}; offset.x = Json::GetNumber(jOffset["x"]); offset.y = Json::GetNumber(jOffset["y"]); offsets.push_back(offset); diff --git a/src/openrct2/object/LargeSceneryObject.h b/src/openrct2/object/LargeSceneryObject.h index 2a548c50e5..a39e387880 100644 --- a/src/openrct2/object/LargeSceneryObject.h +++ b/src/openrct2/object/LargeSceneryObject.h @@ -21,7 +21,7 @@ private: LargeSceneryEntry _legacyType = {}; uint32_t _baseImageId = 0; std::vector _tiles; - std::unique_ptr _3dFont; + std::unique_ptr _3dFont; public: explicit LargeSceneryObject(const rct_object_entry& entry) @@ -45,7 +45,7 @@ public: private: static std::vector ReadTiles(OpenRCT2::IStream* stream); static std::vector ReadJsonTiles(json_t& jTiles); - static std::unique_ptr ReadJson3dFont(json_t& j3dFont); - static std::vector ReadJsonOffsets(json_t& jOffsets); + static std::unique_ptr ReadJson3dFont(json_t& j3dFont); + static std::vector ReadJsonOffsets(json_t& jOffsets); static std::vector ReadJsonGlyphs(json_t& jGlyphs); }; diff --git a/src/openrct2/paint/Paint.h b/src/openrct2/paint/Paint.h index a327ef5ca3..6b5ff077a2 100644 --- a/src/openrct2/paint/Paint.h +++ b/src/openrct2/paint/Paint.h @@ -112,9 +112,9 @@ union paint_entry struct sprite_bb { uint32_t sprite_id; - LocationXYZ16 offset; - LocationXYZ16 bb_offset; - LocationXYZ16 bb_size; + CoordsXYZ offset; + CoordsXYZ bb_offset; + CoordsXYZ bb_size; }; enum PAINT_STRUCT_FLAGS diff --git a/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp b/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp index a2ff3a04a7..155a442efb 100644 --- a/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp @@ -67,7 +67,7 @@ static void large_scenery_paint_supports( paint_util_set_general_support_height(session, clearanceHeight, 0x20); } -static rct_large_scenery_text_glyph* large_scenery_sign_get_glyph(rct_large_scenery_text* text, uint32_t codepoint) +static rct_large_scenery_text_glyph* large_scenery_sign_get_glyph(LargeSceneryText* text, uint32_t codepoint) { if (codepoint >= std::size(text->glyphs)) { @@ -76,7 +76,7 @@ static rct_large_scenery_text_glyph* large_scenery_sign_get_glyph(rct_large_scen return &text->glyphs[codepoint]; } -static int32_t large_scenery_sign_text_width(const utf8* str, rct_large_scenery_text* text) +static int32_t large_scenery_sign_text_width(const utf8* str, LargeSceneryText* text) { int32_t width = 0; uint32_t codepoint; @@ -87,7 +87,7 @@ static int32_t large_scenery_sign_text_width(const utf8* str, rct_large_scenery_ return width; } -static int32_t large_scenery_sign_text_height(const utf8* str, rct_large_scenery_text* text) +static int32_t large_scenery_sign_text_height(const utf8* str, LargeSceneryText* text) { int32_t height = 0; uint32_t codepoint; @@ -98,7 +98,7 @@ static int32_t large_scenery_sign_text_height(const utf8* str, rct_large_scenery return height; } -static void large_scenery_sign_fit_text(const utf8* str, rct_large_scenery_text* text, bool height, utf8* fitStr, size_t bufLen) +static void large_scenery_sign_fit_text(const utf8* str, LargeSceneryText* text, bool height, utf8* fitStr, size_t bufLen) { utf8* fitStrEnd = fitStr; safe_strcpy(fitStr, str, bufLen); @@ -124,8 +124,8 @@ static int32_t div_to_minus_infinity(int32_t a, int32_t b) } static void large_scenery_sign_paint_line( - paint_session* session, const utf8* str, rct_large_scenery_text* text, int32_t textImage, int32_t textColour, - uint8_t direction, int32_t y_offset) + paint_session* session, const utf8* str, LargeSceneryText* text, int32_t textImage, int32_t textColour, uint8_t direction, + int32_t y_offset) { utf8 fitStr[32]; large_scenery_sign_fit_text(str, text, false, fitStr, sizeof(fitStr)); @@ -190,29 +190,29 @@ static void large_scenery_sign_paint_line( struct boundbox { - LocationXY16 offset; - LocationXY16 length; + CoordsXY offset; + CoordsXY length; }; // clang-format off static constexpr const boundbox s98E3C4[] = { - { 3, 3, 26, 26 }, - { 17, 17, 12, 12 }, - { 17, 3, 12, 12 }, - { 17, 3, 12, 26 }, - { 3, 3, 12, 12 }, - { 3, 3, 26, 26 }, - { 3, 3, 28, 12 }, - { 3, 3, 26, 26 }, - { 3, 17, 12, 12 }, - { 3, 17, 26, 12 }, - { 3, 3, 26, 26 }, - { 3, 3, 26, 26 }, - { 3, 3, 12, 28 }, - { 3, 3, 26, 26 }, - { 3, 3, 26, 26 }, - { 3, 3, 26, 26 }, - { 1, 1, 30, 30 }, + { { 3, 3 }, { 26, 26 } }, + { { 17, 17 }, { 12, 12 } }, + { { 17, 3 }, { 12, 12 } }, + { { 17, 3 }, { 12, 26 } }, + { { 3, 3 }, { 12, 12 } }, + { { 3, 3 }, { 26, 26 } }, + { { 3, 3 }, { 28, 12 } }, + { { 3, 3 }, { 26, 26 } }, + { { 3, 17 }, { 12, 12 } }, + { { 3, 17 }, { 26, 12 } }, + { { 3, 3 }, { 26, 26 } }, + { { 3, 3 }, { 26, 26 } }, + { { 3, 3 }, { 12, 28 } }, + { { 3, 3 }, { 26, 26 } }, + { { 3, 3 }, { 26, 26 } }, + { { 3, 3 }, { 26, 26 } }, + { { 1, 1 }, { 30, 30 } }, }; // clang-format on @@ -244,8 +244,8 @@ void large_scenery_paint(paint_session* session, uint8_t direction, uint16_t hei uint32_t dword_F4387C = 0; image_id |= SPRITE_ID_PALETTE_COLOUR_2( tileElement->AsLargeScenery()->GetPrimaryColour(), tileElement->AsLargeScenery()->GetSecondaryColour()); - LocationXYZ16 boxlength; - LocationXYZ16 boxoffset; + CoordsXYZ boxlength; + CoordsXYZ boxoffset; if (gTrackDesignSaveMode) { if (!track_design_save_contains_tile_element(tileElement)) @@ -264,12 +264,12 @@ void large_scenery_paint(paint_session* session, uint8_t direction, uint16_t hei dword_F4387C = sequenceNum; image_id |= dword_F4387C; } - int32_t ah = tile->z_clearance; - if (ah > 0x80) + int32_t boxlengthZ = tile->z_clearance; + if (boxlengthZ > 0x80) { - ah = 0x80; + boxlengthZ = 0x80; } - ah -= 3; + boxlengthZ -= 3; uint16_t edi = tile->flags; int32_t esi = 16; if (edi & 0xF00) @@ -283,8 +283,9 @@ void large_scenery_paint(paint_session* session, uint8_t direction, uint16_t hei boxoffset.z = height; boxlength.x = s98E3C4[esi].length.x; boxlength.y = s98E3C4[esi].length.y; - boxlength.z = ah; - PaintAddImageAsParent(session, image_id, 0, 0, boxlength.x, boxlength.y, ah, height, boxoffset.x, boxoffset.y, boxoffset.z); + boxlength.z = boxlengthZ; + PaintAddImageAsParent( + session, image_id, 0, 0, boxlength.x, boxlength.y, boxlengthZ, height, boxoffset.x, boxoffset.y, boxoffset.z); if (sceneryEntry->scrolling_mode == SCROLLING_MODE_NONE || direction == 1 || direction == 2) { large_scenery_paint_supports(session, direction, height, tileElement, dword_F4387C, tile); @@ -322,7 +323,7 @@ void large_scenery_paint(paint_session* session, uint8_t direction, uint16_t hei banner->FormatTextTo(ft); utf8 signString[256]; format_string(signString, sizeof(signString), STR_STRINGID, ft.Data()); - rct_large_scenery_text* text = sceneryEntry->text; + LargeSceneryText* text = sceneryEntry->text; int32_t y_offset = (text->offset[(direction & 1)].y * 2); if (text->flags & LARGE_SCENERY_TEXT_FLAG_VERTICAL) { diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 0819818634..a493dc28ba 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -1002,8 +1002,8 @@ void path_paint_box_support( uint8_t corners = (((tileElement->AsPath()->GetCorners()) << session->CurrentRotation) & 0xF) | (((tileElement->AsPath()->GetCorners()) << session->CurrentRotation) >> 4); - LocationXY16 boundBoxOffset = { stru_98D804[edges][0], stru_98D804[edges][1] }; - LocationXY16 boundBoxSize = { stru_98D804[edges][2], stru_98D804[edges][3] }; + CoordsXY boundBoxOffset = { stru_98D804[edges][0], stru_98D804[edges][1] }; + CoordsXY boundBoxSize = { stru_98D804[edges][2], stru_98D804[edges][3] }; uint16_t edi = edges | (corners << 4); @@ -1149,9 +1149,9 @@ void path_paint_pole_support( uint8_t edges = ((tileElement->AsPath()->GetEdges() << session->CurrentRotation) & 0xF) | (((tileElement->AsPath()->GetEdges()) << session->CurrentRotation) >> 4); - LocationXY16 boundBoxOffset = { stru_98D804[edges][0], stru_98D804[edges][1] }; + CoordsXY boundBoxOffset = { stru_98D804[edges][0], stru_98D804[edges][1] }; - LocationXY16 boundBoxSize = { stru_98D804[edges][2], stru_98D804[edges][3] }; + CoordsXY boundBoxSize = { stru_98D804[edges][2], stru_98D804[edges][3] }; uint8_t corners = (((tileElement->AsPath()->GetCorners()) << session->CurrentRotation) & 0xF) | (((tileElement->AsPath()->GetCorners()) << session->CurrentRotation) >> 4); diff --git a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp index cd6602da12..e07c6bd115 100644 --- a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp @@ -20,7 +20,7 @@ #include "../Supports.h" #include "Paint.TileElement.h" -static constexpr const LocationXY16 lengths[] = { +static constexpr const CoordsXY lengths[] = { { 12, 26 }, { 26, 12 }, { 12, 26 }, @@ -39,8 +39,8 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co } const SmallSceneryElement* sceneryElement = tileElement->AsSmallScenery(); session->InteractionType = ViewportInteractionItem::Scenery; - LocationXYZ16 boxlength; - LocationXYZ16 boxoffset; + CoordsXYZ boxlength; + CoordsXYZ boxoffset; boxoffset.x = 0; boxoffset.y = 0; boxoffset.z = height; @@ -76,7 +76,7 @@ void scenery_paint(paint_session* session, uint8_t direction, int32_t height, co if (scenery_small_entry_has_flag(sceneryEntry, SMALL_SCENERY_FLAG_HALF_SPACE)) { // 6DFFE3: - static constexpr const LocationXY16 scenery_half_tile_offsets[] = { + static constexpr const CoordsXY scenery_half_tile_offsets[] = { { 3, 3 }, { 3, 17 }, { 17, 3 }, diff --git a/src/openrct2/paint/tile_element/Paint.Surface.cpp b/src/openrct2/paint/tile_element/Paint.Surface.cpp index ba9c54808e..58957450de 100644 --- a/src/openrct2/paint/tile_element/Paint.Surface.cpp +++ b/src/openrct2/paint/tile_element/Paint.Surface.cpp @@ -43,7 +43,7 @@ static constexpr const uint8_t byte_97B444[] = }; // rct2: 0x97B464, 0x97B474, 0x97B484, 0x97B494 -static constexpr const LocationXY16 viewport_surface_paint_data[][4] = { +static constexpr const CoordsXY viewport_surface_paint_data[][4] = { { { 32, 0 }, { -32, 32 }, @@ -561,8 +561,8 @@ static void viewport_surface_draw_tile_side_bottom( CoordsXY offset = { 0, 0 }; CoordsXY bounds = { 0, 0 }; - LocationXY16 tunnelBounds = { 1, 1 }; - LocationXY16 tunnelTopBoundBoxOffset = { 0, 0 }; + CoordsXY tunnelBounds = { 1, 1 }; + CoordsXY tunnelTopBoundBoxOffset = { 0, 0 }; const tunnel_entry* tunnelArray; switch (edge) @@ -992,11 +992,8 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c for (int32_t i = 0; i < 4; i++) { - const LocationXY16& offset = viewport_surface_paint_data[i][rotation]; - const CoordsXY position = { - static_cast(base.x + offset.x), - static_cast(base.y + offset.y), - }; + const CoordsXY& offset = viewport_surface_paint_data[i][rotation]; + const CoordsXY position = base + offset; tile_descriptor& descriptor = tileDescriptors[i + 1]; diff --git a/src/openrct2/paint/tile_element/Paint.Wall.cpp b/src/openrct2/paint/tile_element/Paint.Wall.cpp index d5bfbc6eb0..fc66fae338 100644 --- a/src/openrct2/paint/tile_element/Paint.Wall.cpp +++ b/src/openrct2/paint/tile_element/Paint.Wall.cpp @@ -41,8 +41,8 @@ static constexpr const uint8_t byte_9A40CC[] = { static void fence_paint_door( paint_session* session, uint32_t imageId, WallSceneryEntry* wallEntry, uint32_t imageColourFlags, uint32_t tertiaryColour, - uint32_t dword_141F710, LocationXYZ16 offset, LocationXYZ16 boundsR1, LocationXYZ16 boundsR1_, LocationXYZ16 boundsR2, - LocationXYZ16 boundsR2_, LocationXYZ16 boundsL1, LocationXYZ16 boundsL1_) + uint32_t dword_141F710, CoordsXYZ offset, CoordsXYZ boundsR1, CoordsXYZ boundsR1_, CoordsXYZ boundsR2, CoordsXYZ boundsR2_, + CoordsXYZ boundsL1, CoordsXYZ boundsL1_) { if (wallEntry->flags & WALL_SCENERY_HAS_PRIMARY_COLOUR) { @@ -98,8 +98,8 @@ static void fence_paint_door( static void fence_paint_wall( paint_session* session, uint32_t frameNum, const WallSceneryEntry* wallEntry, uint32_t dword_141F710, - uint32_t imageColourFlags, uint32_t dword_141F718, uint32_t tertiaryColour, uint32_t imageOffset, LocationXYZ16 offset, - LocationXYZ16 bounds, LocationXYZ16 boundsOffset) + uint32_t imageColourFlags, uint32_t dword_141F718, uint32_t tertiaryColour, uint32_t imageOffset, CoordsXYZ offset, + CoordsXYZ bounds, CoordsXYZ boundsOffset) { uint32_t baseImageId = wallEntry->image + imageOffset + frameNum; uint32_t imageId = baseImageId; @@ -210,8 +210,8 @@ void fence_paint(paint_session* session, uint8_t direction, int32_t height, cons if (wallEntry->flags & WALL_SCENERY_IS_DOOR) { - LocationXYZ16 offset; - LocationXYZ16 boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_; + CoordsXYZ offset; + CoordsXYZ boundsR1, boundsR1_, boundsR2, boundsR2_, boundsL1, boundsL1_; uint8_t animationFrame = tile_element->AsWall()->GetAnimationFrame(); // Add the direction as well if (tile_element->AsWall()->AnimationIsBackwards()) @@ -296,7 +296,7 @@ void fence_paint(paint_session* session, uint8_t direction, int32_t height, cons } uint32_t imageOffset = 0; - LocationXYZ16 offset = { 0, 0, 0 }, bounds = { 0, 0, 0 }, boundsOffset = { 0, 0, 0 }; + CoordsXYZ offset = { 0, 0, 0 }, bounds = { 0, 0, 0 }, boundsOffset = { 0, 0, 0 }; switch (direction) { diff --git a/src/openrct2/world/Location.hpp b/src/openrct2/world/Location.hpp index fae9ba192a..7fd725fffa 100644 --- a/src/openrct2/world/Location.hpp +++ b/src/openrct2/world/Location.hpp @@ -22,21 +22,6 @@ constexpr const int32_t COORDS_Z_PER_TINY_Z = 16; constexpr const auto NumOrthogonalDirections = 4; -#pragma pack(push, 1) - -struct LocationXY16 -{ - int16_t x, y; -}; -assert_struct_size(LocationXY16, 4); - -struct LocationXYZ16 -{ - int16_t x, y, z; -}; -assert_struct_size(LocationXYZ16, 6); -#pragma pack(pop) - constexpr int32_t COORDS_NULL = 0xFFFF8000; struct ScreenCoordsXY diff --git a/src/openrct2/world/Scenery.h b/src/openrct2/world/Scenery.h index 4a780962e1..375c2ce153 100644 --- a/src/openrct2/world/Scenery.h +++ b/src/openrct2/world/Scenery.h @@ -20,6 +20,8 @@ #define SCENERY_WITHER_AGE_THRESHOLD_1 0x28 #define SCENERY_WITHER_AGE_THRESHOLD_2 0x37 +struct LargeSceneryText; + #pragma pack(push, 1) struct SceneryEntryBase @@ -56,7 +58,10 @@ assert_struct_size(rct_large_scenery_text_glyph, 4); struct rct_large_scenery_text { - LocationXY16 offset[2]; // 0x0 + struct + { + int16_t x, y; + } offset[2]; // 0x0 uint16_t max_width; // 0x8 uint16_t pad_A; // 0xA uint8_t flags; // 0xC @@ -80,7 +85,7 @@ struct LargeSceneryEntry : SceneryEntryBase rct_large_scenery_tile* tiles; ObjectEntryIndex scenery_tab_id; uint8_t scrolling_mode; - rct_large_scenery_text* text; + LargeSceneryText* text; uint32_t text_image; }; @@ -159,6 +164,33 @@ struct BannerSceneryEntry : SceneryEntryBase #pragma pack(pop) +struct LargeSceneryText +{ + CoordsXY offset[2]; + uint16_t max_width; + uint8_t flags; + uint16_t num_images; + rct_large_scenery_text_glyph glyphs[256]; + + LargeSceneryText() = default; + + explicit LargeSceneryText(const rct_large_scenery_text& original) + { + for (size_t i = 0; i < std::size(original.offset); i++) + { + offset[i].x = original.offset[i].x; + offset[i].y = original.offset[i].y; + } + max_width = original.max_width; + flags = original.flags; + num_images = original.num_images; + for (size_t i = 0; i < std::size(original.glyphs); i++) + { + glyphs[i] = original.glyphs[i]; + } + } +}; + struct rct_scenery_group_entry { rct_string_id name; From 08bd6080fdfd7ea4fde3d82a2022c87143a4bc3f Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Tue, 8 Jun 2021 07:46:56 +0100 Subject: [PATCH 36/39] Add missing compare This should hopefully fail the test --- test/tests/S6ImportExportTests.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/test/tests/S6ImportExportTests.cpp b/test/tests/S6ImportExportTests.cpp index 3f27396092..c1d9bff4e7 100644 --- a/test/tests/S6ImportExportTests.cpp +++ b/test/tests/S6ImportExportTests.cpp @@ -363,6 +363,7 @@ static void CompareSpriteDataVehicle(const Vehicle& left, const Vehicle& right) COMPARE_FIELD(colours_extended); COMPARE_FIELD(seat_rotation); COMPARE_FIELD(target_seat_rotation); + COMPARE_FIELD(BoatLocation); COMPARE_FIELD(IsCrashedVehicle); } From 5d891a0abdec9ed21171285d72985db274454770 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Mon, 7 Jun 2021 17:16:54 +0100 Subject: [PATCH 37/39] Enforce tile start on boat location --- src/openrct2/ride/Vehicle.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 352b649bf5..6d361df18f 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -4656,7 +4656,7 @@ void Vehicle::UpdateBoatLocation() if (location.ToTileStart() == returnPosition.ToCoordsXY()) { sub_state = 1; - BoatLocation = location; + BoatLocation = location.ToTileStart(); return; } @@ -4700,13 +4700,13 @@ void Vehicle::UpdateBoatLocation() continue; } - BoatLocation = trackLocation; + BoatLocation = trackLocation.ToTileStart(); return; } CoordsXY trackLocation = TrackLocation; trackLocation += CoordsDirectionDelta[curDirection & 3]; - BoatLocation = trackLocation; + BoatLocation = trackLocation.ToTileStart(); } /** From b959f5ae2c45675cb7fdad6e3f96380e0f98cffe Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Tue, 8 Jun 2021 08:04:18 +0100 Subject: [PATCH 38/39] Increment network version --- src/openrct2/network/NetworkBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index a4ee899bba..c15e6661d0 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -37,7 +37,7 @@ // 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. -#define NETWORK_STREAM_VERSION "17" +#define NETWORK_STREAM_VERSION "18" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static Peep* _pickup_peep = nullptr; From 072772af7bb81298fa2844da1763b66223218e6a Mon Sep 17 00:00:00 2001 From: Duncan Date: Tue, 8 Jun 2021 08:35:31 +0100 Subject: [PATCH 39/39] Rework importexport test to use GameStateSnapshots (#14838) Rework importexport test to use GameStateSnapshots Output errors Rename function --- src/openrct2/GameStateSnapshots.cpp | 8 +- src/openrct2/GameStateSnapshots.h | 5 + test/tests/S6ImportExportTests.cpp | 458 +++------------------------- 3 files changed, 62 insertions(+), 409 deletions(-) diff --git a/src/openrct2/GameStateSnapshots.cpp b/src/openrct2/GameStateSnapshots.cpp index 5bf1ec0cb1..8ba15a0de6 100644 --- a/src/openrct2/GameStateSnapshots.cpp +++ b/src/openrct2/GameStateSnapshots.cpp @@ -663,7 +663,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots return "Unknown"; } - virtual bool LogCompareDataToFile(const std::string& fileName, const GameStateCompareData_t& cmpData) const override + virtual std::string GetCompareDataText(const GameStateCompareData_t& cmpData) const override { std::string outputBuffer; char tempBuffer[1024] = {}; @@ -715,6 +715,12 @@ struct GameStateSnapshots final : public IGameStateSnapshots } } } + return outputBuffer; + } + + virtual bool LogCompareDataToFile(const std::string& fileName, const GameStateCompareData_t& cmpData) const override + { + auto outputBuffer = GetCompareDataText(cmpData); FILE* fp = fopen(fileName.c_str(), "wt"); if (!fp) diff --git a/src/openrct2/GameStateSnapshots.h b/src/openrct2/GameStateSnapshots.h index a155167313..f7490c953d 100644 --- a/src/openrct2/GameStateSnapshots.h +++ b/src/openrct2/GameStateSnapshots.h @@ -103,6 +103,11 @@ struct IGameStateSnapshots * Writes the GameStateCompareData_t into the specified file as readable text. */ virtual bool LogCompareDataToFile(const std::string& fileName, const GameStateCompareData_t& cmpData) const = 0; + + /* + * Generates a string of readable text from GameStateCompareData_t + */ + virtual std::string GetCompareDataText(const GameStateCompareData_t& cmpData) const = 0; }; std::unique_ptr CreateGameStateSnapshots(); diff --git a/test/tests/S6ImportExportTests.cpp b/test/tests/S6ImportExportTests.cpp index c1d9bff4e7..327042c350 100644 --- a/test/tests/S6ImportExportTests.cpp +++ b/test/tests/S6ImportExportTests.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -25,29 +26,16 @@ #include #include #include -#include #include #include #include -#include -#include -#include #include -#include -#include -#include -#include #include #include #include using namespace OpenRCT2; -struct GameState_t -{ - rct_sprite sprites[MAX_ENTITIES]; -}; - static bool LoadFileToBuffer(MemoryStream& stream, const std::string& filePath) { FILE* fp = fopen(filePath.c_str(), "rb"); @@ -110,18 +98,15 @@ static bool ExportSave(MemoryStream& stream, std::unique_ptr& context) return true; } -static std::unique_ptr GetGameState(std::unique_ptr& context) +static void RecordGameStateSnapshot(std::unique_ptr& context, MemoryStream& snapshotStream) { - std::unique_ptr res = std::make_unique(); - for (size_t spriteIdx = 0; spriteIdx < MAX_ENTITIES; spriteIdx++) - { - rct_sprite* sprite = reinterpret_cast(GetEntity(spriteIdx)); - if (sprite == nullptr) - res->sprites[spriteIdx].base.Type = EntityType::Null; - else - res->sprites[spriteIdx] = *sprite; - } - return res; + auto* snapshots = context->GetGameStateSnapshots(); + + auto& snapshot = snapshots->CreateSnapshot(); + snapshots->Capture(snapshot); + snapshots->LinkSnapshot(snapshot, gCurrentTicks, scenario_rand_state().s0); + DataSerialiser snapShotDs(true, snapshotStream); + snapshots->SerialiseSnapshot(snapshot, snapShotDs); } static void AdvanceGameTicks(uint32_t ticks, std::unique_ptr& context) @@ -133,369 +118,7 @@ static void AdvanceGameTicks(uint32_t ticks, std::unique_ptr& context) } } -#define COMPARE_FIELD(field) EXPECT_EQ(left.field, right.field) - -static void CompareSpriteDataCommon(const SpriteBase& left, const SpriteBase& right) -{ - COMPARE_FIELD(Type); - COMPARE_FIELD(sprite_index); - COMPARE_FIELD(x); - COMPARE_FIELD(y); - COMPARE_FIELD(z); - // INVESTIGATE: These fields never match but are also not important to the game state. - /* - COMPARE_FIELD(sprite_width); - COMPARE_FIELD(sprite_height_negative); - COMPARE_FIELD(sprite_height_positive); - COMPARE_FIELD(sprite_left); - COMPARE_FIELD(sprite_top); - COMPARE_FIELD(sprite_right); - COMPARE_FIELD(sprite_bottom); - */ - COMPARE_FIELD(sprite_direction); -} - -static void CompareSpriteDataPeep(const Peep& left, const Peep& right) -{ - COMPARE_FIELD(NextLoc.x); - COMPARE_FIELD(NextLoc.y); - COMPARE_FIELD(NextLoc.z); - COMPARE_FIELD(NextFlags); - COMPARE_FIELD(State); - COMPARE_FIELD(SubState); - COMPARE_FIELD(SpriteType); - COMPARE_FIELD(TshirtColour); - COMPARE_FIELD(TrousersColour); - COMPARE_FIELD(DestinationX); - COMPARE_FIELD(DestinationY); - COMPARE_FIELD(DestinationTolerance); - COMPARE_FIELD(Var37); - COMPARE_FIELD(Energy); - COMPARE_FIELD(EnergyTarget); - COMPARE_FIELD(Mass); - COMPARE_FIELD(WindowInvalidateFlags); - COMPARE_FIELD(CurrentRide); - COMPARE_FIELD(CurrentRideStation); - COMPARE_FIELD(CurrentTrain); - COMPARE_FIELD(TimeToSitdown); - COMPARE_FIELD(SpecialSprite); - COMPARE_FIELD(ActionSpriteType); - COMPARE_FIELD(NextActionSpriteType); - COMPARE_FIELD(ActionSpriteImageOffset); - COMPARE_FIELD(Action); - COMPARE_FIELD(ActionFrame); - COMPARE_FIELD(StepProgress); - COMPARE_FIELD(MazeLastEdge); - COMPARE_FIELD(InteractionRideIndex); - COMPARE_FIELD(Id); - COMPARE_FIELD(PathCheckOptimisation); - COMPARE_FIELD(PeepFlags); - COMPARE_FIELD(PathfindGoal.x); - COMPARE_FIELD(PathfindGoal.y); - COMPARE_FIELD(PathfindGoal.z); - COMPARE_FIELD(PathfindGoal.direction); - for (int i = 0; i < 4; i++) - { - COMPARE_FIELD(PathfindHistory[i].x); - COMPARE_FIELD(PathfindHistory[i].y); - COMPARE_FIELD(PathfindHistory[i].z); - COMPARE_FIELD(PathfindHistory[i].direction); - } - COMPARE_FIELD(WalkingFrameNum); -} - -static void CompareSpriteDataGuest(const Guest& left, const Guest& right) -{ - CompareSpriteDataPeep(left, right); - COMPARE_FIELD(OutsideOfPark); - COMPARE_FIELD(GuestNumRides); - COMPARE_FIELD(Happiness); - COMPARE_FIELD(HappinessTarget); - COMPARE_FIELD(Nausea); - COMPARE_FIELD(NauseaTarget); - COMPARE_FIELD(Hunger); - COMPARE_FIELD(Thirst); - COMPARE_FIELD(Toilet); - COMPARE_FIELD(TimeToConsume); - COMPARE_FIELD(Intensity); - COMPARE_FIELD(NauseaTolerance); - COMPARE_FIELD(PaidOnDrink); - for (int i = 0; i < PEEP_MAX_THOUGHTS; i++) - { - COMPARE_FIELD(RideTypesBeenOn[i]); - } - COMPARE_FIELD(ItemFlags); - COMPARE_FIELD(Photo2RideRef); - COMPARE_FIELD(Photo3RideRef); - COMPARE_FIELD(Photo4RideRef); - COMPARE_FIELD(GuestNextInQueue); - COMPARE_FIELD(TimeInQueue); - for (int i = 0; i < 32; i++) - { - COMPARE_FIELD(RidesBeenOn[i]); - } - COMPARE_FIELD(CashInPocket); - COMPARE_FIELD(CashSpent); - COMPARE_FIELD(ParkEntryTime); - COMPARE_FIELD(RejoinQueueTimeout); - COMPARE_FIELD(PreviousRide); - COMPARE_FIELD(PreviousRideTimeOut); - for (int i = 0; i < PEEP_MAX_THOUGHTS; i++) - { - COMPARE_FIELD(Thoughts[i].type); - COMPARE_FIELD(Thoughts[i].item); - COMPARE_FIELD(Thoughts[i].freshness); - COMPARE_FIELD(Thoughts[i].fresh_timeout); - } - COMPARE_FIELD(GuestHeadingToRideId); - COMPARE_FIELD(GuestIsLostCountdown); - COMPARE_FIELD(Photo1RideRef); - COMPARE_FIELD(LitterCount); - COMPARE_FIELD(GuestTimeOnRide); - COMPARE_FIELD(DisgustingCount); - COMPARE_FIELD(PaidToEnter); - COMPARE_FIELD(PaidOnRides); - COMPARE_FIELD(PaidOnFood); - COMPARE_FIELD(PaidOnSouvenirs); - COMPARE_FIELD(AmountOfFood); - COMPARE_FIELD(AmountOfDrinks); - COMPARE_FIELD(AmountOfSouvenirs); - COMPARE_FIELD(VandalismSeen); - COMPARE_FIELD(VoucherType); - COMPARE_FIELD(VoucherRideId); - COMPARE_FIELD(SurroundingsThoughtTimeout); - COMPARE_FIELD(Angriness); - COMPARE_FIELD(TimeLost); - COMPARE_FIELD(DaysInQueue); - COMPARE_FIELD(BalloonColour); - COMPARE_FIELD(UmbrellaColour); - COMPARE_FIELD(HatColour); - COMPARE_FIELD(FavouriteRide); - COMPARE_FIELD(FavouriteRideRating); -} - -static void CompareSpriteDataStaff(const Staff& left, const Staff& right) -{ - CompareSpriteDataPeep(left, right); - - COMPARE_FIELD(AssignedStaffType); - COMPARE_FIELD(MechanicTimeSinceCall); - COMPARE_FIELD(HireDate); - COMPARE_FIELD(StaffId); - COMPARE_FIELD(StaffOrders); - COMPARE_FIELD(StaffMowingTimeout); - COMPARE_FIELD(StaffRidesFixed); - COMPARE_FIELD(StaffRidesInspected); - COMPARE_FIELD(StaffLitterSwept); - COMPARE_FIELD(StaffBinsEmptied); -} - -static void CompareSpriteDataVehicle(const Vehicle& left, const Vehicle& right) -{ - COMPARE_FIELD(SubType); - COMPARE_FIELD(Pitch); - COMPARE_FIELD(bank_rotation); - COMPARE_FIELD(remaining_distance); - COMPARE_FIELD(velocity); - COMPARE_FIELD(acceleration); - COMPARE_FIELD(ride); - COMPARE_FIELD(vehicle_type); - COMPARE_FIELD(colours.body_colour); - COMPARE_FIELD(colours.trim_colour); - COMPARE_FIELD(track_progress); - COMPARE_FIELD(TrackTypeAndDirection); - COMPARE_FIELD(TrackLocation.x); - COMPARE_FIELD(TrackLocation.y); - COMPARE_FIELD(TrackLocation.z); - COMPARE_FIELD(next_vehicle_on_train); - COMPARE_FIELD(prev_vehicle_on_ride); - COMPARE_FIELD(next_vehicle_on_ride); - COMPARE_FIELD(var_44); - COMPARE_FIELD(mass); - COMPARE_FIELD(update_flags); - COMPARE_FIELD(SwingSprite); - COMPARE_FIELD(current_station); - COMPARE_FIELD(SwingPosition); - COMPARE_FIELD(SwingSpeed); - COMPARE_FIELD(status); - COMPARE_FIELD(sub_state); - for (int i = 0; i < 32; i++) - { - COMPARE_FIELD(peep[i]); - } - for (int i = 0; i < 32; i++) - { - COMPARE_FIELD(peep_tshirt_colours[i]); - } - COMPARE_FIELD(num_seats); - COMPARE_FIELD(num_peeps); - COMPARE_FIELD(next_free_seat); - COMPARE_FIELD(restraints_position); - COMPARE_FIELD(spin_speed); - COMPARE_FIELD(sound2_flags); - COMPARE_FIELD(spin_sprite); - COMPARE_FIELD(sound1_id); - COMPARE_FIELD(sound1_volume); - COMPARE_FIELD(sound2_id); - COMPARE_FIELD(sound2_volume); - COMPARE_FIELD(sound_vector_factor); - COMPARE_FIELD(cable_lift_target); - COMPARE_FIELD(speed); - COMPARE_FIELD(powered_acceleration); - COMPARE_FIELD(var_C4); - COMPARE_FIELD(animation_frame); - for (int i = 0; i < 2; i++) - { - COMPARE_FIELD(pad_C6[i]); - } - COMPARE_FIELD(var_C8); - COMPARE_FIELD(var_CA); - COMPARE_FIELD(scream_sound_id); - COMPARE_FIELD(TrackSubposition); - COMPARE_FIELD(num_laps); - COMPARE_FIELD(brake_speed); - COMPARE_FIELD(lost_time_out); - COMPARE_FIELD(vertical_drop_countdown); - COMPARE_FIELD(var_D3); - COMPARE_FIELD(mini_golf_current_animation); - COMPARE_FIELD(mini_golf_flags); - COMPARE_FIELD(ride_subtype); - COMPARE_FIELD(colours_extended); - COMPARE_FIELD(seat_rotation); - COMPARE_FIELD(target_seat_rotation); - COMPARE_FIELD(BoatLocation); - COMPARE_FIELD(IsCrashedVehicle); -} - -static void CompareSpriteDataLitter(const Litter& left, const Litter& right) -{ - COMPARE_FIELD(SubType); - COMPARE_FIELD(creationTick); -} - -static void CompareSpriteDataSteamParticle(const SteamParticle& left, const SteamParticle& right) -{ - COMPARE_FIELD(frame); - COMPARE_FIELD(time_to_move); -} - -static void CompareSpriteDataMoneyEffect(const MoneyEffect& left, const MoneyEffect& right) -{ - COMPARE_FIELD(frame); - COMPARE_FIELD(MoveDelay); - COMPARE_FIELD(NumMovements); - COMPARE_FIELD(Vertical); - COMPARE_FIELD(Value); - COMPARE_FIELD(OffsetX); - COMPARE_FIELD(Wiggle); -} - -static void CompareSpriteDataCrashedVehicleParticle(const VehicleCrashParticle& left, const VehicleCrashParticle& right) -{ - COMPARE_FIELD(frame); - COMPARE_FIELD(time_to_live); - for (size_t i = 0; i < std::size(left.colour); i++) - { - COMPARE_FIELD(colour[i]); - } - COMPARE_FIELD(crashed_sprite_base); - COMPARE_FIELD(velocity_x); - COMPARE_FIELD(velocity_y); - COMPARE_FIELD(velocity_z); - COMPARE_FIELD(acceleration_x); - COMPARE_FIELD(acceleration_y); - COMPARE_FIELD(acceleration_z); -} - -static void CompareSpriteDataJumpingFountain(const JumpingFountain& left, const JumpingFountain& right) -{ - COMPARE_FIELD(frame); - COMPARE_FIELD(NumTicksAlive); - COMPARE_FIELD(FountainFlags); - COMPARE_FIELD(TargetX); - COMPARE_FIELD(TargetY); - COMPARE_FIELD(Iteration); - COMPARE_FIELD(FountainType); -} - -static void CompareSpriteDataBalloon(const Balloon& left, const Balloon& right) -{ - COMPARE_FIELD(frame); - COMPARE_FIELD(popped); - COMPARE_FIELD(time_to_move); - COMPARE_FIELD(colour); -} - -static void CompareSpriteDataDuck(const Duck& left, const Duck& right) -{ - COMPARE_FIELD(frame); - COMPARE_FIELD(target_x); - COMPARE_FIELD(target_y); - COMPARE_FIELD(state); -} - -static void CompareSpriteDataMisc(const MiscEntity& left, const MiscEntity& right) -{ - COMPARE_FIELD(frame); -} - -static void CompareSpriteData(const rct_sprite& left, const rct_sprite& right) -{ - CompareSpriteDataCommon(left.base, right.base); - if (left.base.Type == right.base.Type) - { - switch (left.base.Type) - { - case EntityType::Guest: - CompareSpriteDataGuest(static_cast(left.base), static_cast(right.base)); - break; - case EntityType::Staff: - CompareSpriteDataStaff(static_cast(left.base), static_cast(right.base)); - break; - case EntityType::Vehicle: - CompareSpriteDataVehicle(static_cast(left.base), static_cast(right.base)); - break; - case EntityType::Litter: - CompareSpriteDataLitter(static_cast(left.base), static_cast(right.base)); - break; - case EntityType::SteamParticle: - CompareSpriteDataSteamParticle( - static_cast(left.base), static_cast(right.base)); - break; - case EntityType::MoneyEffect: - CompareSpriteDataMoneyEffect( - static_cast(left.base), static_cast(right.base)); - break; - case EntityType::CrashedVehicleParticle: - CompareSpriteDataCrashedVehicleParticle( - static_cast(left.base), static_cast(right.base)); - break; - case EntityType::JumpingFountain: - CompareSpriteDataJumpingFountain( - static_cast(left.base), static_cast(right.base)); - break; - case EntityType::Balloon: - CompareSpriteDataBalloon(static_cast(left.base), static_cast(right.base)); - break; - case EntityType::Duck: - CompareSpriteDataDuck(static_cast(left.base), static_cast(right.base)); - break; - case EntityType::ExplosionCloud: - case EntityType::CrashSplash: - case EntityType::ExplosionFlare: - CompareSpriteDataMisc(static_cast(left.base), static_cast(right.base)); - break; - case EntityType::Null: - break; - default: - break; - } - } -} - -static void CompareStates( - MemoryStream& importBuffer, MemoryStream& exportBuffer, std::unique_ptr& importedState, - std::unique_ptr& exportedState) +static void CompareStates(MemoryStream& importBuffer, MemoryStream& exportBuffer, MemoryStream& snapshotStream) { if (importBuffer.GetLength() != exportBuffer.GetLength()) { @@ -505,14 +128,39 @@ static void CompareStates( static_cast(exportBuffer.GetLength())); } - for (size_t spriteIdx = 0; spriteIdx < MAX_ENTITIES; ++spriteIdx) + std::unique_ptr context = CreateContext(); + EXPECT_NE(context, nullptr); + bool initialised = context->Initialise(); + ASSERT_TRUE(initialised); + + DataSerialiser ds(false, snapshotStream); + IGameStateSnapshots* snapshots = GetContext()->GetGameStateSnapshots(); + + GameStateSnapshot_t& importSnapshot = snapshots->CreateSnapshot(); + snapshots->SerialiseSnapshot(importSnapshot, ds); + + GameStateSnapshot_t& exportSnapshot = snapshots->CreateSnapshot(); + snapshots->SerialiseSnapshot(exportSnapshot, ds); + + try { - if (importedState->sprites[spriteIdx].base.Type == EntityType::Null - && exportedState->sprites[spriteIdx].base.Type == EntityType::Null) + GameStateCompareData_t cmpData = snapshots->Compare(importSnapshot, exportSnapshot); + + // Find out if there are any differences between the two states + auto res = std::find_if( + cmpData.spriteChanges.begin(), cmpData.spriteChanges.end(), + [](const GameStateSpriteChange_t& diff) { return diff.changeType != GameStateSpriteChange_t::EQUAL; }); + + if (res != cmpData.spriteChanges.end()) { - continue; + log_warning("Snapshot data differences. %s", snapshots->GetCompareDataText(cmpData).c_str()); + FAIL(); } - CompareSpriteData(importedState->sprites[spriteIdx], exportedState->sprites[spriteIdx]); + } + catch (const std::runtime_error& err) + { + log_warning("Snapshot data failed to be read. Snapshot not compared. %s", err.what()); + FAIL(); } } @@ -525,9 +173,7 @@ TEST(S6ImportExportBasic, all) MemoryStream importBuffer; MemoryStream exportBuffer; - - std::unique_ptr importedState; - std::unique_ptr exportedState; + MemoryStream snapshotStream; // Load initial park data. { @@ -540,8 +186,7 @@ TEST(S6ImportExportBasic, all) std::string testParkPath = TestData::GetParkPath("BigMapTest.sv6"); ASSERT_TRUE(LoadFileToBuffer(importBuffer, testParkPath)); ASSERT_TRUE(ImportSave(importBuffer, context, false)); - importedState = GetGameState(context); - ASSERT_NE(importedState, nullptr); + RecordGameStateSnapshot(context, snapshotStream); ASSERT_TRUE(ExportSave(exportBuffer, context)); } @@ -556,11 +201,11 @@ TEST(S6ImportExportBasic, all) ASSERT_TRUE(ImportSave(exportBuffer, context, true)); - exportedState = GetGameState(context); - ASSERT_NE(exportedState, nullptr); + RecordGameStateSnapshot(context, snapshotStream); } - CompareStates(importBuffer, exportBuffer, importedState, exportedState); + snapshotStream.SetPosition(0); + CompareStates(importBuffer, exportBuffer, snapshotStream); SUCCEED(); } @@ -574,9 +219,7 @@ TEST(S6ImportExportAdvanceTicks, all) MemoryStream importBuffer; MemoryStream exportBuffer; - - std::unique_ptr importedState; - std::unique_ptr exportedState; + MemoryStream snapshotStream; // Load initial park data. { @@ -592,8 +235,7 @@ TEST(S6ImportExportAdvanceTicks, all) AdvanceGameTicks(1000, context); ASSERT_TRUE(ExportSave(exportBuffer, context)); - importedState = GetGameState(context); - ASSERT_NE(importedState, nullptr); + RecordGameStateSnapshot(context, snapshotStream); } // Import the exported version. @@ -606,11 +248,11 @@ TEST(S6ImportExportAdvanceTicks, all) ASSERT_TRUE(ImportSave(exportBuffer, context, true)); - exportedState = GetGameState(context); - ASSERT_NE(exportedState, nullptr); + RecordGameStateSnapshot(context, snapshotStream); } - CompareStates(importBuffer, exportBuffer, importedState, exportedState); + snapshotStream.SetPosition(0); + CompareStates(importBuffer, exportBuffer, snapshotStream); SUCCEED(); }