From 1b65acc0fb089e23ac5e8a2f8f89a30448e35fd2 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sun, 9 Oct 2016 21:13:34 +0100 Subject: [PATCH] Fix corkscrew roller coaster painting --- src/ride/coaster/corkscrew_roller_coaster.c | 33 +++++++++++++++++---- src/ride/track_paint.c | 33 ++++++++++++--------- src/ride/track_paint.h | 1 + test/testpaint/intercept.c | 2 +- 4 files changed, 48 insertions(+), 21 deletions(-) diff --git a/src/ride/coaster/corkscrew_roller_coaster.c b/src/ride/coaster/corkscrew_roller_coaster.c index 686d414727..b4b13c7931 100644 --- a/src/ride/coaster/corkscrew_roller_coaster.c +++ b/src/ride/coaster/corkscrew_roller_coaster.c @@ -66,6 +66,28 @@ static void corkscrew_rc_track_flat(uint8 rideIndex, uint8 trackSequence, uint8 paint_util_set_general_support_height(height + 32, 0x20); } +static void corkscrew_rc_track_station(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + static const uint32 imageIds[4][3] = { + { 16236, 16232, SPR_STATION_BASE_A_SW_NE }, + { 16237, 16233, SPR_STATION_BASE_A_NW_SE }, + { 16236, 16232, SPR_STATION_BASE_A_SW_NE }, + { 16237, 16233, SPR_STATION_BASE_A_NW_SE }, + }; + + if (mapElement->properties.track.type == TRACK_ELEM_END_STATION) { + sub_98197C_rotated(direction, imageIds[direction][1] | gTrackColours[SCHEME_TRACK], 0, 0, 32, 20, 1, height, 0, 6, height + 3); + } else { + sub_98197C_rotated(direction, imageIds[direction][0] | gTrackColours[SCHEME_TRACK], 0, 0, 32, 20, 1, height, 0, 6, height + 3); + } + sub_98196C_rotated(direction, imageIds[direction][2] | gTrackColours[SCHEME_MISC], 0, 0, 32, 32, 1, height); + track_paint_util_draw_station_metal_supports_2(direction, height, gTrackColours[SCHEME_SUPPORTS], 0); + track_paint_util_draw_station_2(rideIndex, trackSequence, direction, height, mapElement, 9, 11); + paint_util_push_tunnel_rotated(direction, height, TUNNEL_6); + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 32, 0x20); +} + static void corkscrew_rc_track_25_deg_up(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { if (track_element_is_lift_hill(mapElement)) { @@ -3160,32 +3182,27 @@ static void corkscrew_rc_track_on_ride_photo(uint8 rideIndex, uint8 trackSequenc metal_a_supports_paint_setup(0, 5, 0, height, gTrackColours[SCHEME_SUPPORTS]); metal_a_supports_paint_setup(0, 8, 0, height, gTrackColours[SCHEME_SUPPORTS]); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 16224, 0, 0, 32, 20, 0, height, 0, 6, height + 3); - sub_98196C_rotated(direction, gTrackColours[SCHEME_MISC] | 25623, 26, 0, 1, 1, 19, height + 3); break; case 1: sub_98196C_rotated(direction, 0x20000000 | 22432, 0, 0, 32, 32, 1, height); metal_a_supports_paint_setup(0, 6, 0, height, gTrackColours[SCHEME_SUPPORTS]); metal_a_supports_paint_setup(0, 7, 0, height, gTrackColours[SCHEME_SUPPORTS]); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 16225, 0, 0, 32, 20, 0, height, 0, 6, height + 3); - sub_98196C_rotated(direction, gTrackColours[SCHEME_MISC] | 25624, 6, 0, 1, 1, 19, height + 3); break; case 2: sub_98196C_rotated(direction, 0x20000000 | 22432, 0, 0, 32, 32, 1, height); metal_a_supports_paint_setup(0, 5, 0, height, gTrackColours[SCHEME_SUPPORTS]); metal_a_supports_paint_setup(0, 8, 0, height, gTrackColours[SCHEME_SUPPORTS]); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 16224, 0, 0, 32, 20, 0, height, 0, 6, height + 3); - sub_98196C_rotated(direction, gTrackColours[SCHEME_MISC] | 25625, 6, 0, 1, 1, 19, height + 3); break; case 3: sub_98196C_rotated(direction, 0x20000000 | 22432, 0, 0, 32, 32, 1, height); metal_a_supports_paint_setup(0, 6, 0, height, gTrackColours[SCHEME_SUPPORTS]); metal_a_supports_paint_setup(0, 7, 0, height, gTrackColours[SCHEME_SUPPORTS]); sub_98197C_rotated(direction, gTrackColours[SCHEME_TRACK] | 16225, 0, 0, 32, 20, 0, height, 0, 6, height + 3); - sub_98196C_rotated(direction, gTrackColours[SCHEME_MISC] | 25626, 26, 0, 1, 1, 19, height + 3); break; } - sub_98196C_rotated(direction, 0x00000000, 0, 0, 0, 0, 0, height - 48); - sub_98196C_rotated(direction, 0x00000000, 0, 0, 0, 0, 0, height - 48); + track_paint_util_onride_photo_paint(direction, height + 3, mapElement); paint_util_push_tunnel_rotated(direction, height, TUNNEL_0); paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); paint_util_set_general_support_height(height + 48, 0x20); @@ -5772,6 +5789,10 @@ TRACK_PAINT_FUNCTION get_track_paint_function_corkscrew_rc(int trackType, int di switch (trackType) { case TRACK_ELEM_FLAT: return corkscrew_rc_track_flat; + case TRACK_ELEM_END_STATION: + case TRACK_ELEM_BEGIN_STATION: + case TRACK_ELEM_MIDDLE_STATION: + return corkscrew_rc_track_station; case TRACK_ELEM_25_DEG_UP: return corkscrew_rc_track_25_deg_up; case TRACK_ELEM_60_DEG_UP: diff --git a/src/ride/track_paint.c b/src/ride/track_paint.c index 598f277829..6a9439f1bd 100644 --- a/src/ride/track_paint.c +++ b/src/ride/track_paint.c @@ -286,6 +286,11 @@ bool track_paint_util_should_paint_supports(rct_xy16 position) } void track_paint_util_draw_station(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + track_paint_util_draw_station_2(rideIndex, trackSequence, direction, height, mapElement, 5, 7); +} + +void track_paint_util_draw_station_2(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement, int fenceOffsetA, int fenceOffsetB) { rct_xy16 position = {gPaintMapPosition.x, gPaintMapPosition.y}; rct_ride * ride = get_ride(rideIndex); @@ -310,7 +315,7 @@ void track_paint_util_draw_station(uint8 rideIndex, uint8 trackSequence, uint8 d } else { imageId = (hasFence ? SPR_STATION_PLATFORM_FENCED_SW_NE : SPR_STATION_PLATFORM_SW_NE) | gTrackColours[SCHEME_SUPPORTS]; } - sub_98196C(imageId, 0, 0, 32, 8, 1, height + 5, get_current_rotation()); + sub_98196C(imageId, 0, 0, 32, 8, 1, height + fenceOffsetA, get_current_rotation()); //height -= 5 (height) track_paint_util_draw_station_covers(EDGE_NW, hasFence, entranceStyle, direction, height); //height += 5 (height + 5) @@ -322,7 +327,7 @@ void track_paint_util_draw_station(uint8 rideIndex, uint8 trackSequence, uint8 d } else { imageId = SPR_STATION_PLATFORM_SW_NE | gTrackColours[SCHEME_SUPPORTS]; } - sub_98196C(imageId, 0, 24, 32, 8, 1, height + 5, get_current_rotation()); + sub_98196C(imageId, 0, 24, 32, 8, 1, height + fenceOffsetA, get_current_rotation()); //height += 2 (height + 7) hasFence = track_paint_util_has_fence(EDGE_SE, position, mapElement, ride, get_current_rotation()); @@ -334,15 +339,15 @@ void track_paint_util_draw_station(uint8 rideIndex, uint8 trackSequence, uint8 d } else { imageId = SPR_STATION_FENCE_SW_NE | gTrackColours[SCHEME_SUPPORTS]; } - sub_98196C(imageId, 0, 31, 32, 1, 7, height + 7, get_current_rotation()); + sub_98196C(imageId, 0, 31, 32, 1, 7, height + fenceOffsetB, get_current_rotation()); } else if (mapElement->properties.track.type == TRACK_ELEM_BEGIN_STATION && direction == 0) { // Addition: draw only small fence if there is an entrance/exit at the beginning imageId = SPR_STATION_FENCE_SMALL_NW_SE | gTrackColours[SCHEME_SUPPORTS]; - sub_98196C(imageId, 31, 23, 1, 8, 7, height + 7, get_current_rotation()); + sub_98196C(imageId, 31, 23, 1, 8, 7, height + fenceOffsetB, get_current_rotation()); } else if (mapElement->properties.track.type == TRACK_ELEM_END_STATION && direction == 2) { // Addition: draw only small fence if there is an entrance/exit at the end imageId = SPR_STATION_LIGHT_BACK_NE_SW | gTrackColours[SCHEME_SUPPORTS]; - sub_98196C(imageId, 31, 23, 1, 8, 7, height + 7, get_current_rotation()); + sub_98196C(imageId, 31, 23, 1, 8, 7, height + fenceOffsetB, get_current_rotation()); } //height -= 7 (height) track_paint_util_draw_station_covers(EDGE_SE, hasFence, entranceStyle, direction, height); @@ -350,10 +355,10 @@ void track_paint_util_draw_station(uint8 rideIndex, uint8 trackSequence, uint8 d if (mapElement->properties.track.type == TRACK_ELEM_BEGIN_STATION && direction == 0) { imageId = SPR_STATION_FENCE_SMALL_NW_SE | gTrackColours[SCHEME_SUPPORTS]; - sub_98196C(imageId, 31, 0, 1, 8, 7, height + 7, get_current_rotation()); + sub_98196C(imageId, 31, 0, 1, 8, 7, height + fenceOffsetB, get_current_rotation()); } else if (mapElement->properties.track.type == TRACK_ELEM_END_STATION && direction == 2) { imageId = SPR_STATION_LIGHT_BACK_NE_SW | gTrackColours[SCHEME_SUPPORTS]; - sub_98196C(imageId, 31, 0, 1, 8, 7, height + 7, get_current_rotation()); + sub_98196C(imageId, 31, 0, 1, 8, 7, height + fenceOffsetB, get_current_rotation()); } } else if (direction == 1 || direction == 3) { //height += 5 (height + 5); @@ -370,7 +375,7 @@ void track_paint_util_draw_station(uint8 rideIndex, uint8 trackSequence, uint8 d } else { imageId = (hasFence ? SPR_STATION_PLATFORM_FENCED_NW_SE : SPR_STATION_PLATFORM_NW_SE) | gTrackColours[SCHEME_SUPPORTS]; } - sub_98196C(imageId, 0, 0, 8, 32, 1, height + 5, get_current_rotation()); + sub_98196C(imageId, 0, 0, 8, 32, 1, height + fenceOffsetA, get_current_rotation()); //height -= 5 (height) track_paint_util_draw_station_covers(EDGE_NE, hasFence, entranceStyle, direction, height); //height += 5 (height + 5) @@ -382,7 +387,7 @@ void track_paint_util_draw_station(uint8 rideIndex, uint8 trackSequence, uint8 d } else { imageId = SPR_STATION_PLATFORM_NW_SE | gTrackColours[SCHEME_SUPPORTS]; } - sub_98196C(imageId, 24, 0, 8, 32, 1, height + 5, get_current_rotation()); + sub_98196C(imageId, 24, 0, 8, 32, 1, height + fenceOffsetA, get_current_rotation()); //height += 2 (height + 7) hasFence = track_paint_util_has_fence(EDGE_SW, position, mapElement, ride, get_current_rotation()); @@ -394,15 +399,15 @@ void track_paint_util_draw_station(uint8 rideIndex, uint8 trackSequence, uint8 d } else { imageId = SPR_STATION_FENCE_NW_SE | gTrackColours[SCHEME_SUPPORTS]; } - sub_98196C(imageId, 31, 0, 1, 32, 7, height + 7, get_current_rotation()); + sub_98196C(imageId, 31, 0, 1, 32, 7, height + fenceOffsetB, get_current_rotation()); } else if (mapElement->properties.track.type == TRACK_ELEM_BEGIN_STATION && direction == 3) { // Addition: draw only small fence if there is an entrance/exit at the beginning imageId = SPR_STATION_FENCE_SMALL_SW_NE | gTrackColours[SCHEME_SUPPORTS]; - sub_98196C(imageId, 23, 31, 8, 1, 7, height + 7, get_current_rotation()); + sub_98196C(imageId, 23, 31, 8, 1, 7, height + fenceOffsetB, get_current_rotation()); } else if (mapElement->properties.track.type == TRACK_ELEM_END_STATION && direction == 1) { // Addition: draw only small fence if there is an entrance/exit at the end imageId = SPR_STATION_LIGHT_BACK_NW_SE | gTrackColours[SCHEME_SUPPORTS]; - sub_98196C(imageId, 23, 31, 8, 1, 7, height + 7, get_current_rotation()); + sub_98196C(imageId, 23, 31, 8, 1, 7, height + fenceOffsetB, get_current_rotation()); } //height -= 7 (height) @@ -411,10 +416,10 @@ void track_paint_util_draw_station(uint8 rideIndex, uint8 trackSequence, uint8 d if (mapElement->properties.track.type == TRACK_ELEM_BEGIN_STATION && direction == 3) { imageId = SPR_STATION_FENCE_SMALL_SW_NE | gTrackColours[SCHEME_SUPPORTS]; - sub_98196C(imageId, 0, 31, 8, 1, 7, height + 7, get_current_rotation()); + sub_98196C(imageId, 0, 31, 8, 1, 7, height + fenceOffsetB, get_current_rotation()); } else if (mapElement->properties.track.type == TRACK_ELEM_END_STATION && direction == 1) { imageId = SPR_STATION_LIGHT_BACK_NW_SE | gTrackColours[SCHEME_SUPPORTS]; - sub_98196C(imageId, 0, 31, 8, 1, 7, height + 7, get_current_rotation()); + sub_98196C(imageId, 0, 31, 8, 1, 7, height + fenceOffsetB, get_current_rotation()); } } } diff --git a/src/ride/track_paint.h b/src/ride/track_paint.h index 5f052f750b..e0be573f02 100644 --- a/src/ride/track_paint.h +++ b/src/ride/track_paint.h @@ -241,6 +241,7 @@ bool track_paint_util_draw_station_covers(enum edge edge, bool hasFence, const r bool track_paint_util_draw_station_covers_2(enum edge edge, bool hasFence, const rct_ride_entrance_definition * entranceStyle, uint8 direction, uint16 height, bool tall); void track_paint_util_draw_station_platform(rct_ride *ride, uint8 direction, int height, int zOffset, rct_map_element * mapElement); void track_paint_util_draw_station(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement); +void track_paint_util_draw_station_2(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement, int fenceOffsetA, int fenceOffsetB); void track_paint_util_draw_station_inverted(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement); bool track_paint_util_should_paint_supports(rct_xy16 position); void track_paint_util_draw_pier(rct_ride * ride, const rct_ride_entrance_definition * entranceStyle, rct_xy16 position, uint8 direction, int height, rct_map_element * mapElement, uint8 rotation); diff --git a/test/testpaint/intercept.c b/test/testpaint/intercept.c index 179f61af32..468f1853cc 100644 --- a/test/testpaint/intercept.c +++ b/test/testpaint/intercept.c @@ -511,7 +511,7 @@ static bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) unk_140E9A8 = &dpi; rct_ride ride = { 0 }; - ride.entrance_style = RIDE_ENTRANCE_STYLE_CANVAS_TENT; + // ride.entrance_style = RIDE_ENTRANCE_STYLE_CANVAS_TENT; rct_ride_entry rideEntry = { 0 }; rct_ride_entry_vehicle vehicleEntry = {.base_image_id = 0x70000};