From 12109993ae6d44c6d29b12bc7a82c5e053a82e88 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 18 Sep 2016 01:34:17 +0100 Subject: [PATCH 01/16] Implement station --- openrct2.vcxproj.user | 10 +-- src/ride/coaster/reverse_freefall_coaster.c | 74 +++++++++++++++++++++ src/ride/track_data.c | 2 +- src/ride/track_paint.h | 3 +- 4 files changed, 83 insertions(+), 6 deletions(-) diff --git a/openrct2.vcxproj.user b/openrct2.vcxproj.user index b782b153c4..708caa78af 100644 --- a/openrct2.vcxproj.user +++ b/openrct2.vcxproj.user @@ -7,22 +7,24 @@ $(TargetDir)\openrct2.exe WindowsLocalDebugger $(TargetDir) - - + "C:\Users\Ted\Documents\OpenRCT2\save\paint_reverse_freefall_rc.sv6" $(TargetDir) WindowsLocalDebugger $(TargetDir)\openrct2.exe - - + "C:\Users\Ted\Documents\OpenRCT2\save\paint_reverse_freefall_rc.sv6" $(TargetDir) WindowsLocalDebugger + + $(TargetDir) WindowsLocalDebugger + + \ No newline at end of file diff --git a/src/ride/coaster/reverse_freefall_coaster.c b/src/ride/coaster/reverse_freefall_coaster.c index 846fd9695d..2f7fc71717 100644 --- a/src/ride/coaster/reverse_freefall_coaster.c +++ b/src/ride/coaster/reverse_freefall_coaster.c @@ -13,3 +13,77 @@ * A full copy of the GNU General Public License can be found in licence.txt *****************************************************************************/ #pragma endregion + +#include "../../config.h" +#include "../../drawing/drawing.h" +#include "../../paint/supports.h" +#include "../../interface/viewport.h" +#include "../../paint/map_element/map_element.h" +#include "../../paint/paint.h" +#include "../../interface/window.h" +#include "../../localisation/localisation.h" +#include "../../sprites.h" +#include "../../world/map.h" +#include "../../world/sprite.h" +#include "../ride_data.h" +#include "../track_data.h" +#include "../track_paint.h" + +enum { + SPR_REVERSE_FREEFALL_RC_STATION_SW_NE = 22162, + SPR_REVERSE_FREEFALL_RC_STATION_NW_SE = 22163, +}; + +static const uint32 reverse_freefall_rc_track_pieces_station[4] = { + SPR_REVERSE_FREEFALL_RC_STATION_SW_NE, + SPR_REVERSE_FREEFALL_RC_STATION_NW_SE, + SPR_REVERSE_FREEFALL_RC_STATION_SW_NE, + SPR_REVERSE_FREEFALL_RC_STATION_NW_SE, +}; + +static void paint_reverse_freefall_rc_station_track(uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element *mapElement) +{ + rct_ride * ride = get_ride(rideIndex); + const rct_ride_entrance_definition * entranceStyle = &RideEntranceDefinitions[ride->entrance_style]; + uint32 imageId = entranceStyle->base_image_id; + if (!(gTrackColours[SCHEME_MISC] & (1 << 29))) { + imageId &= 0x7FFFF; + } + + if (direction == 0 || direction == 2) { + // height -= 2 (height - 2) + imageId = SPR_STATION_BASE_B_SW_NE | gTrackColours[SCHEME_MISC]; + sub_98197C(imageId, 0, 0, 32, 28, 1, height - 2, 0, 2, height, get_current_rotation()); + // height += 2 (height) + + imageId = reverse_freefall_rc_track_pieces_station[direction] | gTrackColours[SCHEME_TRACK]; + sub_98199C(imageId, 0, 0, 32, 20, 1, height, 0, 6, height, get_current_rotation()); + } else if (direction == 1 || direction == 3) { + // height -= 2 (height - 2) + imageId = SPR_STATION_BASE_B_NW_SE | gTrackColours[SCHEME_MISC]; + sub_98197C(imageId, 0, 0, 28, 32, 1, height - 2, 2, 0, height, get_current_rotation()); + // height += 2 (height) + + imageId = reverse_freefall_rc_track_pieces_station[direction] | gTrackColours[SCHEME_TRACK]; + sub_98199C(imageId, 0, 0, 20, 32, 1, height, 6, 0, height, get_current_rotation()); + } + + wooden_a_supports_paint_setup(0, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); + paint_util_push_tunnel_right(height, TUNNEL_6); + + track_paint_util_draw_station_platform(ride, direction, height, 5, mapElement); + + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 32, 0x20); +} + +TRACK_PAINT_FUNCTION get_track_paint_function_reverse_freefall_rc(int trackType, int direction) +{ + switch (trackType) { + case TRACK_ELEM_END_STATION: + case TRACK_ELEM_BEGIN_STATION: + case TRACK_ELEM_MIDDLE_STATION: + return paint_reverse_freefall_rc_station_track; + } + return NULL; +} diff --git a/src/ride/track_data.c b/src/ride/track_data.c index f33be6f310..6ca11c6d4d 100644 --- a/src/ride/track_data.c +++ b/src/ride/track_data.c @@ -6283,7 +6283,7 @@ const TRACK_PAINT_FUNCTION_GETTER RideTypeTrackPaintFunctions[91] = { get_track_paint_function_3d_cinema, // RIDE_TYPE_3D_CINEMA get_track_paint_function_topspin, // RIDE_TYPE_TOP_SPIN get_track_paint_function_space_rings, // RIDE_TYPE_SPACE_RINGS - 0, // RIDE_TYPE_REVERSE_FREEFALL_COASTER + get_track_paint_function_reverse_freefall_rc, // RIDE_TYPE_REVERSE_FREEFALL_COASTER get_track_paint_function_lift, // RIDE_TYPE_LIFT 0, // RIDE_TYPE_VERTICAL_DROP_ROLLER_COASTER get_track_paint_function_shop, // RIDE_TYPE_CASH_MACHINE diff --git a/src/ride/track_paint.h b/src/ride/track_paint.h index 40b9169278..cab56681ef 100644 --- a/src/ride/track_paint.h +++ b/src/ride/track_paint.h @@ -246,6 +246,7 @@ void track_paint_util_diag_tiles_paint(sint8 thickness, sint16 height, int direc typedef void (*TRACK_PAINT_FUNCTION)(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement); typedef TRACK_PAINT_FUNCTION (*TRACK_PAINT_FUNCTION_GETTER)(int trackType, int direction); +TRACK_PAINT_FUNCTION get_track_paint_function_junior_rc(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_monorail(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_boat_ride(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_car_ride(int trackType, int direction); @@ -264,6 +265,7 @@ TRACK_PAINT_FUNCTION get_track_paint_function_motionsimulator(int trackType, int TRACK_PAINT_FUNCTION get_track_paint_function_3d_cinema(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_topspin(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_space_rings(int trackType, int direction); +TRACK_PAINT_FUNCTION get_track_paint_function_reverse_freefall_rc(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_lift(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_shop(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_merry_go_round(int trackType, int direction); @@ -283,6 +285,5 @@ TRACK_PAINT_FUNCTION get_track_paint_function_magic_carpet(int trackType, int di TRACK_PAINT_FUNCTION get_track_paint_function_submarine_ride(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_river_rafts(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_enterprise(int trackType, int direction); -TRACK_PAINT_FUNCTION get_track_paint_function_junior_rc(int trackType, int direction); #endif From a62277c44f2f7e6320df1ef9cb732142025c8648 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 18 Sep 2016 01:45:30 +0100 Subject: [PATCH 02/16] Implement flat --- src/ride/coaster/reverse_freefall_coaster.c | 33 +++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/ride/coaster/reverse_freefall_coaster.c b/src/ride/coaster/reverse_freefall_coaster.c index 2f7fc71717..6b0dd83082 100644 --- a/src/ride/coaster/reverse_freefall_coaster.c +++ b/src/ride/coaster/reverse_freefall_coaster.c @@ -32,6 +32,8 @@ enum { SPR_REVERSE_FREEFALL_RC_STATION_SW_NE = 22162, SPR_REVERSE_FREEFALL_RC_STATION_NW_SE = 22163, + SPR_REVERSE_FREEFALL_RC_FLAT_SW_NE = 22164, + SPR_REVERSE_FREEFALL_RC_FLAT_NW_SE = 22165, }; static const uint32 reverse_freefall_rc_track_pieces_station[4] = { @@ -41,7 +43,30 @@ static const uint32 reverse_freefall_rc_track_pieces_station[4] = { SPR_REVERSE_FREEFALL_RC_STATION_NW_SE, }; -static void paint_reverse_freefall_rc_station_track(uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element *mapElement) +static void paint_reverse_freefall_rc_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element *mapElement) +{ + uint32 imageId = 0; + bool isChained = mapElement->type & (1 << 7); + + if (direction & 1) { + imageId = SPR_REVERSE_FREEFALL_RC_FLAT_NW_SE | gTrackColours[SCHEME_TRACK]; + sub_98197C(imageId, 0, 0, 20, 32, 1, height, 6, 0, height, get_current_rotation()); + paint_util_push_tunnel_right(height, TUNNEL_0); + } else { + imageId += SPR_REVERSE_FREEFALL_RC_FLAT_SW_NE | gTrackColours[SCHEME_TRACK]; + sub_98197C(imageId, 0, 0, 32, 20, 1, height, 0, 6, height, get_current_rotation()); + paint_util_push_tunnel_left(height, TUNNEL_0); + } + + if (track_paint_util_should_paint_supports(gPaintMapPosition)) { + wooden_a_supports_paint_setup((direction & 1) ? 1 : 0, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); + } + + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 32, 0x20); +} + +static void paint_reverse_freefall_rc_station(uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element *mapElement) { rct_ride * ride = get_ride(rideIndex); const rct_ride_entrance_definition * entranceStyle = &RideEntranceDefinitions[ride->entrance_style]; @@ -68,7 +93,7 @@ static void paint_reverse_freefall_rc_station_track(uint8 rideIndex, uint8 track sub_98199C(imageId, 0, 0, 20, 32, 1, height, 6, 0, height, get_current_rotation()); } - wooden_a_supports_paint_setup(0, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); + wooden_a_supports_paint_setup((direction & 1) ? 1 : 0, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); paint_util_push_tunnel_right(height, TUNNEL_6); track_paint_util_draw_station_platform(ride, direction, height, 5, mapElement); @@ -80,10 +105,12 @@ static void paint_reverse_freefall_rc_station_track(uint8 rideIndex, uint8 track TRACK_PAINT_FUNCTION get_track_paint_function_reverse_freefall_rc(int trackType, int direction) { switch (trackType) { + case TRACK_ELEM_FLAT: + return paint_reverse_freefall_rc_flat; case TRACK_ELEM_END_STATION: case TRACK_ELEM_BEGIN_STATION: case TRACK_ELEM_MIDDLE_STATION: - return paint_reverse_freefall_rc_station_track; + return paint_reverse_freefall_rc_station; } return NULL; } From f713eb201ab86b78f1811c25e16fee0b27ae1b75 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 18 Sep 2016 03:25:08 +0100 Subject: [PATCH 03/16] Implement slope --- src/ride/coaster/reverse_freefall_coaster.c | 225 +++++++++++++++++++- 1 file changed, 216 insertions(+), 9 deletions(-) diff --git a/src/ride/coaster/reverse_freefall_coaster.c b/src/ride/coaster/reverse_freefall_coaster.c index 6b0dd83082..fa95a0a46e 100644 --- a/src/ride/coaster/reverse_freefall_coaster.c +++ b/src/ride/coaster/reverse_freefall_coaster.c @@ -20,8 +20,6 @@ #include "../../interface/viewport.h" #include "../../paint/map_element/map_element.h" #include "../../paint/paint.h" -#include "../../interface/window.h" -#include "../../localisation/localisation.h" #include "../../sprites.h" #include "../../world/map.h" #include "../../world/sprite.h" @@ -34,6 +32,59 @@ enum { SPR_REVERSE_FREEFALL_RC_STATION_NW_SE = 22163, SPR_REVERSE_FREEFALL_RC_FLAT_SW_NE = 22164, SPR_REVERSE_FREEFALL_RC_FLAT_NW_SE = 22165, + + SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_0 = 22174, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_1 = 22175, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_2 = 22176, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_3 = 22177, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_4 = 22178, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_6 = 22179, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_0 = 22180, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_1 = 22181, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_2 = 22182, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_3 = 22183, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_4 = 22184, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_6 = 22185, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_0 = 22186, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_1 = 22187, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_2 = 22188, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_3 = 22189, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_4 = 22190, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_6 = 22191, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_0 = 22192, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_1 = 22193, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_2 = 22194, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_3 = 22195, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_4 = 22196, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_6 = 22197, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_0 = 22198, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_1 = 22199, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_2 = 22200, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_3 = 22201, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_4 = 22202, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_6 = 22203, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_5 = 22204, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_0 = 22205, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_1 = 22206, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_2 = 22207, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_3 = 22208, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_4 = 22209, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_6 = 22210, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_5 = 22211, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_0 = 22212, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_1 = 22213, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_2 = 22214, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_3 = 22215, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_4 = 22216, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_6 = 22217, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_5 = 22218, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_0 = 22219, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_1 = 22220, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_2 = 22221, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_3 = 22222, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_4 = 22223, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_6 = 22224, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_5 = 22225, }; static const uint32 reverse_freefall_rc_track_pieces_station[4] = { @@ -43,6 +94,96 @@ static const uint32 reverse_freefall_rc_track_pieces_station[4] = { SPR_REVERSE_FREEFALL_RC_STATION_NW_SE, }; +static const uint32 reverse_freefall_rc_track_pieces_slope[7][4] = { + { + SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_0, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_0, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_0, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_0, + }, + { + SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_1, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_1, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_1, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_1, + }, + { + SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_2, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_2, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_2, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_2, + }, + { + SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_3, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_3, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_3, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_3, + }, + { + SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_4, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_4, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_4, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_4, + }, + { + 0, + 0, + 0, + 0 + }, + { + SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_6, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_6, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_6, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_6, + }, +}; + +static const uint32 reverse_freefall_rc_track_pieces_slope_supports[7][4] = { + { + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_0, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_0, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_0, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_0, + }, + { + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_1, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_1, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_1, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_1, + }, + { + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_2, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_2, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_2, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_2, + }, + { + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_3, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_3, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_3, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_3, + }, + { + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_4, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_4, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_4, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_4, + }, + { + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_5, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_5, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_5, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_5, + }, + { + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_6, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_6, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_6, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_6, + }, +}; + static void paint_reverse_freefall_rc_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element *mapElement) { uint32 imageId = 0; @@ -58,10 +199,7 @@ static void paint_reverse_freefall_rc_flat(uint8 rideIndex, uint8 trackSequence, paint_util_push_tunnel_left(height, TUNNEL_0); } - if (track_paint_util_should_paint_supports(gPaintMapPosition)) { - wooden_a_supports_paint_setup((direction & 1) ? 1 : 0, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); - } - + wooden_a_supports_paint_setup((direction & 1) ? 1 : 0, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); paint_util_set_general_support_height(height + 32, 0x20); } @@ -83,6 +221,9 @@ static void paint_reverse_freefall_rc_station(uint8 rideIndex, uint8 trackSequen imageId = reverse_freefall_rc_track_pieces_station[direction] | gTrackColours[SCHEME_TRACK]; sub_98199C(imageId, 0, 0, 32, 20, 1, height, 0, 6, height, get_current_rotation()); + + wooden_a_supports_paint_setup((direction & 1) ? 1 : 0, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); + paint_util_push_tunnel_left(height, TUNNEL_6); } else if (direction == 1 || direction == 3) { // height -= 2 (height - 2) imageId = SPR_STATION_BASE_B_NW_SE | gTrackColours[SCHEME_MISC]; @@ -91,10 +232,10 @@ static void paint_reverse_freefall_rc_station(uint8 rideIndex, uint8 trackSequen imageId = reverse_freefall_rc_track_pieces_station[direction] | gTrackColours[SCHEME_TRACK]; sub_98199C(imageId, 0, 0, 20, 32, 1, height, 6, 0, height, get_current_rotation()); - } - wooden_a_supports_paint_setup((direction & 1) ? 1 : 0, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); - paint_util_push_tunnel_right(height, TUNNEL_6); + wooden_a_supports_paint_setup((direction & 1) ? 1 : 0, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); + paint_util_push_tunnel_right(height, TUNNEL_6); + } track_paint_util_draw_station_platform(ride, direction, height, 5, mapElement); @@ -102,6 +243,68 @@ static void paint_reverse_freefall_rc_station(uint8 rideIndex, uint8 trackSequen paint_util_set_general_support_height(height + 32, 0x20); } +static void paint_reverse_freefall_rc_slope(uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element *mapElement) +{ + static const sint32 supportHeights[] = { 48, 64, 128, 176, 208, 240, 240 }; + + uint32 supportsImageId = reverse_freefall_rc_track_pieces_slope_supports[trackSequence][direction] | gTrackColours[SCHEME_SUPPORTS]; + uint32 trackImageId = reverse_freefall_rc_track_pieces_slope[trackSequence][direction] | gTrackColours[SCHEME_TRACK]; + uint32 floorImageId; + + switch (trackSequence) { + case 0: + case 1: + case 2: + case 3: + case 4: + if (!(direction & 1)) { + sub_98197C(supportsImageId, 0, 0, 32, 20, 1, height, 0, 6, height, get_current_rotation()); + sub_98199C(trackImageId, 0, 0, 32, 20, 1, height, 0, 6, height, get_current_rotation()); + paint_util_push_tunnel_left(height, TUNNEL_6); + } else { + sub_98197C(supportsImageId, 0, 0, 20, 32, 1, height, 6, 0, height, get_current_rotation()); + sub_98199C(trackImageId, 0, 0, 20, 32, 1, height, 6, 0, height, get_current_rotation()); + paint_util_push_tunnel_right(height, TUNNEL_6); + } + wooden_a_supports_paint_setup(direction & 1, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + supportHeights[trackSequence], 0x20); + break; + case 5: + if (wooden_a_supports_paint_setup(direction & 1, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL)) { + if (direction & 1) { + floorImageId = SPR_FLOOR_PLANKS_90_DEG | gTrackColours[SCHEME_SUPPORTS]; + } else { + floorImageId = SPR_FLOOR_PLANKS | gTrackColours[SCHEME_SUPPORTS]; + } + sub_98197C(floorImageId, 0, 0, 26, 26, 126, height, 3, 3, height, get_current_rotation()); + sub_98199C(supportsImageId, 0, 0, 26, 26, 126, height, 3, 3, height, get_current_rotation()); + } else { + sub_98197C(supportsImageId, 0, 0, 26, 26, 126, height, 3, 3, height, get_current_rotation()); + } + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + supportHeights[trackSequence], 0x20); + break; + case 6: + if (!(direction & 1)) { + sub_98197C(supportsImageId, 0, 0, 5, 20, 79, height, 0, 6, height + 128, get_current_rotation()); + sub_98199C(trackImageId, 0, 0, 5, 20, 79, height, 0, 6, height + 128, get_current_rotation()); + } else { + sub_98197C(supportsImageId, 0, 0, 20, 5, 79, height, 6, 0, height, get_current_rotation()); + sub_98199C(trackImageId, 0, 0, 20, 5, 79, height, 6, 0, height, get_current_rotation()); + } + wooden_a_supports_paint_setup(direction & 1, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + supportHeights[trackSequence], 0x20); + break; + } +} + +static void paint_reverse_freefall_rc_vertical(uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element *mapElement) +{ + // 0x00768E04 +} + TRACK_PAINT_FUNCTION get_track_paint_function_reverse_freefall_rc(int trackType, int direction) { switch (trackType) { @@ -111,6 +314,10 @@ TRACK_PAINT_FUNCTION get_track_paint_function_reverse_freefall_rc(int trackType, case TRACK_ELEM_BEGIN_STATION: case TRACK_ELEM_MIDDLE_STATION: return paint_reverse_freefall_rc_station; + case TRACK_ELEM_REVERSE_WHOA_BELLY_SLOPE: + return paint_reverse_freefall_rc_slope; + case TRACK_ELEM_REVERSE_WHOA_BELLY_VERTICAL: + return paint_reverse_freefall_rc_vertical; } return NULL; } From 8e6871cf775677d8cb564d1ab625ade85c7741c0 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 18 Sep 2016 12:09:08 +0100 Subject: [PATCH 04/16] Correct name of SPR enum items --- src/ride/coaster/reverse_freefall_coaster.c | 208 ++++++++++---------- 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/src/ride/coaster/reverse_freefall_coaster.c b/src/ride/coaster/reverse_freefall_coaster.c index fa95a0a46e..5b1b8bf9e0 100644 --- a/src/ride/coaster/reverse_freefall_coaster.c +++ b/src/ride/coaster/reverse_freefall_coaster.c @@ -33,58 +33,58 @@ enum { SPR_REVERSE_FREEFALL_RC_FLAT_SW_NE = 22164, SPR_REVERSE_FREEFALL_RC_FLAT_NW_SE = 22165, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_0 = 22174, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_1 = 22175, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_2 = 22176, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_3 = 22177, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_4 = 22178, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_6 = 22179, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_0 = 22180, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_1 = 22181, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_2 = 22182, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_3 = 22183, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_4 = 22184, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_6 = 22185, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_0 = 22186, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_1 = 22187, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_2 = 22188, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_3 = 22189, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_4 = 22190, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_6 = 22191, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_0 = 22192, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_1 = 22193, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_2 = 22194, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_3 = 22195, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_4 = 22196, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_6 = 22197, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_0 = 22198, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_1 = 22199, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_2 = 22200, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_3 = 22201, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_4 = 22202, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_6 = 22203, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_5 = 22204, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_0 = 22205, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_1 = 22206, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_2 = 22207, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_3 = 22208, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_4 = 22209, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_6 = 22210, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_5 = 22211, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_0 = 22212, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_1 = 22213, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_2 = 22214, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_3 = 22215, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_4 = 22216, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_6 = 22217, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_5 = 22218, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_0 = 22219, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_1 = 22220, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_2 = 22221, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_3 = 22222, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_4 = 22223, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_6 = 22224, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_5 = 22225, + SPR_REVERSE_FREEFALL_RC_SLOPE_SW_NE_0 = 22174, + SPR_REVERSE_FREEFALL_RC_SLOPE_SW_NE_1 = 22175, + SPR_REVERSE_FREEFALL_RC_SLOPE_SW_NE_2 = 22176, + SPR_REVERSE_FREEFALL_RC_SLOPE_SW_NE_3 = 22177, + SPR_REVERSE_FREEFALL_RC_SLOPE_SW_NE_4 = 22178, + SPR_REVERSE_FREEFALL_RC_SLOPE_SW_NE_6 = 22179, + SPR_REVERSE_FREEFALL_RC_SLOPE_NW_SE_0 = 22180, + SPR_REVERSE_FREEFALL_RC_SLOPE_NW_SE_1 = 22181, + SPR_REVERSE_FREEFALL_RC_SLOPE_NW_SE_2 = 22182, + SPR_REVERSE_FREEFALL_RC_SLOPE_NW_SE_3 = 22183, + SPR_REVERSE_FREEFALL_RC_SLOPE_NW_SE_4 = 22184, + SPR_REVERSE_FREEFALL_RC_SLOPE_NW_SE_6 = 22185, + SPR_REVERSE_FREEFALL_RC_SLOPE_NE_SW_0 = 22186, + SPR_REVERSE_FREEFALL_RC_SLOPE_NE_SW_1 = 22187, + SPR_REVERSE_FREEFALL_RC_SLOPE_NE_SW_2 = 22188, + SPR_REVERSE_FREEFALL_RC_SLOPE_NE_SW_3 = 22189, + SPR_REVERSE_FREEFALL_RC_SLOPE_NE_SW_4 = 22190, + SPR_REVERSE_FREEFALL_RC_SLOPE_NE_SW_6 = 22191, + SPR_REVERSE_FREEFALL_RC_SLOPE_SE_NW_0 = 22192, + SPR_REVERSE_FREEFALL_RC_SLOPE_SE_NW_1 = 22193, + SPR_REVERSE_FREEFALL_RC_SLOPE_SE_NW_2 = 22194, + SPR_REVERSE_FREEFALL_RC_SLOPE_SE_NW_3 = 22195, + SPR_REVERSE_FREEFALL_RC_SLOPE_SE_NW_4 = 22196, + SPR_REVERSE_FREEFALL_RC_SLOPE_SE_NW_6 = 22197, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SW_NE_0 = 22198, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SW_NE_1 = 22199, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SW_NE_2 = 22200, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SW_NE_3 = 22201, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SW_NE_4 = 22202, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SW_NE_6 = 22203, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SW_NE_5 = 22204, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NW_SE_0 = 22205, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NW_SE_1 = 22206, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NW_SE_2 = 22207, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NW_SE_3 = 22208, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NW_SE_4 = 22209, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NW_SE_6 = 22210, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NW_SE_5 = 22211, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NE_SW_0 = 22212, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NE_SW_1 = 22213, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NE_SW_2 = 22214, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NE_SW_3 = 22215, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NE_SW_4 = 22216, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NE_SW_6 = 22217, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NE_SW_5 = 22218, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SE_NW_0 = 22219, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SE_NW_1 = 22220, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SE_NW_2 = 22221, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SE_NW_3 = 22222, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SE_NW_4 = 22223, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SE_NW_6 = 22224, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SE_NW_5 = 22225, }; static const uint32 reverse_freefall_rc_track_pieces_station[4] = { @@ -96,34 +96,34 @@ static const uint32 reverse_freefall_rc_track_pieces_station[4] = { static const uint32 reverse_freefall_rc_track_pieces_slope[7][4] = { { - SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_0, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_0, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_0, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_0, + SPR_REVERSE_FREEFALL_RC_SLOPE_SW_NE_0, + SPR_REVERSE_FREEFALL_RC_SLOPE_NW_SE_0, + SPR_REVERSE_FREEFALL_RC_SLOPE_NE_SW_0, + SPR_REVERSE_FREEFALL_RC_SLOPE_SE_NW_0, }, { - SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_1, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_1, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_1, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_1, + SPR_REVERSE_FREEFALL_RC_SLOPE_SW_NE_1, + SPR_REVERSE_FREEFALL_RC_SLOPE_NW_SE_1, + SPR_REVERSE_FREEFALL_RC_SLOPE_NE_SW_1, + SPR_REVERSE_FREEFALL_RC_SLOPE_SE_NW_1, }, { - SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_2, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_2, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_2, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_2, + SPR_REVERSE_FREEFALL_RC_SLOPE_SW_NE_2, + SPR_REVERSE_FREEFALL_RC_SLOPE_NW_SE_2, + SPR_REVERSE_FREEFALL_RC_SLOPE_NE_SW_2, + SPR_REVERSE_FREEFALL_RC_SLOPE_SE_NW_2, }, { - SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_3, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_3, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_3, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_3, + SPR_REVERSE_FREEFALL_RC_SLOPE_SW_NE_3, + SPR_REVERSE_FREEFALL_RC_SLOPE_NW_SE_3, + SPR_REVERSE_FREEFALL_RC_SLOPE_NE_SW_3, + SPR_REVERSE_FREEFALL_RC_SLOPE_SE_NW_3, }, { - SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_4, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_4, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_4, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_4, + SPR_REVERSE_FREEFALL_RC_SLOPE_SW_NE_4, + SPR_REVERSE_FREEFALL_RC_SLOPE_NW_SE_4, + SPR_REVERSE_FREEFALL_RC_SLOPE_NE_SW_4, + SPR_REVERSE_FREEFALL_RC_SLOPE_SE_NW_4, }, { 0, @@ -132,55 +132,55 @@ static const uint32 reverse_freefall_rc_track_pieces_slope[7][4] = { 0 }, { - SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE_6, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE_6, - SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW_6, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW_6, + SPR_REVERSE_FREEFALL_RC_SLOPE_SW_NE_6, + SPR_REVERSE_FREEFALL_RC_SLOPE_NW_SE_6, + SPR_REVERSE_FREEFALL_RC_SLOPE_NE_SW_6, + SPR_REVERSE_FREEFALL_RC_SLOPE_SE_NW_6, }, }; static const uint32 reverse_freefall_rc_track_pieces_slope_supports[7][4] = { { - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_0, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_0, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_0, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_0, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SW_NE_0, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NW_SE_0, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NE_SW_0, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SE_NW_0, }, { - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_1, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_1, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_1, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_1, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SW_NE_1, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NW_SE_1, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NE_SW_1, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SE_NW_1, }, { - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_2, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_2, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_2, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_2, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SW_NE_2, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NW_SE_2, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NE_SW_2, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SE_NW_2, }, { - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_3, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_3, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_3, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_3, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SW_NE_3, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NW_SE_3, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NE_SW_3, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SE_NW_3, }, { - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_4, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_4, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_4, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_4, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SW_NE_4, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NW_SE_4, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NE_SW_4, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SE_NW_4, }, { - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_5, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_5, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_5, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_5, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SW_NE_5, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NW_SE_5, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NE_SW_5, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SE_NW_5, }, { - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE_6, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE_6, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW_6, - SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW_6, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SW_NE_6, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NW_SE_6, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_NE_SW_6, + SPR_REVERSE_FREEFALL_RC_SLOPE_SUPPORTS_SE_NW_6, }, }; From 09cb01b28a8c4a204ea8bef69c731b2636d2edc1 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 18 Sep 2016 12:30:29 +0100 Subject: [PATCH 05/16] Implement vertical --- src/ride/coaster/reverse_freefall_coaster.c | 44 ++++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/ride/coaster/reverse_freefall_coaster.c b/src/ride/coaster/reverse_freefall_coaster.c index 5b1b8bf9e0..9bd0577464 100644 --- a/src/ride/coaster/reverse_freefall_coaster.c +++ b/src/ride/coaster/reverse_freefall_coaster.c @@ -32,7 +32,14 @@ enum { SPR_REVERSE_FREEFALL_RC_STATION_NW_SE = 22163, SPR_REVERSE_FREEFALL_RC_FLAT_SW_NE = 22164, SPR_REVERSE_FREEFALL_RC_FLAT_NW_SE = 22165, - + SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE = 22166, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE = 22167, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW = 22168, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW = 22169, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE = 22170, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE = 22171, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW = 22172, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW = 22173, SPR_REVERSE_FREEFALL_RC_SLOPE_SW_NE_0 = 22174, SPR_REVERSE_FREEFALL_RC_SLOPE_SW_NE_1 = 22175, SPR_REVERSE_FREEFALL_RC_SLOPE_SW_NE_2 = 22176, @@ -184,6 +191,20 @@ static const uint32 reverse_freefall_rc_track_pieces_slope_supports[7][4] = { }, }; +static const uint32 reverse_freefall_rc_track_pieces_vertical[4] = { + SPR_REVERSE_FREEFALL_RC_VERTICAL_SW_NE, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NW_SE, + SPR_REVERSE_FREEFALL_RC_VERTICAL_NE_SW, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SE_NW, +}; + +static const uint32 reverse_freefall_rc_track_pieces_vertical_supports[4] = { + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SW_NE, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NW_SE, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_NE_SW, + SPR_REVERSE_FREEFALL_RC_VERTICAL_SUPPORTS_SE_NW, +}; + static void paint_reverse_freefall_rc_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element *mapElement) { uint32 imageId = 0; @@ -302,7 +323,26 @@ static void paint_reverse_freefall_rc_slope(uint8 rideIndex, uint8 trackSequence static void paint_reverse_freefall_rc_vertical(uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element *mapElement) { - // 0x00768E04 + uint32 supportsImageId, trackImageId; + switch (trackSequence) { + case 0: + supportsImageId = reverse_freefall_rc_track_pieces_vertical_supports[direction] | gTrackColours[SCHEME_SUPPORTS]; + sub_98197C(supportsImageId, 0, 0, 26, 26, 79, height, 3, 3, height, get_current_rotation()); + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 80, 0x20); + break; + case 1: + trackImageId = reverse_freefall_rc_track_pieces_vertical[direction] | gTrackColours[SCHEME_TRACK]; + if (!(direction & 1)) { + sub_98197C(trackImageId, 0, 0, 2, 20, 79, height, 0, 6, height, get_current_rotation()); + } else { + sub_98197C(trackImageId, 0, 0, 20, 2, 79, height, 6, 0, height, get_current_rotation()); + } + paint_util_set_vertical_tunnel(height + 80); + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 80, 0x20); + break; + } } TRACK_PAINT_FUNCTION get_track_paint_function_reverse_freefall_rc(int trackType, int direction) From df761fb64d2c43b4291f651035e30ca2eaf27a61 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 18 Sep 2016 13:16:20 +0100 Subject: [PATCH 06/16] Fix bound boxes and draw order --- src/paint/paint.c | 30 +++++++++++++++++++ src/paint/paint.h | 3 ++ src/ride/coaster/reverse_freefall_coaster.c | 33 ++++++++++----------- 3 files changed, 49 insertions(+), 17 deletions(-) diff --git a/src/paint/paint.c b/src/paint/paint.c index b0652e590d..e05845e3b7 100644 --- a/src/paint/paint.c +++ b/src/paint/paint.c @@ -524,6 +524,36 @@ paint_struct * sub_98199C( return ps; } +paint_struct * sub_98197C_rotated( + uint8 direction, + uint32 image_id, + sint8 x_offset, sint8 y_offset, + sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, + sint16 z_offset, + sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z) +{ + if (direction & 1) { + return sub_98197C(image_id, x_offset, y_offset, bound_box_length_y, bound_box_length_x, bound_box_length_z, z_offset, bound_box_offset_y, bound_box_offset_x, bound_box_offset_z, get_current_rotation()); + } else { + return sub_98197C(image_id, 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, get_current_rotation()); + } +} + +paint_struct * sub_98199C_rotated( + uint8 direction, + uint32 image_id, + sint8 x_offset, sint8 y_offset, + sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, + sint16 z_offset, + sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z) +{ + if (direction & 1) { + return sub_98199C(image_id, x_offset, y_offset, bound_box_length_y, bound_box_length_x, bound_box_length_z, z_offset, bound_box_offset_y, bound_box_offset_x, bound_box_offset_z, get_current_rotation()); + } else { + return sub_98199C(image_id, 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, get_current_rotation()); + } +} + /** * rct2: 0x006881D0 * diff --git a/src/paint/paint.h b/src/paint/paint.h index 3c21afe306..1ece628da5 100644 --- a/src/paint/paint.h +++ b/src/paint/paint.h @@ -158,6 +158,9 @@ paint_struct * sub_98197C(uint32 image_id, sint8 x_offset, sint8 y_offset, sint1 paint_struct * sub_98198C(uint32 image_id, sint8 x_offset, sint8 y_offset, sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, sint16 z_offset, sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation); paint_struct * sub_98199C(uint32 image_id, sint8 x_offset, sint8 y_offset, sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, sint16 z_offset, sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z, uint32 rotation); +paint_struct * sub_98197C_rotated(uint8 direction, uint32 image_id, sint8 x_offset, sint8 y_offset, sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, sint16 z_offset, sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z); +paint_struct * sub_98199C_rotated(uint8 direction, uint32 image_id, sint8 x_offset, sint8 y_offset, sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, sint16 z_offset, sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z); + bool paint_attach_to_previous_attach(uint32 image_id, uint16 x, uint16 y); bool paint_attach_to_previous_ps(uint32 image_id, uint16 x, uint16 y); void sub_685EBC(money32 amount, rct_string_id string_id, sint16 y, sint16 z, sint8 y_offsets[], sint16 offset_x, uint32 rotation); diff --git a/src/ride/coaster/reverse_freefall_coaster.c b/src/ride/coaster/reverse_freefall_coaster.c index 9bd0577464..151c068f0f 100644 --- a/src/ride/coaster/reverse_freefall_coaster.c +++ b/src/ride/coaster/reverse_freefall_coaster.c @@ -14,7 +14,6 @@ *****************************************************************************/ #pragma endregion -#include "../../config.h" #include "../../drawing/drawing.h" #include "../../paint/supports.h" #include "../../interface/viewport.h" @@ -266,11 +265,12 @@ static void paint_reverse_freefall_rc_station(uint8 rideIndex, uint8 trackSequen static void paint_reverse_freefall_rc_slope(uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element *mapElement) { + static const sint8 bbHeights03[] = { 1, 6, 14, 37, 64 }; + static const sint8 bbHeights12[] = { 1, 6, 14, 27, 59 }; static const sint32 supportHeights[] = { 48, 64, 128, 176, 208, 240, 240 }; uint32 supportsImageId = reverse_freefall_rc_track_pieces_slope_supports[trackSequence][direction] | gTrackColours[SCHEME_SUPPORTS]; uint32 trackImageId = reverse_freefall_rc_track_pieces_slope[trackSequence][direction] | gTrackColours[SCHEME_TRACK]; - uint32 floorImageId; switch (trackSequence) { case 0: @@ -278,13 +278,15 @@ static void paint_reverse_freefall_rc_slope(uint8 rideIndex, uint8 trackSequence case 2: case 3: case 4: - if (!(direction & 1)) { - sub_98197C(supportsImageId, 0, 0, 32, 20, 1, height, 0, 6, height, get_current_rotation()); - sub_98199C(trackImageId, 0, 0, 32, 20, 1, height, 0, 6, height, get_current_rotation()); + if (direction == 0 || direction == 3) { + sint8 bbHeight = bbHeights03[trackSequence]; + sub_98197C_rotated(direction, supportsImageId, 0, 0, 32, 20, bbHeight, height, 0, 6, height); + sub_98199C_rotated(direction, trackImageId, 0, 0, 32, 20, bbHeight, height, 0, 6, height); paint_util_push_tunnel_left(height, TUNNEL_6); } else { - sub_98197C(supportsImageId, 0, 0, 20, 32, 1, height, 6, 0, height, get_current_rotation()); - sub_98199C(trackImageId, 0, 0, 20, 32, 1, height, 6, 0, height, get_current_rotation()); + sint8 bbHeight = bbHeights12[trackSequence]; + sub_98197C_rotated(direction, trackImageId, 0, 0, 32, 20, bbHeight, height, 0, 6, height); + sub_98199C_rotated(direction, supportsImageId, 0, 0, 32, 20, bbHeight, height, 0, 6, height); paint_util_push_tunnel_right(height, TUNNEL_6); } wooden_a_supports_paint_setup(direction & 1, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); @@ -293,6 +295,7 @@ static void paint_reverse_freefall_rc_slope(uint8 rideIndex, uint8 trackSequence break; case 5: if (wooden_a_supports_paint_setup(direction & 1, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL)) { + uint32 floorImageId; if (direction & 1) { floorImageId = SPR_FLOOR_PLANKS_90_DEG | gTrackColours[SCHEME_SUPPORTS]; } else { @@ -307,12 +310,12 @@ static void paint_reverse_freefall_rc_slope(uint8 rideIndex, uint8 trackSequence paint_util_set_general_support_height(height + supportHeights[trackSequence], 0x20); break; case 6: - if (!(direction & 1)) { - sub_98197C(supportsImageId, 0, 0, 5, 20, 79, height, 0, 6, height + 128, get_current_rotation()); - sub_98199C(trackImageId, 0, 0, 5, 20, 79, height, 0, 6, height + 128, get_current_rotation()); + if (direction == 0 || direction == 3) { + sub_98197C_rotated(direction, supportsImageId, 0, 0, 5, 20, 79, height, 0, 6, height + 128); + sub_98199C_rotated(direction, trackImageId, 0, 0, 5, 20, 79, height, 0, 6, height + 128); } else { - sub_98197C(supportsImageId, 0, 0, 20, 5, 79, height, 6, 0, height, get_current_rotation()); - sub_98199C(trackImageId, 0, 0, 20, 5, 79, height, 6, 0, height, get_current_rotation()); + sub_98197C_rotated(direction, trackImageId, 0, 0, 1, 20, 126, height, 27, 6, height); + sub_98199C_rotated(direction, supportsImageId, 0, 0, 1, 20, 126, height, 27, 6, height); } wooden_a_supports_paint_setup(direction & 1, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); @@ -333,11 +336,7 @@ static void paint_reverse_freefall_rc_vertical(uint8 rideIndex, uint8 trackSeque break; case 1: trackImageId = reverse_freefall_rc_track_pieces_vertical[direction] | gTrackColours[SCHEME_TRACK]; - if (!(direction & 1)) { - sub_98197C(trackImageId, 0, 0, 2, 20, 79, height, 0, 6, height, get_current_rotation()); - } else { - sub_98197C(trackImageId, 0, 0, 20, 2, 79, height, 6, 0, height, get_current_rotation()); - } + sub_98197C_rotated(direction, trackImageId, 0, 0, 2, 20, 79, height, 0, 6, height); paint_util_set_vertical_tunnel(height + 80); paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); paint_util_set_general_support_height(height + 80, 0x20); From 9fe4a9b41faab50fcd7bbc63085ce964e083fed4 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 18 Sep 2016 13:42:54 +0100 Subject: [PATCH 07/16] Add support for Windows coloured console --- test/testpaint/main.cpp | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/test/testpaint/main.cpp b/test/testpaint/main.cpp index 06191c9d3e..02c053284b 100644 --- a/test/testpaint/main.cpp +++ b/test/testpaint/main.cpp @@ -83,13 +83,46 @@ static const char* GetAnsiColorCode(CLIColour color) { }; } +#ifdef __WINDOWS__ + +static WORD GetCurrentWindowsConsoleAttribute(HANDLE hConsoleOutput) +{ + CONSOLE_SCREEN_BUFFER_INFO csbi; + GetConsoleScreenBufferInfo(hConsoleOutput, &csbi); + return csbi.wAttributes; +} + +static WORD GetWindowsConsoleAttribute(CLIColour color, WORD defaultAttr) +{ + switch (color) { + case RED: return FOREGROUND_RED; + case GREEN: return FOREGROUND_GREEN; + default: return defaultAttr; + }; +} + +#endif + static void ColouredPrintF(CLIColour colour, const char* fmt, ...) { va_list args; va_start(args, fmt); if(!ShouldUseColor()) { - vprintf(fmt, args); - va_end(args); + if (gTestColor) { +#ifdef __WINDOWS__ + HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); + WORD defaultAttr = GetCurrentWindowsConsoleAttribute(hStdOut); + SetConsoleTextAttribute(hStdOut, GetWindowsConsoleAttribute(colour, defaultAttr)); +#endif + vprintf(fmt, args); +#ifdef __WINDOWS__ + SetConsoleTextAttribute(hStdOut, defaultAttr); +#endif + va_end(args); + } else { + vprintf(fmt, args); + va_end(args); + } return; } From fd4103d8f5caa404ce5987b5c8f097030716d768 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 18 Sep 2016 13:43:43 +0100 Subject: [PATCH 08/16] Move sub_98197C_rotated and sub_98199C_rotated to helpers source Because paint.c can't be used by testpaint. --- openrct2.vcxproj | 1 + src/paint/paint.c | 30 -------------------- src/paint/paint_helpers.c | 48 ++++++++++++++++++++++++++++++++ test/testpaint/testpaint.vcxproj | 1 + 4 files changed, 50 insertions(+), 30 deletions(-) create mode 100644 src/paint/paint_helpers.c diff --git a/openrct2.vcxproj b/openrct2.vcxproj index 535e087afb..6bb34c1e25 100644 --- a/openrct2.vcxproj +++ b/openrct2.vcxproj @@ -151,6 +151,7 @@ + diff --git a/src/paint/paint.c b/src/paint/paint.c index e05845e3b7..b0652e590d 100644 --- a/src/paint/paint.c +++ b/src/paint/paint.c @@ -524,36 +524,6 @@ paint_struct * sub_98199C( return ps; } -paint_struct * sub_98197C_rotated( - uint8 direction, - uint32 image_id, - sint8 x_offset, sint8 y_offset, - sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, - sint16 z_offset, - sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z) -{ - if (direction & 1) { - return sub_98197C(image_id, x_offset, y_offset, bound_box_length_y, bound_box_length_x, bound_box_length_z, z_offset, bound_box_offset_y, bound_box_offset_x, bound_box_offset_z, get_current_rotation()); - } else { - return sub_98197C(image_id, 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, get_current_rotation()); - } -} - -paint_struct * sub_98199C_rotated( - uint8 direction, - uint32 image_id, - sint8 x_offset, sint8 y_offset, - sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, - sint16 z_offset, - sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z) -{ - if (direction & 1) { - return sub_98199C(image_id, x_offset, y_offset, bound_box_length_y, bound_box_length_x, bound_box_length_z, z_offset, bound_box_offset_y, bound_box_offset_x, bound_box_offset_z, get_current_rotation()); - } else { - return sub_98199C(image_id, 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, get_current_rotation()); - } -} - /** * rct2: 0x006881D0 * diff --git a/src/paint/paint_helpers.c b/src/paint/paint_helpers.c new file mode 100644 index 0000000000..15ca445c54 --- /dev/null +++ b/src/paint/paint_helpers.c @@ -0,0 +1,48 @@ +#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers +/***************************************************************************** + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * OpenRCT2 is the work of many authors, a full list can be found in contributors.md + * For more information, visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * A full copy of the GNU General Public License can be found in licence.txt + *****************************************************************************/ +#pragma endregion + +#include "../interface/viewport.h" +#include "paint.h" + +paint_struct * sub_98197C_rotated( + uint8 direction, + uint32 image_id, + sint8 x_offset, sint8 y_offset, + sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, + sint16 z_offset, + sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z) +{ + if (direction & 1) { + return sub_98197C(image_id, x_offset, y_offset, bound_box_length_y, bound_box_length_x, bound_box_length_z, z_offset, bound_box_offset_y, bound_box_offset_x, bound_box_offset_z, get_current_rotation()); + } else { + return sub_98197C(image_id, 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, get_current_rotation()); + } +} + +paint_struct * sub_98199C_rotated( + uint8 direction, + uint32 image_id, + sint8 x_offset, sint8 y_offset, + sint16 bound_box_length_x, sint16 bound_box_length_y, sint8 bound_box_length_z, + sint16 z_offset, + sint16 bound_box_offset_x, sint16 bound_box_offset_y, sint16 bound_box_offset_z) +{ + if (direction & 1) { + return sub_98199C(image_id, x_offset, y_offset, bound_box_length_y, bound_box_length_x, bound_box_length_z, z_offset, bound_box_offset_y, bound_box_offset_x, bound_box_offset_z, get_current_rotation()); + } else { + return sub_98199C(image_id, 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, get_current_rotation()); + } +} diff --git a/test/testpaint/testpaint.vcxproj b/test/testpaint/testpaint.vcxproj index 15fb0291ce..5cbf078e8b 100644 --- a/test/testpaint/testpaint.vcxproj +++ b/test/testpaint/testpaint.vcxproj @@ -86,6 +86,7 @@ + From d94d2e582007ba3f5b645a62551d1946506f2426 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 18 Sep 2016 13:43:54 +0100 Subject: [PATCH 09/16] Clean up paint_reverse_freefall_rc_flat --- src/ride/coaster/reverse_freefall_coaster.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ride/coaster/reverse_freefall_coaster.c b/src/ride/coaster/reverse_freefall_coaster.c index 151c068f0f..f6ab87d8fb 100644 --- a/src/ride/coaster/reverse_freefall_coaster.c +++ b/src/ride/coaster/reverse_freefall_coaster.c @@ -206,15 +206,12 @@ static const uint32 reverse_freefall_rc_track_pieces_vertical_supports[4] = { static void paint_reverse_freefall_rc_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element *mapElement) { - uint32 imageId = 0; - bool isChained = mapElement->type & (1 << 7); - if (direction & 1) { - imageId = SPR_REVERSE_FREEFALL_RC_FLAT_NW_SE | gTrackColours[SCHEME_TRACK]; + uint32 imageId = SPR_REVERSE_FREEFALL_RC_FLAT_NW_SE | gTrackColours[SCHEME_TRACK]; sub_98197C(imageId, 0, 0, 20, 32, 1, height, 6, 0, height, get_current_rotation()); paint_util_push_tunnel_right(height, TUNNEL_0); } else { - imageId += SPR_REVERSE_FREEFALL_RC_FLAT_SW_NE | gTrackColours[SCHEME_TRACK]; + uint32 imageId = SPR_REVERSE_FREEFALL_RC_FLAT_SW_NE | gTrackColours[SCHEME_TRACK]; sub_98197C(imageId, 0, 0, 32, 20, 1, height, 0, 6, height, get_current_rotation()); paint_util_push_tunnel_left(height, TUNNEL_0); } From 0c569e6b02b2010b31a4b93020a1433c7d20bcaf Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 18 Sep 2016 14:07:07 +0100 Subject: [PATCH 10/16] Add support for passing a single ride type to testpaint --- test/testpaint/main.cpp | 81 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/test/testpaint/main.cpp b/test/testpaint/main.cpp index 02c053284b..4a7150b13d 100644 --- a/test/testpaint/main.cpp +++ b/test/testpaint/main.cpp @@ -133,12 +133,71 @@ static void ColouredPrintF(CLIColour colour, const char* fmt, ...) { } #if defined(__WINDOWS__) + +#include + int main(int argc, char *argv[]); #define OPENRCT2_DLL_MODULE_NAME "openrct2.dll" static HMODULE _dllModule = NULL; +utf8 *utf8_write_codepoint(utf8 *dst, uint32 codepoint) +{ + if (codepoint <= 0x7F) { + dst[0] = (utf8)codepoint; + return dst + 1; + } else if (codepoint <= 0x7FF) { + dst[0] = 0xC0 | ((codepoint >> 6) & 0x1F); + dst[1] = 0x80 | (codepoint & 0x3F); + return dst + 2; + } else if (codepoint <= 0xFFFF) { + dst[0] = 0xE0 | ((codepoint >> 12) & 0x0F); + dst[1] = 0x80 | ((codepoint >> 6) & 0x3F); + dst[2] = 0x80 | (codepoint & 0x3F); + return dst + 3; + } else { + dst[0] = 0xF0 | ((codepoint >> 18) & 0x07); + dst[1] = 0x80 | ((codepoint >> 12) & 0x3F); + dst[2] = 0x80 | ((codepoint >> 6) & 0x3F); + dst[3] = 0x80 | (codepoint & 0x3F); + return dst + 4; + } +} + +utf8 *widechar_to_utf8(const wchar_t *src) +{ + utf8 *result = (utf8 *)malloc((wcslen(src) * 4) + 1); + utf8 *dst = result; + + for (; *src != 0; src++) { + dst = utf8_write_codepoint(dst, *src); + } + *dst++ = 0; + + size_t size = (size_t)(dst - result); + return (utf8 *)realloc(result, size); +} + +utf8 **windows_get_command_line_args(int *outNumArgs) +{ + int argc; + + // Get command line arguments as widechar + LPWSTR commandLine = GetCommandLineW(); + LPWSTR *argvW = CommandLineToArgvW(commandLine, &argc); + + // Convert to UTF-8 + utf8 **argvUtf8 = (utf8**)malloc(argc * sizeof(utf8*)); + for (int i = 0; i < argc; i++) { + argvUtf8[i] = widechar_to_utf8(argvW[i]); + } + LocalFree(argvW); + + *outNumArgs = argc; + return argvUtf8; +} + BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved) { _dllModule = (HMODULE)hModule; @@ -152,7 +211,16 @@ __declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInsta _dllModule = GetModuleHandleA(OPENRCT2_DLL_MODULE_NAME); } - int gExitCode = main(0, NULL); + int argc; + char ** argv = (char**)windows_get_command_line_args(&argc); + + int gExitCode = main(argc, argv); + + // Free argv + for (int i = 0; i < argc; i++) { + free(argv[i]); + } + free(argv); exit(gExitCode); return gExitCode; @@ -256,14 +324,25 @@ static bool openrct2_setup_rct2_segment() int main(int argc, char *argv[]) { std::vector testCases; + uint8 specificRideType = 0xFF; for (int i = 0; i < argc; ++i) { char *arg = argv[i]; if (strcmp(arg, "--gtest_color=no") == 0) { gTestColor = false; } + else if (strcmp(arg, "--ride-type") == 0) { + if (i + 1 < argc) { + i++; + specificRideType = atoi(argv[i]); + } + } } for (uint8 rideType = 0; rideType < 91; rideType++) { + if (specificRideType != 0xFF && rideType != specificRideType) { + continue; + } + if (!rideIsImplemented(rideType)) { continue; } From 21bb6c507dd2c6550b6a497b9f5459c727259e4d Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 18 Sep 2016 14:41:23 +0100 Subject: [PATCH 11/16] Fix bugs spotted by testpaint --- src/ride/coaster/reverse_freefall_coaster.c | 14 +++++++++----- test/testpaint/testpaint.vcxproj.user | 7 ++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/ride/coaster/reverse_freefall_coaster.c b/src/ride/coaster/reverse_freefall_coaster.c index f6ab87d8fb..1615d48ae2 100644 --- a/src/ride/coaster/reverse_freefall_coaster.c +++ b/src/ride/coaster/reverse_freefall_coaster.c @@ -209,11 +209,11 @@ static void paint_reverse_freefall_rc_flat(uint8 rideIndex, uint8 trackSequence, if (direction & 1) { uint32 imageId = SPR_REVERSE_FREEFALL_RC_FLAT_NW_SE | gTrackColours[SCHEME_TRACK]; sub_98197C(imageId, 0, 0, 20, 32, 1, height, 6, 0, height, get_current_rotation()); - paint_util_push_tunnel_right(height, TUNNEL_0); + paint_util_push_tunnel_right(height, TUNNEL_6); } else { uint32 imageId = SPR_REVERSE_FREEFALL_RC_FLAT_SW_NE | gTrackColours[SCHEME_TRACK]; sub_98197C(imageId, 0, 0, 32, 20, 1, height, 0, 6, height, get_current_rotation()); - paint_util_push_tunnel_left(height, TUNNEL_0); + paint_util_push_tunnel_left(height, TUNNEL_6); } wooden_a_supports_paint_setup((direction & 1) ? 1 : 0, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); @@ -282,8 +282,8 @@ static void paint_reverse_freefall_rc_slope(uint8 rideIndex, uint8 trackSequence paint_util_push_tunnel_left(height, TUNNEL_6); } else { sint8 bbHeight = bbHeights12[trackSequence]; - sub_98197C_rotated(direction, trackImageId, 0, 0, 32, 20, bbHeight, height, 0, 6, height); - sub_98199C_rotated(direction, supportsImageId, 0, 0, 32, 20, bbHeight, height, 0, 6, height); + sub_98197C_rotated(direction, supportsImageId, 0, 0, 32, 20, bbHeight, height, 0, 6, height); + sub_98199C_rotated(direction, trackImageId, 0, 0, 32, 20, bbHeight, height, 0, 6, height); paint_util_push_tunnel_right(height, TUNNEL_6); } wooden_a_supports_paint_setup(direction & 1, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); @@ -333,7 +333,11 @@ static void paint_reverse_freefall_rc_vertical(uint8 rideIndex, uint8 trackSeque break; case 1: trackImageId = reverse_freefall_rc_track_pieces_vertical[direction] | gTrackColours[SCHEME_TRACK]; - sub_98197C_rotated(direction, trackImageId, 0, 0, 2, 20, 79, height, 0, 6, height); + if (direction == 0 || direction == 3) { + sub_98197C_rotated(direction, trackImageId, 0, 0, 2, 20, 79, height, 0, 6, height); + } else { + sub_98197C_rotated(direction, trackImageId, 0, 0, 2, 20, 79, height, 30, 6, height); + } paint_util_set_vertical_tunnel(height + 80); paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); paint_util_set_general_support_height(height + 80, 0x20); diff --git a/test/testpaint/testpaint.vcxproj.user b/test/testpaint/testpaint.vcxproj.user index 2d0a6983e6..1bb4d146b6 100644 --- a/test/testpaint/testpaint.vcxproj.user +++ b/test/testpaint/testpaint.vcxproj.user @@ -4,8 +4,13 @@ $(TargetDir)\openrct2.exe $(TargetDir) WindowsLocalDebugger + --ride-type 4 - true + false + + + --ride-type 4 + WindowsLocalDebugger \ No newline at end of file From a4b75fd84a6c2b72d856a70d7ab6a9c79011cb65 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 18 Sep 2016 16:46:26 +0100 Subject: [PATCH 12/16] Allow test ignoring --- src/paint/paint.h | 14 ++++++ test/testpaint/intercept.c | 5 ++ test/testpaint/intercept_2.cpp | 70 +++++++++++++++++++++++++++ test/testpaint/testpaint.vcxproj | 4 +- test/testpaint/testpaint.vcxproj.user | 4 +- 5 files changed, 93 insertions(+), 4 deletions(-) diff --git a/src/paint/paint.h b/src/paint/paint.h index 1ece628da5..e12b7b0891 100644 --- a/src/paint/paint.h +++ b/src/paint/paint.h @@ -168,4 +168,18 @@ void sub_685EBC(money32 amount, rct_string_id string_id, sint16 y, sint16 z, sin void viewport_draw_money_effects(); void viewport_paint_setup(); +// TESTING +#ifdef __TESTPAINT__ + void testpaint_clear_ignore(); + void testpaint_ignore(uint8 direction, uint8 trackSequence); + void testpaint_ignore_all(); + bool testpaint_is_ignored(uint8 direction, uint8 trackSequence); + + #define TESTPAINT_IGNORE(direction, trackSequence) testpaint_ignore(direction, trackSequence) + #define TESTPAINT_IGNORE_ALL() testpaint_ignore_all() +#else + #define TESTPAINT_IGNORE(direction, trackSequence) + #define TESTPAINT_IGNORE_ALL() +#endif + #endif diff --git a/test/testpaint/intercept.c b/test/testpaint/intercept.c index 6a44c3423e..82bb8c4076 100644 --- a/test/testpaint/intercept.c +++ b/test/testpaint/intercept.c @@ -576,7 +576,12 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) callCount = 0; + testpaint_clear_ignore(); newPaintFunction(rideIndex, trackSequence, direction, height, &mapElement); + if (testpaint_is_ignored(direction, trackSequence)) { + sprintf(*error, "[ IGNORED ] [direction:%d trackSequence:%d]\n", direction, trackSequence); + continue; + } uint8 newCallCount = callCount; function_call newCalls[256]; diff --git a/test/testpaint/intercept_2.cpp b/test/testpaint/intercept_2.cpp index ce80ec6ed0..da48fd8ebf 100644 --- a/test/testpaint/intercept_2.cpp +++ b/test/testpaint/intercept_2.cpp @@ -397,8 +397,12 @@ namespace Intercept2 gSupportSegments[s].slope = 0xFF; } + testpaint_clear_ignore(); TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction); newPaintFunction(rideIndex, trackSequence, direction, height, &mapElement); + if (testpaint_is_ignored(direction, trackSequence)) { + continue; + } std::vector newCalls = getSegmentCalls(gSupportSegments, direction); @@ -432,8 +436,12 @@ namespace Intercept2 gSupport.height = 0; gSupport.slope = 0xFF; + testpaint_clear_ignore(); TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction); newPaintFunction(rideIndex, trackSequence, direction, height, &mapElement); + if (testpaint_is_ignored(direction, trackSequence)) { + continue; + } if (referenceGeneralSupportCall.height != -1) { if (gSupport.height != referenceGeneralSupportCall.height) { @@ -583,6 +591,7 @@ namespace Intercept2 gLeftTunnelCount = 0; gRightTunnelCount = 0; + testpaint_clear_ignore(); TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction); for (int offset = -8; offset <= 8; offset += 8) { @@ -757,8 +766,12 @@ namespace Intercept2 for (int direction = 0; direction < 4; direction++) { gVerticalTunnelHeight = 0; + testpaint_clear_ignore(); TRACK_PAINT_FUNCTION newPaintFunction = newPaintGetter(trackType, direction); newPaintFunction(rideIndex, trackSequence, direction, height, &mapElement); + if (testpaint_is_ignored(direction, trackSequence)) { + continue; + } if (gVerticalTunnelHeight != referenceHeight) { if (referenceHeight == 0) { @@ -795,6 +808,44 @@ namespace Intercept2 return true; } + struct IgnoredEntry + { + uint8 Direction; + uint8 TrackSequence; + }; + + static bool _ignoredAll; + static std::vector _ignoredEntries; + + static void testClearIgnore() + { + _ignoredAll = false; + _ignoredEntries.clear(); + } + + static void testIgnore(uint8 direction, uint8 trackSequence) + { + _ignoredEntries.push_back({ direction, trackSequence }); + } + + static void testIgnoreAll() + { + _ignoredAll = true; + } + + static bool testIsIgnored(uint8 direction, uint8 trackSequence) + { + if (_ignoredAll) return true; + for (const IgnoredEntry &entry : _ignoredEntries) + { + if (entry.Direction == direction && + entry.TrackSequence == trackSequence) + { + return true; + } + } + return false; + } } extern "C" @@ -814,4 +865,23 @@ extern "C" return Intercept2::testVerticalTunnels(rideType, trackType); } + void testpaint_clear_ignore() + { + Intercept2::testClearIgnore(); + } + + void testpaint_ignore(uint8 direction, uint8 trackSequence) + { + Intercept2::testIgnore(direction, trackSequence); + } + + void testpaint_ignore_all() + { + Intercept2::testIgnoreAll(); + } + + bool testpaint_is_ignored(uint8 direction, uint8 trackSequence) + { + return Intercept2::testIsIgnored(direction, trackSequence); + } } diff --git a/test/testpaint/testpaint.vcxproj b/test/testpaint/testpaint.vcxproj index 5cbf078e8b..aa2e3b925c 100644 --- a/test/testpaint/testpaint.vcxproj +++ b/test/testpaint/testpaint.vcxproj @@ -60,7 +60,7 @@ Level3 Disabled true - DEBUG;NO_VEHICLES;OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + __TESTPAINT__;DEBUG;NO_VEHICLES;OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) true 4200 @@ -72,7 +72,7 @@ true true true - NO_VEHICLES;OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + __TESTPAINT__;NO_VEHICLES;OPENGL_NO_LINK;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;CURL_STATICLIB;SDL_MAIN_HANDLED;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) true 4200 diff --git a/test/testpaint/testpaint.vcxproj.user b/test/testpaint/testpaint.vcxproj.user index 1bb4d146b6..33d0913624 100644 --- a/test/testpaint/testpaint.vcxproj.user +++ b/test/testpaint/testpaint.vcxproj.user @@ -4,13 +4,13 @@ $(TargetDir)\openrct2.exe $(TargetDir) WindowsLocalDebugger - --ride-type 4 + --ride-type 42 false - --ride-type 4 + --ride-type 42 WindowsLocalDebugger \ No newline at end of file From 2429cd84df6e62443cedaf04a935ce5d17957e40 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 18 Sep 2016 16:46:54 +0100 Subject: [PATCH 13/16] Fix remaining issues --- src/ride/coaster/reverse_freefall_coaster.c | 32 ++++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/ride/coaster/reverse_freefall_coaster.c b/src/ride/coaster/reverse_freefall_coaster.c index 1615d48ae2..fc4bb437e9 100644 --- a/src/ride/coaster/reverse_freefall_coaster.c +++ b/src/ride/coaster/reverse_freefall_coaster.c @@ -262,30 +262,40 @@ static void paint_reverse_freefall_rc_station(uint8 rideIndex, uint8 trackSequen static void paint_reverse_freefall_rc_slope(uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element *mapElement) { + TESTPAINT_IGNORE_ALL(); + static const sint8 bbHeights03[] = { 1, 6, 14, 37, 64 }; static const sint8 bbHeights12[] = { 1, 6, 14, 27, 59 }; static const sint32 supportHeights[] = { 48, 64, 128, 176, 208, 240, 240 }; + static const sint32 tunnelOffsets03[] = { 0, 0, 0, 16, 64 }; uint32 supportsImageId = reverse_freefall_rc_track_pieces_slope_supports[trackSequence][direction] | gTrackColours[SCHEME_SUPPORTS]; uint32 trackImageId = reverse_freefall_rc_track_pieces_slope[trackSequence][direction] | gTrackColours[SCHEME_TRACK]; - + sint8 bbHeight; + bool isDirection03 = (direction == 0 || direction == 3); switch (trackSequence) { case 0: case 1: case 2: case 3: case 4: - if (direction == 0 || direction == 3) { - sint8 bbHeight = bbHeights03[trackSequence]; + if (isDirection03) { + bbHeight = bbHeights03[trackSequence]; sub_98197C_rotated(direction, supportsImageId, 0, 0, 32, 20, bbHeight, height, 0, 6, height); sub_98199C_rotated(direction, trackImageId, 0, 0, 32, 20, bbHeight, height, 0, 6, height); - paint_util_push_tunnel_left(height, TUNNEL_6); + + sint32 tunnelOffset = tunnelOffsets03[trackSequence]; + if (direction & 1) { + paint_util_push_tunnel_right(height + tunnelOffset, TUNNEL_6); + } else { + paint_util_push_tunnel_left(height + tunnelOffset, TUNNEL_6); + } } else { - sint8 bbHeight = bbHeights12[trackSequence]; - sub_98197C_rotated(direction, supportsImageId, 0, 0, 32, 20, bbHeight, height, 0, 6, height); - sub_98199C_rotated(direction, trackImageId, 0, 0, 32, 20, bbHeight, height, 0, 6, height); - paint_util_push_tunnel_right(height, TUNNEL_6); + bbHeight = bbHeights12[trackSequence]; + sub_98197C_rotated(direction, trackImageId, 0, 0, 32, 20, bbHeight, height, 0, 6, height); + sub_98199C_rotated(direction, supportsImageId, 0, 0, 32, 20, bbHeight, height, 0, 6, height); } + wooden_a_supports_paint_setup(direction & 1, 0, height, gTrackColours[SCHEME_SUPPORTS], NULL); paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); paint_util_set_general_support_height(height + supportHeights[trackSequence], 0x20); @@ -299,15 +309,15 @@ static void paint_reverse_freefall_rc_slope(uint8 rideIndex, uint8 trackSequence floorImageId = SPR_FLOOR_PLANKS | gTrackColours[SCHEME_SUPPORTS]; } sub_98197C(floorImageId, 0, 0, 26, 26, 126, height, 3, 3, height, get_current_rotation()); - sub_98199C(supportsImageId, 0, 0, 26, 26, 126, height, 3, 3, height, get_current_rotation()); + sub_98199C_rotated(direction, supportsImageId, 0, 0, isDirection03 ? 26 : 18, 26, 126, height, isDirection03 ? 3 : 11, 3, height); } else { - sub_98197C(supportsImageId, 0, 0, 26, 26, 126, height, 3, 3, height, get_current_rotation()); + sub_98197C_rotated(direction, supportsImageId, 0, 0, isDirection03 ? 26 : 18, 26, 126, height, isDirection03 ? 3 : 11, 3, height); } paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); paint_util_set_general_support_height(height + supportHeights[trackSequence], 0x20); break; case 6: - if (direction == 0 || direction == 3) { + if (isDirection03) { sub_98197C_rotated(direction, supportsImageId, 0, 0, 5, 20, 79, height, 0, 6, height + 128); sub_98199C_rotated(direction, trackImageId, 0, 0, 5, 20, 79, height, 0, 6, height + 128); } else { From cdb85023a60d5986b8e396ff40c89c64b08e23c1 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 18 Sep 2016 16:50:51 +0100 Subject: [PATCH 14/16] Rollback .user files --- openrct2.vcxproj.user | 10 ++++------ test/testpaint/testpaint.vcxproj.user | 7 +------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/openrct2.vcxproj.user b/openrct2.vcxproj.user index 708caa78af..b782b153c4 100644 --- a/openrct2.vcxproj.user +++ b/openrct2.vcxproj.user @@ -7,24 +7,22 @@ $(TargetDir)\openrct2.exe WindowsLocalDebugger $(TargetDir) - "C:\Users\Ted\Documents\OpenRCT2\save\paint_reverse_freefall_rc.sv6" + + $(TargetDir) WindowsLocalDebugger $(TargetDir)\openrct2.exe - "C:\Users\Ted\Documents\OpenRCT2\save\paint_reverse_freefall_rc.sv6" + + $(TargetDir) WindowsLocalDebugger - - $(TargetDir) WindowsLocalDebugger - - \ No newline at end of file diff --git a/test/testpaint/testpaint.vcxproj.user b/test/testpaint/testpaint.vcxproj.user index 33d0913624..2d0a6983e6 100644 --- a/test/testpaint/testpaint.vcxproj.user +++ b/test/testpaint/testpaint.vcxproj.user @@ -4,13 +4,8 @@ $(TargetDir)\openrct2.exe $(TargetDir) WindowsLocalDebugger - --ride-type 42 - false - - - --ride-type 42 - WindowsLocalDebugger + true \ No newline at end of file From 741ce17e04b0639aa9952223d965e250d3a4853f Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 24 Sep 2016 12:04:10 +0200 Subject: [PATCH 15/16] Update Xcode project --- OpenRCT2.xcodeproj/project.pbxproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index b01faed27b..3a09330e71 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -20,6 +20,8 @@ 85060FD31D8C17CC00DFA2B3 /* track_data_old.c in Sources */ = {isa = PBXBuildFile; fileRef = 8594C05F1D885CF600235E93 /* track_data_old.c */; }; 8594C0601D885CF600235E93 /* track_data_old.c in Sources */ = {isa = PBXBuildFile; fileRef = 8594C05F1D885CF600235E93 /* track_data_old.c */; }; 85AFA2111D7DB83E00221B42 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85AFA20F1D7DB83E00221B42 /* main.cpp */; }; + 85B468FC1D96822F000F1DB5 /* paint_helpers.c in Sources */ = {isa = PBXBuildFile; fileRef = 85B468FB1D96822F000F1DB5 /* paint_helpers.c */; }; + 85B468FD1D96822F000F1DB5 /* paint_helpers.c in Sources */ = {isa = PBXBuildFile; fileRef = 85B468FB1D96822F000F1DB5 /* paint_helpers.c */; }; 85B5C0B01D81D912001B99A8 /* intercept_2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85B5C0AF1D81D912001B99A8 /* intercept_2.cpp */; }; C612A8991D64825300B634CA /* vehicle_data.c in Sources */ = {isa = PBXBuildFile; fileRef = C612A8971D64825300B634CA /* vehicle_data.c */; }; C61FB7201CF6180C004CE991 /* libssl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D45A38BA1CF3006400659A24 /* libssl.dylib */; }; @@ -497,6 +499,7 @@ 85AFA20F1D7DB83E00221B42 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 85AFA2101D7DB83E00221B42 /* intercept.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = intercept.h; sourceTree = ""; }; 85AFA2141D7DDFA100221B42 /* data.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = data.h; sourceTree = ""; }; + 85B468FB1D96822F000F1DB5 /* paint_helpers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = paint_helpers.c; sourceTree = ""; }; 85B5C0AF1D81D912001B99A8 /* intercept_2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = intercept_2.cpp; sourceTree = ""; }; C612A8971D64825300B634CA /* vehicle_data.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vehicle_data.c; sourceTree = ""; }; C612A8981D64825300B634CA /* vehicle_data.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vehicle_data.h; sourceTree = ""; }; @@ -1193,6 +1196,7 @@ children = ( C686F8971CDBC37E009F9BFC /* map_element */, C686F8A41CDBC37E009F9BFC /* sprite */, + 85B468FB1D96822F000F1DB5 /* paint_helpers.c */, C686F8A21CDBC37E009F9BFC /* paint.c */, C686F8AA1CDBC37E009F9BFC /* supports.c */, C686F8A31CDBC37E009F9BFC /* paint.h */, @@ -2446,6 +2450,7 @@ C64FDAA41D6D9A2100F259B9 /* minature_railway.c in Sources */, C64FDAA51D6D9A2100F259B9 /* monorail.c in Sources */, C64FDAA61D6D9A2100F259B9 /* suspended_monorail.c in Sources */, + 85B468FD1D96822F000F1DB5 /* paint_helpers.c in Sources */, C64FDAA71D6D9A2100F259B9 /* boat_ride.c in Sources */, C64FDAA81D6D9A2100F259B9 /* dingy_slide.c in Sources */, C64FDAA91D6D9A2100F259B9 /* log_flume.c in Sources */, @@ -2569,6 +2574,7 @@ C686F91C1CDBC3B7009F9BFC /* mini_suspended_coaster.c in Sources */, D44271FA1CC81B3200D84D28 /* RootCommands.cpp in Sources */, D442726B1CC81B3200D84D28 /* map.c in Sources */, + 85B468FC1D96822F000F1DB5 /* paint_helpers.c in Sources */, D464FEE71D31A6AA00CBABAC /* FootpathItemObject.cpp in Sources */, D442721E1CC81B3200D84D28 /* Theme.cpp in Sources */, C686F9271CDBC3B7009F9BFC /* virginia_reel.c in Sources */, @@ -2801,6 +2807,7 @@ "DEBUG=1", "$(inherited)", "NO_VEHICLES=1", + __TESTPAINT__, ); GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; @@ -2854,6 +2861,7 @@ OPENGL_NO_LINK, "OPENRCT2_BUILD_INFO_HEADER=\"\\\"$(DERIVED_FILE_DIR)/gitversion.h\\\"\"", "NO_VEHICLES=1", + __TESTPAINT__, ); GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; From 0070f0d05751eeb292d282677c8aa830b110bac4 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sat, 24 Sep 2016 11:54:45 +0100 Subject: [PATCH 16/16] Add listing of ride types, inc. status in testpaint --- test/testpaint/main.cpp | 83 ++++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 26 deletions(-) diff --git a/test/testpaint/main.cpp b/test/testpaint/main.cpp index 4a7150b13d..071f61bcc2 100644 --- a/test/testpaint/main.cpp +++ b/test/testpaint/main.cpp @@ -39,6 +39,7 @@ typedef struct { } TestCase; enum CLIColour { + DEFAULT, RED, GREEN, }; @@ -53,9 +54,16 @@ static bool CStringEquals(const char *lhs, const char *rhs) { return strcmp(lhs, rhs) == 0; } -static bool ShouldUseColor() { - if (gTestColor == false) { - return false; +enum COLOUR_METHOD { + COLOUR_METHOD_NONE, + COLOUR_METHOD_ANSI, + COLOUR_METHOD_WINDOWS, +}; + +static COLOUR_METHOD GetColourMethod() +{ + if (!gTestColor) { + return COLOUR_METHOD_NONE; } const char* const term = getenv("TERM"); @@ -72,7 +80,15 @@ static bool ShouldUseColor() { CStringEquals(term, "linux") || CStringEquals(term, "cygwin"); - return term_supports_color; + if (term_supports_color) { + return COLOUR_METHOD_ANSI; + } + +#ifdef __WINDOWS__ + return COLOUR_METHOD_WINDOWS; +#else + return COLOUR_METHOD_NONE; +#endif } static const char* GetAnsiColorCode(CLIColour color) { @@ -103,32 +119,28 @@ static WORD GetWindowsConsoleAttribute(CLIColour color, WORD defaultAttr) #endif -static void ColouredPrintF(CLIColour colour, const char* fmt, ...) { +static void ColouredPrintF(CLIColour colour, const char* fmt, ...) +{ va_list args; va_start(args, fmt); - if(!ShouldUseColor()) { - if (gTestColor) { -#ifdef __WINDOWS__ - HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); - WORD defaultAttr = GetCurrentWindowsConsoleAttribute(hStdOut); - SetConsoleTextAttribute(hStdOut, GetWindowsConsoleAttribute(colour, defaultAttr)); -#endif - vprintf(fmt, args); -#ifdef __WINDOWS__ - SetConsoleTextAttribute(hStdOut, defaultAttr); -#endif - va_end(args); - } else { - vprintf(fmt, args); - va_end(args); - } - return; - } + COLOUR_METHOD colourMethod = GetColourMethod(); - printf("\033[0;3%sm", GetAnsiColorCode(colour)); - vprintf(fmt, args); - printf("\033[m"); + if (colour == CLIColour::DEFAULT || colourMethod == COLOUR_METHOD_NONE) { + vprintf(fmt, args); + } else if (colourMethod == COLOUR_METHOD_ANSI) { + printf("\033[0;3%sm", GetAnsiColorCode(colour)); + vprintf(fmt, args); + printf("\033[m"); + } else if (colourMethod == COLOUR_METHOD_WINDOWS) { +#ifdef __WINDOWS__ + HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); + WORD defaultAttr = GetCurrentWindowsConsoleAttribute(hStdOut); + SetConsoleTextAttribute(hStdOut, GetWindowsConsoleAttribute(colour, defaultAttr)); + vprintf(fmt, args); + SetConsoleTextAttribute(hStdOut, defaultAttr); +#endif + } va_end(args); } @@ -321,6 +333,22 @@ static bool openrct2_setup_rct2_segment() return true; } +void PrintRideTypes() +{ + for (uint8 rideType = 0; rideType < 91; rideType++) { + CLIColour colour = CLIColour::DEFAULT; + bool implemented = rideIsImplemented(rideType); + const char * rideName = RideNames[rideType]; + const char * status = ""; + if (implemented) { + status = " [IMPLEMENTED]"; + colour = CLIColour::GREEN; + } + + ColouredPrintF(colour, "%2d: %-30s%s\n", rideType, rideName, status); + } +} + int main(int argc, char *argv[]) { std::vector testCases; @@ -334,6 +362,9 @@ int main(int argc, char *argv[]) { if (i + 1 < argc) { i++; specificRideType = atoi(argv[i]); + } else { + PrintRideTypes(); + return 2; } } }