From 2fca2adbc1a36a4ea0c673b6cb4356a85cc504de Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Mon, 19 Dec 2016 18:45:08 +0100 Subject: [PATCH] Fix prepended wooden supports --- src/paint/supports.c | 8 +- src/rct2/interop.c | 3 + src/ride/coaster/heartline_twister_coaster.c | 24 +++--- src/ride/coaster/mine_train_coaster.c | 12 +-- src/ride/coaster/wooden_roller_coaster.c | 10 +-- src/ride/coaster/wooden_wild_mouse.c | 6 +- src/ride/thrill/go_karts.c | 18 ++--- src/ride/water/splash_boats.c | 6 +- test/testpaint/FunctionCall.cpp | 11 +++ test/testpaint/FunctionCall.hpp | 2 + test/testpaint/PaintIntercept.cpp | 82 +++++++++++--------- test/testpaint/Printer.cpp | 29 ++++++- test/testpaint/TestTrack.cpp | 3 + 13 files changed, 133 insertions(+), 81 deletions(-) diff --git a/src/paint/supports.c b/src/paint/supports.c index bc1b1331ce..c2cc1416ae 100644 --- a/src/paint/supports.c +++ b/src/paint/supports.c @@ -222,7 +222,7 @@ typedef struct unk_supports_desc_bound_box { uint8 x, y, z; } offset; struct { - uint8 y, x, z; + uint8 x, y, z; } length; } unk_supports_desc_bound_box; @@ -436,7 +436,7 @@ bool wooden_a_supports_paint_setup(int supportType, int special, int height, uin if ((z & 16) == 0 && height >= 2 && z + 16 != gUnk141E9DC) { // Full support int imageId = WoodenSupportImageIds[supportType].full | imageColourFlags; - uint8 ah = special == 2 ? 23 : 28; + uint8 ah = height == 2 ? 23 : 28; sub_98196C(imageId, 0, 0, 32, 32, ah, z, rotation); hasSupports = true; z += 32; @@ -444,7 +444,7 @@ bool wooden_a_supports_paint_setup(int supportType, int special, int height, uin } else { // Half support int imageId = WoodenSupportImageIds[supportType].half | imageColourFlags; - uint8 ah = special == 1 ? 7 : 12; + uint8 ah = height == 1 ? 7 : 12; sub_98196C(imageId, 0, 0, 32, 32, ah, z, rotation); hasSupports = true; z += 16; @@ -651,7 +651,7 @@ bool wooden_b_supports_paint_setup(int supportType, int special, int height, uin sub_98197C( imageId | imageColourFlags, 0, 0, - boundBox.length.y, boundBox.length.x, boundBox.length.z, + boundBox.length.x, boundBox.length.y, boundBox.length.z, baseHeight, boundBox.offset.x, boundBox.offset.y, boundBox.offset.z + baseHeight, get_current_rotation() diff --git a/src/rct2/interop.c b/src/rct2/interop.c index a653469090..ac4ece0d2c 100644 --- a/src/rct2/interop.c +++ b/src/rct2/interop.c @@ -63,6 +63,9 @@ bool rct2_interop_setup_segment() // in some configurations err and len may be unused UNUSED(err); UNUSED(len); +#if !defined(NO_RCT2) + UNUSED(segments); +#endif #if defined(USE_MMAP) && (defined(__unix__) || defined(__MACOSX__)) && !defined(NO_RCT2) #define RDATA_OFFSET 0x004A4000 #define DATASEG_OFFSET 0x005E2000 diff --git a/src/ride/coaster/heartline_twister_coaster.c b/src/ride/coaster/heartline_twister_coaster.c index 8f462ef0f7..28b3d28a0a 100644 --- a/src/ride/coaster/heartline_twister_coaster.c +++ b/src/ride/coaster/heartline_twister_coaster.c @@ -161,12 +161,12 @@ static void heartline_twister_rc_track_60_deg_up(uint8 rideIndex, uint8 trackSeq wooden_a_supports_paint_setup(6, 21, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 1: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21403, 0, 0, 32, 20, 2, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21403, 0, 0, 32, 20, 2, height, 0, 6, height); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21407, 0, 0, 32, 1, 98, height, 0, 27, height); wooden_a_supports_paint_setup(7, 22, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 2: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21404, 0, 0, 32, 20, 2, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21404, 0, 0, 32, 20, 2, height, 0, 6, height); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21408, 0, 0, 32, 1, 98, height, 0, 27, height); wooden_a_supports_paint_setup(6, 23, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; @@ -184,12 +184,12 @@ static void heartline_twister_rc_track_60_deg_up(uint8 rideIndex, uint8 trackSeq wooden_a_supports_paint_setup(6, 21, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 1: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21347, 0, 0, 32, 20, 2, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21347, 0, 0, 32, 20, 2, height, 0, 6, height); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21351, 0, 0, 32, 1, 98, height, 0, 27, height); wooden_a_supports_paint_setup(7, 22, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 2: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21348, 0, 0, 32, 20, 2, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21348, 0, 0, 32, 20, 2, height, 0, 6, height); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21352, 0, 0, 32, 1, 98, height, 0, 27, height); wooden_a_supports_paint_setup(6, 23, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; @@ -279,12 +279,12 @@ static void heartline_twister_rc_track_25_deg_up_to_60_deg_up(uint8 rideIndex, u wooden_a_supports_paint_setup(6, 13, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 1: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21387, 0, 0, 32, 20, 2, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21387, 0, 0, 32, 20, 2, height, 0, 6, height); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21391, 0, 0, 32, 1, 66, height, 0, 27, height); wooden_a_supports_paint_setup(7, 14, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 2: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21388, 0, 0, 32, 20, 2, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21388, 0, 0, 32, 20, 2, height, 0, 6, height); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21392, 0, 0, 32, 1, 66, height, 0, 27, height); wooden_a_supports_paint_setup(6, 15, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; @@ -302,12 +302,12 @@ static void heartline_twister_rc_track_25_deg_up_to_60_deg_up(uint8 rideIndex, u wooden_a_supports_paint_setup(6, 13, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 1: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21331, 0, 0, 32, 20, 2, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21331, 0, 0, 32, 20, 2, height, 0, 6, height); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21335, 0, 0, 32, 1, 66, height, 0, 27, height); wooden_a_supports_paint_setup(7, 14, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 2: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21332, 0, 0, 32, 20, 2, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21332, 0, 0, 32, 20, 2, height, 0, 6, height); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21336, 0, 0, 32, 1, 66, height, 0, 27, height); wooden_a_supports_paint_setup(6, 15, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; @@ -338,12 +338,12 @@ static void heartline_twister_rc_track_60_deg_up_to_25_deg_up(uint8 rideIndex, u wooden_a_supports_paint_setup(6, 17, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 1: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21395, 0, 0, 32, 20, 2, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21395, 0, 0, 32, 20, 2, height, 0, 6, height); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21399, 0, 0, 32, 1, 66, height, 0, 27, height); wooden_a_supports_paint_setup(7, 18, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 2: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21396, 0, 0, 32, 20, 2, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21396, 0, 0, 32, 20, 2, height, 0, 6, height); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21400, 0, 0, 32, 1, 66, height, 0, 27, height); wooden_a_supports_paint_setup(6, 19, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; @@ -361,12 +361,12 @@ static void heartline_twister_rc_track_60_deg_up_to_25_deg_up(uint8 rideIndex, u wooden_a_supports_paint_setup(6, 17, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 1: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21339, 0, 0, 32, 20, 2, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21339, 0, 0, 32, 20, 2, height, 0, 6, height); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21343, 0, 0, 32, 1, 66, height, 0, 27, height); wooden_a_supports_paint_setup(7, 18, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 2: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21340, 0, 0, 32, 20, 2, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21340, 0, 0, 32, 20, 2, height, 0, 6, height); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 21344, 0, 0, 32, 1, 66, height, 0, 27, height); wooden_a_supports_paint_setup(6, 19, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; diff --git a/src/ride/coaster/mine_train_coaster.c b/src/ride/coaster/mine_train_coaster.c index bce77fc201..45fd3b94e4 100644 --- a/src/ride/coaster/mine_train_coaster.c +++ b/src/ride/coaster/mine_train_coaster.c @@ -150,11 +150,11 @@ static void mine_train_rc_track_60_deg_up(uint8 rideIndex, uint8 trackSequence, wooden_a_supports_paint_setup(6, 21, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 1: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20091, 0, 0, 1, 32, 98, height, 27, 0, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20091, 0, 0, 1, 32, 98, height, 27, 0, height); wooden_a_supports_paint_setup(7, 22, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 2: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20092, 0, 0, 1, 32, 98, height, 27, 0, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20092, 0, 0, 1, 32, 98, height, 27, 0, height); wooden_a_supports_paint_setup(6, 23, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 3: @@ -231,12 +231,12 @@ static void mine_train_rc_track_25_deg_up_to_60_deg_up(uint8 rideIndex, uint8 tr wooden_a_supports_paint_setup(6, 13, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 1: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20079, 0, 0, 32, 20, 1, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20079, 0, 0, 32, 20, 1, height, 0, 6, height); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20082, 0, 0, 32, 1, 66, height, 0, 27, height); wooden_a_supports_paint_setup(7, 14, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 2: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20080, 0, 0, 32, 20, 1, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20080, 0, 0, 32, 20, 1, height, 0, 6, height); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20083, 0, 0, 32, 1, 66, height, 0, 27, height); wooden_a_supports_paint_setup(6, 15, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; @@ -263,12 +263,12 @@ static void mine_train_rc_track_60_deg_up_to_25_deg_up(uint8 rideIndex, uint8 tr wooden_a_supports_paint_setup(6, 17, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 1: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20085, 0, 0, 24, 1, 61, height, 4, 29, height - 16); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20085, 0, 0, 24, 1, 61, height, 4, 29, height - 16); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20088, 0, 0, 32, 2, 66, height, 0, 4, height); wooden_a_supports_paint_setup(7, 18, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; case 2: - sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20086, 0, 0, 24, 1, 61, height, 4, 29, height - 16); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20086, 0, 0, 24, 1, 61, height, 4, 29, height - 16); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 20089, 0, 0, 32, 2, 66, height, 0, 4, height); wooden_a_supports_paint_setup(6, 19, height, gTrackColours[SCHEME_SUPPORTS], NULL); break; diff --git a/src/ride/coaster/wooden_roller_coaster.c b/src/ride/coaster/wooden_roller_coaster.c index 42c7f6cecd..9a3eeea572 100644 --- a/src/ride/coaster/wooden_roller_coaster.c +++ b/src/ride/coaster/wooden_roller_coaster.c @@ -405,7 +405,7 @@ static uint32 wooden_rc_get_rails_colour() return gTrackColours[SCHEME_TRACK]; } -static void wooden_rc_track_paint( +static paint_struct * wooden_rc_track_paint( uint32 imageIdTrack, uint32 imageIdRails, uint8 direction, @@ -418,7 +418,7 @@ static void wooden_rc_track_paint( uint32 railsImageId = imageIdRails | wooden_rc_get_rails_colour(); sub_98197C_rotated(direction, imageId, x_offset, y_offset, bound_box_length_x, bound_box_length_y, bound_box_length_z, z_offset, bound_box_offset_x, bound_box_offset_y, bound_box_offset_z); - sub_98199C_rotated(direction, railsImageId, x_offset, y_offset, bound_box_length_x, bound_box_length_y, bound_box_length_z, z_offset, bound_box_offset_x, bound_box_offset_y, bound_box_offset_z); + return sub_98199C_rotated(direction, railsImageId, x_offset, y_offset, bound_box_length_x, bound_box_length_y, bound_box_length_z, z_offset, bound_box_offset_x, bound_box_offset_y, bound_box_offset_z); } static void wooden_rc_track_paint_bb(const sprite_bb_2 *bb, sint16 height) @@ -530,7 +530,7 @@ static void wooden_rc_track_60_deg_up(uint8 rideIndex, uint8 trackSequence, uint if (direction == 0 || direction == 3) { wooden_rc_track_paint(imageIds[direction][0], imageIds[direction][1], direction, 0, 0, 32, 25, 2, height, 0, 3, height); } else { - wooden_rc_track_paint(imageIds[direction][0], imageIds[direction][1], direction, 0, 0, 2, 24, 93, height, 28, 4, height - 16); + gWoodenSupportsPrependTo = wooden_rc_track_paint(imageIds[direction][0], imageIds[direction][1], direction, 0, 0, 2, 24, 93, height, 28, 4, height - 16); } wooden_a_supports_paint_setup(direction & 1, 21 + direction, height, gTrackColours[SCHEME_SUPPORTS], NULL); @@ -592,7 +592,7 @@ static void wooden_rc_track_25_deg_up_to_60_deg_up(uint8 rideIndex, uint8 trackS if (direction == 0 || direction == 3) { wooden_rc_track_paint(imageIds[direction][0], imageIds[direction][1], direction, 0, 0, 32, 25, 2, height, 0, 3, height); } else { - wooden_rc_track_paint(imageIds[direction][0], imageIds[direction][1], direction, 0, 0, 2, 24, 43, height, 28, 4, height + 2); + gWoodenSupportsPrependTo = wooden_rc_track_paint(imageIds[direction][0], imageIds[direction][1], direction, 0, 0, 2, 24, 43, height, 28, 4, height + 2); wooden_rc_track_paint(imageIds[direction][2], imageIds[direction][3], direction, 0, 0, 32, 2, 43, height, 0, 4, height); } wooden_a_supports_paint_setup(direction & 1, 13 + direction, height, gTrackColours[SCHEME_SUPPORTS], NULL); @@ -620,7 +620,7 @@ static void wooden_rc_track_60_deg_up_to_25_deg_up(uint8 rideIndex, uint8 trackS if (direction == 0 || direction == 3) { wooden_rc_track_paint(imageIds[direction][0], imageIds[direction][1], direction, 0, 0, 32, 25, 2, height, 0, 3, height); } else { - wooden_rc_track_paint(imageIds[direction][0], imageIds[direction][1], direction, 0, 0, 24, 1, 61, height, 4, 28, height - 16); + gWoodenSupportsPrependTo = wooden_rc_track_paint(imageIds[direction][0], imageIds[direction][1], direction, 0, 0, 24, 1, 61, height, 4, 28, height - 16); wooden_rc_track_paint(imageIds[direction][2], imageIds[direction][3], direction, 0, 0, 32, 2, 43, height, 0, 4, height); } wooden_a_supports_paint_setup(direction & 1, 17 + direction, height, gTrackColours[SCHEME_SUPPORTS], NULL); diff --git a/src/ride/coaster/wooden_wild_mouse.c b/src/ride/coaster/wooden_wild_mouse.c index 1dc0abfd93..e073d2724d 100644 --- a/src/ride/coaster/wooden_wild_mouse.c +++ b/src/ride/coaster/wooden_wild_mouse.c @@ -221,7 +221,7 @@ static void wooden_wild_mouse_track_60_deg_up(uint8 rideIndex, uint8 trackSequen if (direction == 0 || direction == 3) { sub_98197C_rotated(direction, imageId, 0, 2, 32, 25, 1, height, 0, 3, height); } else { - sub_98197C_rotated(direction, imageId, 0, 6, 2, 24, 93, height, 28, 4, height - 16); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, imageId, 0, 6, 2, 24, 93, height, 28, 4, height - 16); } wooden_a_supports_paint_setup(direction & 1, 21 + direction, height, gTrackColours[SCHEME_SUPPORTS], NULL); @@ -295,7 +295,7 @@ static void wooden_wild_mouse_track_25_deg_up_to_60_deg_up(uint8 rideIndex, uint sub_98197C_rotated(direction, imageId, 0, 2, 32, 25, 1, height, 0, 3, height); } else { imageId = imageIds[isChained][direction][0] | gTrackColours[SCHEME_TRACK]; - sub_98197C_rotated(direction, imageId, 0, 6, 2, 24, 43, height, 28, 4, height + 2); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, imageId, 0, 6, 2, 24, 43, height, 28, 4, height + 2); imageId = imageIds[isChained][direction][1] | gTrackColours[SCHEME_TRACK]; sub_98197C_rotated(direction, imageId, 0, 6, 32, 2, 43, height, 0, 4, height); } @@ -336,7 +336,7 @@ static void wooden_wild_mouse_track_60_deg_to_25_deg_up(uint8 rideIndex, uint8 t sub_98197C_rotated(direction, imageId, 0, 2, 32, 25, 1, height, 0, 3, height); } else { imageId = imageIds[isChained][direction][0] | gTrackColours[SCHEME_TRACK]; - sub_98197C_rotated(direction, imageId, 0, 6, 2, 24, 43, height, 28, 4, height + 2); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, imageId, 0, 6, 2, 24, 43, height, 28, 4, height + 2); imageId = imageIds[isChained][direction][1] | gTrackColours[SCHEME_TRACK]; sub_98197C_rotated(direction, imageId, 0, 6, 32, 2, 43, height, 0, 4, height); } diff --git a/src/ride/thrill/go_karts.c b/src/ride/thrill/go_karts.c index 0f8a1afba5..bae2fc8c70 100644 --- a/src/ride/thrill/go_karts.c +++ b/src/ride/thrill/go_karts.c @@ -171,10 +171,6 @@ static void paint_go_karts_track_25_deg_up(uint8 rideIndex, uint8 trackSequence, ps = sub_98197C(imageId, 0, 0, 28, 32, 1, height, 2, 0, height, get_current_rotation()); } - if (direction == 1 || direction == 2) { - gWoodenSupportsPrependTo = ps; - } - imageId = go_karts_track_pieces_25_deg_up[direction][1] | gTrackColours[SCHEME_TRACK]; if (direction == 0 || direction == 2) { sub_98197C(imageId, 0, 0, 32, 1, 11, height, 0, 29, height + 2, get_current_rotation()); @@ -182,6 +178,8 @@ static void paint_go_karts_track_25_deg_up(uint8 rideIndex, uint8 trackSequence, sub_98197C(imageId, 0, 0, 1, 32, 11, height, 29, 0, height + 2, get_current_rotation()); } + gWoodenSupportsPrependTo = ps; + switch (direction) { case 0: wooden_a_supports_paint_setup(0, 9, height, gTrackColours[SCHEME_SUPPORTS], NULL); @@ -218,10 +216,6 @@ static void paint_go_karts_track_flat_to_25_deg_up(uint8 rideIndex, uint8 trackS ps = sub_98197C(imageId, 0, 0, 28, 32, 1, height, 2, 0, height, get_current_rotation()); } - if (direction == 1 || direction == 2) { - gWoodenSupportsPrependTo = ps; - } - imageId = go_karts_track_pieces_flat_to_25_deg_up[direction][1] | gTrackColours[SCHEME_TRACK]; if (direction == 0 || direction == 2) { sub_98197C(imageId, 0, 0, 32, 1, 11, height, 0, 29, height + 2, get_current_rotation()); @@ -229,6 +223,8 @@ static void paint_go_karts_track_flat_to_25_deg_up(uint8 rideIndex, uint8 trackS sub_98197C(imageId, 0, 0, 1, 32, 11, height, 29, 0, height + 2, get_current_rotation()); } + gWoodenSupportsPrependTo = ps; + switch (direction) { case 0: wooden_a_supports_paint_setup(0, 1, height, gTrackColours[SCHEME_SUPPORTS], NULL); @@ -265,10 +261,6 @@ static void paint_go_karts_track_25_deg_up_to_flat(uint8 rideIndex, uint8 trackS ps = sub_98197C(imageId, 0, 0, 28, 32, 1, height, 2, 0, height, get_current_rotation()); } - if (direction == 1 || direction == 2) { - gWoodenSupportsPrependTo = ps; - } - imageId = go_karts_track_pieces_25_deg_up_to_flat[direction][1] | gTrackColours[SCHEME_TRACK]; if (direction == 0 || direction == 2) { sub_98197C(imageId, 0, 0, 32, 1, 11, height, 0, 29, height + 2, get_current_rotation()); @@ -276,6 +268,8 @@ static void paint_go_karts_track_25_deg_up_to_flat(uint8 rideIndex, uint8 trackS sub_98197C(imageId, 0, 0, 1, 32, 11, height, 29, 0, height + 2, get_current_rotation()); } + gWoodenSupportsPrependTo = ps; + switch (direction) { case 0: wooden_a_supports_paint_setup(0, 5, height, gTrackColours[SCHEME_SUPPORTS], NULL); diff --git a/src/ride/water/splash_boats.c b/src/ride/water/splash_boats.c index 9150466f8e..d496eeedce 100644 --- a/src/ride/water/splash_boats.c +++ b/src/ride/water/splash_boats.c @@ -254,7 +254,7 @@ static void paint_splash_boats_track_60_deg_up(uint8 rideIndex, uint8 trackSeque uint32 imageId = SplashBoats60DegUpImageId[direction] | gTrackColours[SCHEME_TRACK]; uint32 frontImageId = SplashBoats60DegUpFrontImageId[direction] | gTrackColours[SCHEME_TRACK]; - sub_98197C_rotated(direction, imageId, 0, 0, 32, 20, 2, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, imageId, 0, 0, 32, 20, 2, height, 0, 6, height); sub_98197C_rotated(direction, frontImageId, 0, 0, 32, 1, 98, height, 0, 27, height); wooden_a_supports_paint_setup((direction & 1), 21 + direction, height, gTrackColours[SCHEME_SUPPORTS], NULL); @@ -311,7 +311,7 @@ static void paint_splash_boats_track_25_deg_up_to_60_deg_up(uint8 rideIndex, uin uint32 imageId = SplashBoats25DegUpTo60DegUpImageId[direction] | gTrackColours[SCHEME_TRACK]; uint32 frontImageId = SplashBoats25DegUpTo60DegUpFrontImageId[direction] | gTrackColours[SCHEME_TRACK]; - sub_98197C_rotated(direction, imageId, 0, 0, 32, 20, 2, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, imageId, 0, 0, 32, 20, 2, height, 0, 6, height); sub_98197C_rotated(direction, frontImageId, 0, 0, 32, 1, 66, height, 0, 27, height); wooden_a_supports_paint_setup((direction & 1), 13 + direction, height, gTrackColours[SCHEME_SUPPORTS], NULL); @@ -330,7 +330,7 @@ static void paint_splash_boats_track_60_deg_up_to_25_deg_up(uint8 rideIndex, uin uint32 imageId = SplashBoats60DegUpTo25DegUpImageId[direction] | gTrackColours[SCHEME_TRACK]; uint32 frontImageId = SplashBoats60DegUpTo25DegUpFrontImageId[direction] | gTrackColours[SCHEME_TRACK]; - sub_98197C_rotated(direction, imageId, 0, 0, 32, 20, 2, height, 0, 6, height); + gWoodenSupportsPrependTo = sub_98197C_rotated(direction, imageId, 0, 0, 32, 20, 2, height, 0, 6, height); sub_98197C_rotated(direction, frontImageId, 0, 0, 32, 1, 66, height, 0, 27, height); wooden_a_supports_paint_setup((direction & 1), 17 + direction, height, gTrackColours[SCHEME_SUPPORTS], NULL); diff --git a/test/testpaint/FunctionCall.cpp b/test/testpaint/FunctionCall.cpp index b120f5b2f7..75e14021f7 100644 --- a/test/testpaint/FunctionCall.cpp +++ b/test/testpaint/FunctionCall.cpp @@ -16,6 +16,10 @@ #include "FunctionCall.hpp" +extern "C" { +#include "../../src/sprites.h" +} + enum SpriteGroup { SPRITEGROUP_NONE, @@ -62,6 +66,13 @@ bool FunctionCall::AssertsEquals(function_call expected, function_call actual) { if (expected.supports.height != actual.supports.height) return false; if (expected.supports.colour_flags != actual.supports.colour_flags) return false; + if (expected.supports.special == 14 || expected.supports.special == 15 || + expected.supports.special == 18 || expected.supports.special == 19 || + expected.supports.special == 22 || expected.supports.special == 23) + { + if (expected.supports.prepend_to != actual.supports.prepend_to) return false; + } + return true; } diff --git a/test/testpaint/FunctionCall.hpp b/test/testpaint/FunctionCall.hpp index 10c1c4d18c..9c3d3a62b1 100644 --- a/test/testpaint/FunctionCall.hpp +++ b/test/testpaint/FunctionCall.hpp @@ -45,6 +45,7 @@ typedef struct sint16 z_offset; rct_xyz16 bound_box_offset; uint32 rotation; + paint_struct output_struct; } paint; struct supports { @@ -53,6 +54,7 @@ typedef struct int special; int height; uint32 colour_flags; + sint32 prepend_to; } supports; } function_call; diff --git a/test/testpaint/PaintIntercept.cpp b/test/testpaint/PaintIntercept.cpp index 89c744156d..4fcc159c0c 100644 --- a/test/testpaint/PaintIntercept.cpp +++ b/test/testpaint/PaintIntercept.cpp @@ -16,17 +16,20 @@ #include "PaintIntercept.hpp" +#include "FunctionCall.hpp" extern "C" { #include "../../src/common.h" #include "../../src/rct2/hook.h" #include "../../src/interface/viewport.h" #include "../../src/paint/supports.h" +#include "../../src/sprites.h" } static bool _woodenSupports = false; static uint8 _callCount = 0; static function_call _calls[256] = {0}; +static paint_struct _paintStructs = {0}; namespace PaintIntercept { static uint8 InterceptWoodenASupports(registers *regs); @@ -72,14 +75,26 @@ namespace PaintIntercept { } bool PaintWoodenSupports(uint8 function, int supportType, int special, int height, uint32 imageColourFlags, bool *underground) { - function_call call = {0}; - call.function = function; - call.supports.type = supportType; - call.supports.special = special; - call.supports.height = height; - call.supports.colour_flags = imageColourFlags; + function_call * call = &_calls[_callCount]; + call->function = function; + call->supports.type = supportType; + call->supports.special = special; + call->supports.height = height; + call->supports.colour_flags = imageColourFlags; + + call->supports.prepend_to = SPR_NONE; + if (gWoodenSupportsPrependTo != nullptr) + { + for (int i = 0; i < _callCount; i++) + { + if (&_calls[i].paint.output_struct == gWoodenSupportsPrependTo) + { + call->supports.prepend_to = _calls[i].paint.image_id; + break; + } + } + } - _calls[_callCount] = call; _callCount++; return _woodenSupports; @@ -88,15 +103,14 @@ namespace PaintIntercept { bool PaintMetalSupports(uint8 function, int supportType, uint8 segment, int special, int height, uint32 imageColourFlags) { CheckSegmentSupportHeight(); - function_call call = {0}; - call.function = function; - call.supports.type = supportType; - call.supports.segment = segment; - call.supports.special = special; - call.supports.height = height; - call.supports.colour_flags = imageColourFlags; + function_call * call = &_calls[_callCount]; + call->function = function; + call->supports.type = supportType; + call->supports.segment = segment; + call->supports.special = special; + call->supports.height = height; + call->supports.colour_flags = imageColourFlags; - _calls[_callCount] = call; _callCount++; return false; @@ -109,18 +123,17 @@ namespace PaintIntercept { sint16 zOffset, uint32 rotation ) { - function_call call = _calls[_callCount]; - call.function = PAINT_98196C; - call.paint.image_id = imageID; - call.paint.offset = {xOffset, yOffset}; - call.paint.bound_box_length = {boundBoxLengthX, boundBoxLengthY, boundBoxLengthZ}; - call.paint.z_offset = zOffset; - call.paint.rotation = rotation; + function_call * call = &_calls[_callCount]; + call->function = PAINT_98196C; + call->paint.image_id = imageID; + call->paint.offset = {xOffset, yOffset}; + call->paint.bound_box_length = {boundBoxLengthX, boundBoxLengthY, boundBoxLengthZ}; + call->paint.z_offset = zOffset; + call->paint.rotation = rotation; - _calls[_callCount] = call; _callCount++; - return nullptr; + return &call->paint.output_struct; } static paint_struct *PaintFull( @@ -132,19 +145,18 @@ namespace PaintIntercept { sint16 boundBoxOffsetX, sint16 boundBoxOffsetY, sint16 boundBoxOffsetZ, uint32 rotation ) { - function_call call = _calls[_callCount]; - call.function = function; - call.paint.image_id = imageID; - call.paint.offset = {xOffset, yOffset}; - call.paint.bound_box_length = {boundBoxLengthX, boundBoxLengthY, boundBoxLengthZ}; - call.paint.bound_box_offset = {boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ}; - call.paint.z_offset = zOffset; - call.paint.rotation = rotation; + function_call * call = &_calls[_callCount]; + call->function = function; + call->paint.image_id = imageID; + call->paint.offset = {xOffset, yOffset}; + call->paint.bound_box_length = {boundBoxLengthX, boundBoxLengthY, boundBoxLengthZ}; + call->paint.bound_box_offset = {boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ}; + call->paint.z_offset = zOffset; + call->paint.rotation = rotation; - _calls[_callCount] = call; _callCount++; - return nullptr; + return &call->paint.output_struct; } void ClearCalls() { @@ -241,7 +253,7 @@ namespace PaintIntercept { } regs->ebp = (int) out; - regs->al = 1; + regs->al = 1; return 0; } diff --git a/test/testpaint/Printer.cpp b/test/testpaint/Printer.cpp index efdd5183da..80b35ce1c6 100644 --- a/test/testpaint/Printer.cpp +++ b/test/testpaint/Printer.cpp @@ -17,6 +17,11 @@ #include "Printer.hpp" #include "String.hpp" #include "../../src/core/Util.hpp" +#include "FunctionCall.hpp" + +extern "C" { +#include "../../src/sprites.h" +} namespace Printer { @@ -55,14 +60,36 @@ namespace Printer { std::string imageId = GetImageIdString(call.supports.colour_flags); assert(call.function < Util::CountOf(functionNames)); const char *functionName = functionNames[call.function]; + std::string out = ""; switch (call.function) { case SUPPORTS_WOOD_A: case SUPPORTS_WOOD_B: - return String::Format( + out += String::Format( "%s(%d, %d, %s, %s)", functionName, call.supports.type, call.supports.special, PrintHeightOffset(call.supports.height, baseHeight).c_str(), imageId.c_str() ); + if (call.supports.special == 14 || + call.supports.special == 15 || + call.supports.special == 18 || + call.supports.special == 19 || + call.supports.special == 22 || + call.supports.special == 23) + { + if (call.supports.prepend_to == SPR_NONE) + { + out += " [prependTo:SPR_NONE]"; + } else { + std::string prependId = GetImageIdString(call.supports.prepend_to); + out += String::Format(" [prependTo:%s]", prependId.c_str()); + } + } + else if (call.supports.prepend_to != SPR_NONE) + { + std::string prependId = GetImageIdString(call.supports.prepend_to); + out += String::Format(" [prependTo:%s]", prependId.c_str()); + } + return out; case SUPPORTS_METAL_A: case SUPPORTS_METAL_B: diff --git a/test/testpaint/TestTrack.cpp b/test/testpaint/TestTrack.cpp index 9aebea8742..ea44c7d99f 100644 --- a/test/testpaint/TestTrack.cpp +++ b/test/testpaint/TestTrack.cpp @@ -30,6 +30,7 @@ #include "VerticalTunnelCall.hpp" extern "C" { +#include "../../src/paint/supports.h" #include "../../src/ride/ride.h" #include "../../src/ride/track.h" #include "../../src/ride/track_data.h" @@ -347,6 +348,7 @@ static uint8 TestTrackElementPaintCalls(uint8 rideType, uint8 trackType, uint8 t PaintIntercept::ClearCalls(); TestPaint::ResetSupportHeights(); + gWoodenSupportsPrependTo = nullptr; CallOriginal(rideType, trackType, direction, trackSequence, height, &mapElement); @@ -357,6 +359,7 @@ static uint8 TestTrackElementPaintCalls(uint8 rideType, uint8 trackType, uint8 t PaintIntercept::ClearCalls(); testpaint_clear_ignore(); TestPaint::ResetSupportHeights(); + gWoodenSupportsPrependTo = nullptr; CallNew(rideType, trackType, direction, trackSequence, height, &mapElement);