From bc6dd233ec8e4ff9a9657c98cda66d5d631eb563 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 7 May 2016 00:17:49 +0200 Subject: [PATCH 1/8] Draw chairlift --- src/ride/track_data.c | 4 +- src/ride/track_paint.h | 1 + src/ride/transport/chairlift.c | 436 +++++++++++++++++++++++++++++++++ 3 files changed, 439 insertions(+), 2 deletions(-) diff --git a/src/ride/track_data.c b/src/ride/track_data.c index 68ed96fcbb..232c59cb38 100644 --- a/src/ride/track_data.c +++ b/src/ride/track_data.c @@ -5485,7 +5485,7 @@ const uint32 RideTypeTrackPaintFunctionsOld[91] = { 0x008A5B88, // RIDE_TYPE_LOOPING_ROLLER_COASTER 0x0070EDB4, // RIDE_TYPE_DINGHY_SLIDE 0x0071BC40, // RIDE_TYPE_MINE_TRAIN_COASTER - 0x00743EC8, // RIDE_TYPE_CHAIRLIFT + 0, // RIDE_TYPE_CHAIRLIFT 0x008A7784, // RIDE_TYPE_CORKSCREW_ROLLER_COASTER 0, // RIDE_TYPE_MAZE 0, // RIDE_TYPE_SPIRAL_SLIDE @@ -5580,7 +5580,7 @@ const TRACK_PAINT_FUNCTION_GETTER RideTypeTrackPaintFunctions[91] = { 0, // RIDE_TYPE_LOOPING_ROLLER_COASTER 0, // RIDE_TYPE_DINGHY_SLIDE 0, // RIDE_TYPE_MINE_TRAIN_COASTER - 0, // RIDE_TYPE_CHAIRLIFT + get_track_paint_function_chairlift, // RIDE_TYPE_CHAIRLIFT 0, // RIDE_TYPE_CORKSCREW_ROLLER_COASTER get_track_paint_function_maze, // RIDE_TYPE_MAZE get_track_paint_function_spiral_slide, // RIDE_TYPE_SPIRAL_SLIDE diff --git a/src/ride/track_paint.h b/src/ride/track_paint.h index 3d37da77f9..a158dad197 100644 --- a/src/ride/track_paint.h +++ b/src/ride/track_paint.h @@ -64,6 +64,7 @@ bool track_paint_util_should_paint_supports(rct_xy16 position); 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_chairlift(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_maze(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_spiral_slide(int trackType, int direction); TRACK_PAINT_FUNCTION get_track_paint_function_dodgems(int trackType, int direction); diff --git a/src/ride/transport/chairlift.c b/src/ride/transport/chairlift.c index 846fd9695d..cdb15c313e 100644 --- a/src/ride/transport/chairlift.c +++ b/src/ride/transport/chairlift.c @@ -13,3 +13,439 @@ * A full copy of the GNU General Public License can be found in licence.txt *****************************************************************************/ #pragma endregion + +#include "../../world/map.h" +#include "../track_paint.h" +#include "../track.h" +#include "../../paint/paint.h" +#include "../../interface/viewport.h" +#include "../../paint/supports.h" + +enum +{ + SPR_CHAIRLIFT_CABLE_FLAT_SW_NE = 20500, + SPR_CHAIRLIFT_CABLE_FLAT_SE_NW, + SPR_20502, + SPR_20503, + SPR_20504, + SPR_20505, + SPR_20506, + SPR_20507, + SPR_20508, + SPR_20509, + SPR_20510, + SPR_20511, + SPR_20512, + SPR_20513, + SPR_20514, + SPR_20515, + SPR_CHAIRLIFT_CABLE_UP_SW_NE, + SPR_CHAIRLIFT_CABLE_UP_NW_SE, + SPR_CHAIRLIFT_CABLE_UP_NE_SW, + SPR_CHAIRLIFT_CABLE_UP_SE_NW, + SPR_20520, + SPR_20521, + SPR_20522, + SPR_20523, + SPR_20524, + SPR_20525, + SPR_20526, + SPR_20527, + SPR_CHAIRLIFT_CORNER_NW_SW, + SPR_CHAIRLIFT_CORNER_NW_NE, + SPR_CHAIRLIFT_CORNER_SE_NE, + SPR_CHAIRLIFT_CORNER_SW_SE, + SPR_20532, + SPR_20533, + SPR_20534, + SPR_20535, + SPR_20536, + SPR_20537, + SPR_20538, + SPR_20539, + SPR_20540, + SPR_20541, + SPR_20542, + SPR_20543, + SPR_20544, + SPR_20545, + SPR_20546, + SPR_20547, +} SPR_CHAIRLIFT; + +enum +{ + SEGMENT_B4 = (1 << 0), + SEGMENT_0 = SEGMENT_B4, + SEGMENT_B8 = (1 << 1), + SEGMENT_1 = SEGMENT_B8, + SEGMENT_BC = (1 << 2), + SEGMENT_2 = SEGMENT_BC, + SEGMENT_C0 = (1 << 3), + SEGMENT_3 = SEGMENT_C0, + SEGMENT_C4 = (1 << 4), + SEGMENT_4 = SEGMENT_C4, + SEGMENT_C8 = (1 << 5), + SEGMENT_5 = SEGMENT_C8, + SEGMENT_CC = (1 << 6), + SEGMENT_6 = SEGMENT_CC, + SEGMENT_D0 = (1 << 7), + SEGMENT_7 = SEGMENT_D0, + SEGMENT_D4 = (1 << 8), + SEGMENT_8 = SEGMENT_D4, +}; + +const int SEGMENTS_ALL = SEGMENT_B4 | SEGMENT_B8 | SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4; + +static void paint_util_set_segment_support_height(int flags, uint16 height, uint8 segment_flags) +{ + for (int s = 0; s < 9; s++) { + if (flags & (1 << s)) { + RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16) = height; + RCT2_GLOBAL(0x0141E9B6 + s * 4, uint8) = segment_flags; + } + } +} + +static void paint_util_set_support_height(uint16 height, uint8 flags) +{ + if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; + RCT2_GLOBAL(0x141E9DA, uint8) = flags; + } +} + +enum +{ + TUNNEL_0, + TUNNEL_FLAT = 6, + TUNNEL_7 = 7, + TUNNEL_UP = 8, + TUNNEL_14 = 0x0E +}; + +static void paint_util_push_tunnel_left(uint16 height, uint8 type) +{ + uint32 eax = 0xFFFF0000 | ((height / 16) & 0xFF) | type << 8; + RCT2_ADDRESS(0x009E3138, uint32)[RCT2_GLOBAL(0x141F56A, uint8) / 2] = eax; + RCT2_GLOBAL(0x141F56A, uint8)++; +} + +static void paint_util_push_tunnel_right(uint16 height, uint8 type) +{ + uint32 eax = 0xFFFF0000 | ((height / 16) & 0xFF) | type << 8; + RCT2_ADDRESS(0x009E30B6, uint32)[RCT2_GLOBAL(0x141F56B, uint8) / 2] = eax; + RCT2_GLOBAL(0x141F56B, uint8)++; +} + +static void chairlift_paint_util_draw_supports(int supports, uint16 height) +{ + bool success = false; + + for (int s = 0; s < 9; s++) { + if (!(supports & (1 << s))) { + continue; + } + + if (metal_a_supports_paint_setup(10, s, 0, height, RCT2_GLOBAL(0x00F4419C, uint32))) { + success = true; + } + } + + if (success) { + return; + } + + for (int s = 0; s < 9; s++) { + if (!(supports & (1 << s))) { + continue; + } + uint16 temp = RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16); + RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, uint16); + metal_a_supports_paint_setup(10, s, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16) = temp; + } +} + +static void chairlift_paint_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + uint32 imageId; + if (direction & 1) { + imageId = SPR_CHAIRLIFT_CABLE_FLAT_SE_NW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + paint_util_push_tunnel_right(height, TUNNEL_FLAT); + } else { + imageId = SPR_CHAIRLIFT_CABLE_FLAT_SW_NE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + paint_util_push_tunnel_left(height, TUNNEL_FLAT); + } + + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_support_height(height + 32, 0x20); +} + +/** rct2: 0x00743FD8 */ +static void chairlift_paint_25_deg_up(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + uint32 imageId; + + switch (direction) { + case 0: + imageId = SPR_CHAIRLIFT_CABLE_UP_SW_NE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + paint_util_push_tunnel_left(height - 8, TUNNEL_7); + break; + + case 1: + imageId = SPR_CHAIRLIFT_CABLE_UP_NW_SE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + paint_util_push_tunnel_right(height + 8, TUNNEL_UP); + break; + + case 2: + imageId = SPR_CHAIRLIFT_CABLE_UP_NE_SW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + paint_util_push_tunnel_left(height + 8, TUNNEL_UP); + break; + + case 3: + imageId = SPR_CHAIRLIFT_CABLE_UP_SE_NW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + paint_util_push_tunnel_right(height - 8, TUNNEL_7); + break; + } + + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_support_height(height + 56, 0x20); +} + +/** rct2: 0x00743FD8 */ +static void chairlift_paint_flat_to_25_deg_up(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + uint32 imageId; + + switch (direction) { + case 0: + imageId = SPR_20508 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + + imageId = SPR_20520 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + + paint_util_push_tunnel_left(height, TUNNEL_FLAT); + break; + + case 1: + imageId = SPR_20509 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + + imageId = SPR_20521 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + + paint_util_push_tunnel_right(height, TUNNEL_UP); + break; + + case 2: + imageId = SPR_20510 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + + imageId = SPR_20522 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + + paint_util_push_tunnel_left(height, TUNNEL_UP); + break; + + case 3: + imageId = SPR_20511 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + + imageId = SPR_20523 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + + paint_util_push_tunnel_right(height, TUNNEL_FLAT); + break; + } + + chairlift_paint_util_draw_supports(SEGMENT_4, height); + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_support_height(height + 48, 0x20); +} + +/** rct2: 0x00743FF8 */ +static void chairlift_paint_25_deg_up_to_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + uint32 imageId; + + switch (direction) { + case 0: + imageId = SPR_20512 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + + imageId = SPR_20524 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + + paint_util_push_tunnel_left(height - 8, TUNNEL_FLAT); + break; + + case 1: + imageId = SPR_20513 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + + imageId = SPR_20525 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + + paint_util_push_tunnel_right(height + 8, TUNNEL_14); + break; + + case 2: + imageId = SPR_20514 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + + imageId = SPR_20526 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + + paint_util_push_tunnel_left(height + 8, TUNNEL_14); + break; + + case 3: + imageId = SPR_20515 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + + imageId = SPR_20527 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + + paint_util_push_tunnel_right(height - 8, TUNNEL_FLAT); + break; + + } + + chairlift_paint_util_draw_supports(SEGMENT_4, height); + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_support_height(height + 40, 0x20); +} + +/** rct2: 0x00744008 */ +static void chairlift_paint_25_deg_down(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + chairlift_paint_25_deg_up(rideIndex, trackSequence, (direction + 2) % 4, height, mapElement); +} + +/** rct2: 0x00744018 */ +static void chairlift_paint_flat_to_25_deg_down(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + chairlift_paint_25_deg_up_to_flat(rideIndex, trackSequence, (direction + 2) % 4, height, mapElement); +} + +/** rct2: 0x00744028 */ +static void chairlift_paint_25_deg_down_to_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + chairlift_paint_flat_to_25_deg_up(rideIndex, trackSequence, (direction + 2) % 4, height, mapElement); +} + +/** rct2: 0x00744038 */ +static void chairlift_paint_left_quarter_turn_1_tile(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + uint32 imageId; + + switch (direction) { + case 0: + imageId = SPR_CHAIRLIFT_CORNER_NW_SW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 16, 16, 2, height, 16, 0, height + 28, get_current_rotation()); + + imageId = SPR_20532 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 16, 4, height, get_current_rotation()); + + imageId = SPR_20536 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 28, 4, height, get_current_rotation()); + + paint_util_push_tunnel_left(height, TUNNEL_FLAT); + chairlift_paint_util_draw_supports(SEGMENT_5 | SEGMENT_7, height); + break; + + case 1: + imageId = SPR_CHAIRLIFT_CORNER_NW_NE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 16, 16, 2, height, 0, 0, height + 28, get_current_rotation()); + + imageId = SPR_20533 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 16, 4, height, get_current_rotation()); + + imageId = SPR_20537 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 4, 16, height, get_current_rotation()); + + chairlift_paint_util_draw_supports(SEGMENT_5 | SEGMENT_6, height); + break; + + case 2: + imageId = SPR_CHAIRLIFT_CORNER_SE_NE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 16, 16, 2, height, 0, 16, height + 28, get_current_rotation()); + + imageId = SPR_20534 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 4, 16, height, get_current_rotation()); + + imageId = SPR_20538 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 16, 28, height, get_current_rotation()); + + paint_util_push_tunnel_right(height, TUNNEL_FLAT); + chairlift_paint_util_draw_supports(SEGMENT_6 | SEGMENT_8, height); + break; + + case 3: + imageId = SPR_CHAIRLIFT_CORNER_SW_SE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 16, 16, 2, height, 16, 16, height + 28, get_current_rotation()); + + imageId = SPR_20535 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 28, 16, height, get_current_rotation()); + + imageId = SPR_20539 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 16, 28, height, get_current_rotation()); + + paint_util_push_tunnel_left(height, TUNNEL_FLAT); + paint_util_push_tunnel_right(height, TUNNEL_FLAT); + chairlift_paint_util_draw_supports(SEGMENT_7 | SEGMENT_8, height); + break; + } + + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_support_height(height + 32, 0x20); +} + +/** rct2: 0x00744048 */ +static void chairlift_paint_right_quarter_turn_1_tile(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + chairlift_paint_left_quarter_turn_1_tile(rideIndex, trackSequence, (direction + 3) % 4, height, mapElement); +} + +/* 0x008AAA0C */ +TRACK_PAINT_FUNCTION get_track_paint_function_chairlift(int trackType, int direction) +{ + switch (trackType) { + case TRACK_ELEM_BEGIN_STATION: + case TRACK_ELEM_MIDDLE_STATION: + case TRACK_ELEM_END_STATION: + return NULL; + + case TRACK_ELEM_FLAT: + return chairlift_paint_flat; + + case TRACK_ELEM_FLAT_TO_25_DEG_UP: + return chairlift_paint_flat_to_25_deg_up; + case TRACK_ELEM_25_DEG_UP: + return chairlift_paint_25_deg_up; + case TRACK_ELEM_25_DEG_UP_TO_FLAT: + return chairlift_paint_25_deg_up_to_flat; + + case TRACK_ELEM_FLAT_TO_25_DEG_DOWN: + return chairlift_paint_flat_to_25_deg_down; + case TRACK_ELEM_25_DEG_DOWN: + return chairlift_paint_25_deg_down; + case TRACK_ELEM_25_DEG_DOWN_TO_FLAT: + return chairlift_paint_25_deg_down_to_flat; + + case TRACK_ELEM_LEFT_QUARTER_TURN_1_TILE: + return chairlift_paint_left_quarter_turn_1_tile; + case TRACK_ELEM_RIGHT_QUARTER_TURN_1_TILE: + return chairlift_paint_right_quarter_turn_1_tile; + } + + return NULL; +} From e4e98883520015a011143448edfa05c6eafa22ac Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 7 May 2016 12:07:09 +0200 Subject: [PATCH 2/8] [wip] station --- src/ride/transport/chairlift.c | 226 +++++++++++++++++++++++++++++++-- 1 file changed, 215 insertions(+), 11 deletions(-) diff --git a/src/ride/transport/chairlift.c b/src/ride/transport/chairlift.c index cdb15c313e..cef460c9e6 100644 --- a/src/ride/transport/chairlift.c +++ b/src/ride/transport/chairlift.c @@ -20,6 +20,17 @@ #include "../../paint/paint.h" #include "../../interface/viewport.h" #include "../../paint/supports.h" +#include "../ride.h" +#include "../ride_data.h" + +enum +{ + SPR_METAL_FLOOR = 14567, + SPR_METAL_FENCE_NE = 14568, + SPR_METAL_FENCE_SE = 14569, + SPR_METAL_FENCE_SW = 14570, + SPR_METAL_FENCE_NW = 14571 +}; enum { @@ -29,8 +40,8 @@ enum SPR_20503, SPR_20504, SPR_20505, - SPR_20506, - SPR_20507, + SPR_CHAIRLIFT_STATION_COLUMN_NE_SW, + SPR_CHAIRLIFT_STATION_COLUMN_SE_NW, SPR_20508, SPR_20509, SPR_20510, @@ -63,16 +74,23 @@ enum SPR_20537, SPR_20538, SPR_20539, - SPR_20540, - SPR_20541, - SPR_20542, - SPR_20543, - SPR_20544, - SPR_20545, - SPR_20546, - SPR_20547, + SPR_CHAIRLIFT_BULLWHEEL_FRAME_1, + SPR_CHAIRLIFT_BULLWHEEL_FRAME_2, + SPR_CHAIRLIFT_BULLWHEEL_FRAME_3, + SPR_CHAIRLIFT_BULLWHEEL_FRAME_4, + SPR_CHAIRLIFT_STATION_END_CAP_NE, + SPR_CHAIRLIFT_STATION_END_CAP_SE, + SPR_CHAIRLIFT_STATION_END_CAP_SW, + SPR_CHAIRLIFT_STATION_END_CAP_NW, } SPR_CHAIRLIFT; +const uint32 chairlift_bullwheel_frames[] = { + SPR_CHAIRLIFT_BULLWHEEL_FRAME_1, + SPR_CHAIRLIFT_BULLWHEEL_FRAME_2, + SPR_CHAIRLIFT_BULLWHEEL_FRAME_3, + SPR_CHAIRLIFT_BULLWHEEL_FRAME_4 +}; + enum { SEGMENT_B4 = (1 << 0), @@ -138,6 +156,57 @@ static void paint_util_push_tunnel_right(uint16 height, uint8 type) RCT2_GLOBAL(0x141F56B, uint8)++; } +/* rct2: 0x007667AE */ +static rct_xy16 loc_7667AE[] = { + {.x = 0, .y = -1}, + {.x = 1, .y = 0}, + {.x = 0, .y = 1}, + {.x = -1, .y = 0}, +}; + +/* rct2: 0x007667AC */ +static rct_xy16 loc_7667AC[] = { + {.x = -1, .y = 0}, + {.x = 0, .y = -1}, + {.x = 1, .y = 0}, + {.x = 0, .y = 1}, +}; + +typedef enum EDGE +{ + EDGE_NE, + EDGE_SE, + EDGE_SW, + EDGE_NW +} EDGE; + +static bool paint_util_has_fence(EDGE edge, rct_xy16 position, rct_map_element * mapElement, rct_ride * ride, uint8 rotation) +{ + rct_xy16 offset; + switch (edge) { + case EDGE_NE: + offset = loc_7667AC[rotation]; + break; + case EDGE_SE: + offset = loc_7667AC[(rotation + 1) & 3]; + break; + case EDGE_SW: + offset = loc_7667AE[(rotation + 1) & 3]; + break; + case EDGE_NW: + offset = loc_7667AE[rotation]; + break; + }; + + uint16 entranceLoc = + ((position.x / 32) + offset.x) | + (((position.y / 32) + offset.y) << 8); + + uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; + + return (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc); +} + static void chairlift_paint_util_draw_supports(int supports, uint16 height) { bool success = false; @@ -167,6 +236,141 @@ static void chairlift_paint_util_draw_supports(int supports, uint16 height) } } +rct_map_element * map_get_track_element_at_from_ride_fuzzy(int x, int y, int z, int rideIndex) +{ + rct_map_element * mapElement = map_get_first_element_at(x >> 5, y >> 5); + do { + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK) continue; + if (mapElement->properties.track.ride_index != rideIndex) continue; + if (mapElement->base_height != z && mapElement->base_height != z - 1) continue; + + return mapElement; + } while (!map_element_is_last_for_tile(mapElement++)); + + return NULL; +}; + +static void chairlift_paint_station(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + if (direction != 0) { + return; + } + + const rct_xy16 pos = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; + uint8 trackType = mapElement->properties.track.type; + rct_ride * ride = get_ride(rideIndex); + uint32 imageId; + uint8 branch = 0; + + if (trackType == TRACK_ELEM_BEGIN_STATION || trackType == TRACK_ELEM_END_STATION) { + rct_xy16 delta = TileDirectionDelta[map_element_get_direction(mapElement)]; + + rct_xy16 newPos; + if (trackType == TRACK_ELEM_BEGIN_STATION) { + newPos = (rct_xy16) { + .x = pos.x - delta.x, + .y = pos.y - delta.y, + }; + } else { + newPos = (rct_xy16) { + .x = pos.x + delta.x, + .y = pos.y + delta.y, + }; + } + + rct_map_element * nextTrack = map_get_track_element_at_from_ride_fuzzy(newPos.x, newPos.y, mapElement->base_height, rideIndex); + if ((nextTrack == NULL && trackType == TRACK_ELEM_BEGIN_STATION && direction == 0) + || (nextTrack == NULL && trackType == TRACK_ELEM_END_STATION && direction == 2)) { + branch = 1; + } + } + + const rct_ride_entrance_definition * entranceStyle = &RideEntranceDefinitions[ride->entrance_style]; + uint32 eax = entranceStyle->flags; + + if (RCT2_GLOBAL(0x00F441A0, uint32) != 0x20000000) { + eax &= 0x7FFFF; + } + + RCT2_GLOBAL(0x00F441E8, uint32) = eax; + RCT2_GLOBAL(0x00F441E4, uint32) = eax; + + wooden_a_supports_paint_setup(0, 0, height, RCT2_GLOBAL(0x00F441A0, uint32), NULL); + + if (branch == 0) { + imageId = SPR_20502 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + } + + imageId = SPR_METAL_FLOOR | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); + + if (paint_util_has_fence(EDGE_NW, pos, mapElement, ride, get_current_rotation())) { + imageId = SPR_METAL_FENCE_NW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 32, 1, 7, height, 0, 2, height + 2, get_current_rotation()); + RCT2_GLOBAL(0x00F441E8, uint32)++; + } + + imageId = RCT2_GLOBAL(0x00F441E8, uint32); + if (imageId > 0x20) { + if (imageId & 0x40000000) { + // save imageId; + uint32 tempImageId = imageId & 0xBFFFFFFF; + sub_98197C(tempImageId, 0, 0, 30, 1, 30, height, 1, 0, height + 1, get_current_rotation()); + + uint32 edi = RCT2_GLOBAL(0x00F4419C, uint32) & (0b11111 << 19); + + // weird jump + if (true) { + imageId = imageId | edi + 0x380000C; + sub_98199C(imageId, 0, 0, 30, 1, 30, height, 1, 0, height + 1, get_current_rotation()); + } + } else { + imageId |= RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 30, 1, 30, height, 1, 0, height + 1, get_current_rotation()); + } + } + + if (RCT2_GLOBAL(0x0141E9DB, uint8) & 3) { + // Something with ghosting? + imageId = SPR_METAL_FENCE_SE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 1, 27, height, 0, 30, height + 2, get_current_rotation()); + + uint32 ebx = RCT2_GLOBAL(0x00F441E4, uint32); + if (ebx >= 0x20) { + if (ebx & 0x40000000) { + + } else { + imageId = (ebx | RCT2_GLOBAL(0x00F44198, uint32)) + 2; + sub_98197C(imageId, 0, 0, 32, 32, 0, height, 0, 0, height + 31, get_current_rotation()); + } + } + } + + if (branch == 1) { + imageId = SPR_METAL_FENCE_SW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 1, 28, 27, height, 30, 2, height + 4, get_current_rotation()); + + imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + + imageId = SPR_CHAIRLIFT_STATION_END_CAP_NE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + } + + imageId = SPR_CHAIRLIFT_STATION_COLUMN_NE_SW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 16, 1, 1, 7, height + 2, 1, 16, height + 2, get_current_rotation()); + + if (branch == 0) { + imageId = SPR_CHAIRLIFT_STATION_COLUMN_NE_SW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 30, 16, 1, 1, 7, height + 2, 1, 16, height + 2, get_current_rotation()); // bound offset x is wrong? + } + + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_push_tunnel_left(height, TUNNEL_FLAT); + paint_util_set_support_height(height + 32, 0x20); +} + static void chairlift_paint_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { uint32 imageId; @@ -422,7 +626,7 @@ TRACK_PAINT_FUNCTION get_track_paint_function_chairlift(int trackType, int direc case TRACK_ELEM_BEGIN_STATION: case TRACK_ELEM_MIDDLE_STATION: case TRACK_ELEM_END_STATION: - return NULL; + return chairlift_paint_station; case TRACK_ELEM_FLAT: return chairlift_paint_flat; From 4173a420601f67165feb01ef0b31d6755b64d277 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 7 May 2016 14:55:13 +0200 Subject: [PATCH 3/8] Refactor station overlay --- src/ride/transport/chairlift.c | 142 +++++++++++++++++++++------------ 1 file changed, 91 insertions(+), 51 deletions(-) diff --git a/src/ride/transport/chairlift.c b/src/ride/transport/chairlift.c index cef460c9e6..a337a67313 100644 --- a/src/ride/transport/chairlift.c +++ b/src/ride/transport/chairlift.c @@ -250,17 +250,77 @@ rct_map_element * map_get_track_element_at_from_ride_fuzzy(int x, int y, int z, return NULL; }; -static void chairlift_paint_station(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +enum { - if (direction != 0) { - return; + SPR_STATION_COVER_OFFSET_NE_SW_BACK_0 = 0, + SPR_STATION_COVER_OFFSET_NE_SW_BACK_1, + SPR_STATION_COVER_OFFSET_NE_SW_FRONT, + SPR_STATION_COVER_OFFSET_SE_NW_BACK_0, + SPR_STATION_COVER_OFFSET_SE_NW_BACK_1, + SPR_STATION_COVER_OFFSET_SE_NW_FRONT, + SPR_STATION_COVER_OFFSET_HIGH, + SPR_STATION_COVER_OFFSET_FLASS +} SPR_STATION_COVER; + +static bool paint_util_draw_station_covers(EDGE edge, bool hasFence, rct_ride_entrance_definition * entranceStyle, uint8 direction, uint16 height) +{ + uint32 imageId; + uint32 baseImageId = entranceStyle->flags; + int imageOffset; + rct_xyz16 offset, bounds, boundsOffset; + + offset = (rct_xyz16) {0, 0, height}; + switch (edge) { + case EDGE_NE: + break; + case EDGE_SE: + bounds = (rct_xyz16) {32, 32, 0}; + boundsOffset = (rct_xyz16) {1, 0, height + 31}; + imageOffset = SPR_STATION_COVER_OFFSET_NE_SW_FRONT; + break; + case EDGE_SW: + break; + case EDGE_NW: + bounds = (rct_xyz16) {30, 1, 30}; + boundsOffset = (rct_xyz16) {1, 0, height + 1}; + imageOffset = hasFence ? SPR_STATION_COVER_OFFSET_NE_SW_BACK_1 : SPR_STATION_COVER_OFFSET_NE_SW_BACK_0; + break; } + if (RCT2_GLOBAL(0x00F441A0, uint32) != 0x20000000) { + baseImageId &= 0x7FFFF; + } + + if (baseImageId <= 0x20) { + return false; + } + + if (baseImageId & 0x40000000) { + imageId = baseImageId & 0xBFFFFFFF + imageOffset; + sub_98197C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation()); + + uint32 edi = RCT2_GLOBAL(0x00F4419C, uint32) & (0b11111 << 19); + + // weird jump + imageId = baseImageId | edi + 0x3800000 + imageOffset + 12; + sub_98199C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation()); + return true; + } + + imageId = (baseImageId + imageOffset) | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation()); + return true; +} + +static void chairlift_paint_station_ne_sw(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ const rct_xy16 pos = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; uint8 trackType = mapElement->properties.track.type; rct_ride * ride = get_ride(rideIndex); uint32 imageId; - uint8 branch = 0; + + bool isStart = false; + bool isEnd = false; if (trackType == TRACK_ELEM_BEGIN_STATION || trackType == TRACK_ELEM_END_STATION) { rct_xy16 delta = TileDirectionDelta[map_element_get_direction(mapElement)]; @@ -279,75 +339,46 @@ static void chairlift_paint_station(uint8 rideIndex, uint8 trackSequence, uint8 } rct_map_element * nextTrack = map_get_track_element_at_from_ride_fuzzy(newPos.x, newPos.y, mapElement->base_height, rideIndex); - if ((nextTrack == NULL && trackType == TRACK_ELEM_BEGIN_STATION && direction == 0) - || (nextTrack == NULL && trackType == TRACK_ELEM_END_STATION && direction == 2)) { - branch = 1; + if (nextTrack == NULL && trackType == TRACK_ELEM_BEGIN_STATION) { + isStart = true; + } + + if (nextTrack == NULL && trackType == TRACK_ELEM_END_STATION) { + isEnd = true; } } const rct_ride_entrance_definition * entranceStyle = &RideEntranceDefinitions[ride->entrance_style]; - uint32 eax = entranceStyle->flags; - if (RCT2_GLOBAL(0x00F441A0, uint32) != 0x20000000) { - eax &= 0x7FFFF; - } - - RCT2_GLOBAL(0x00F441E8, uint32) = eax; - RCT2_GLOBAL(0x00F441E4, uint32) = eax; wooden_a_supports_paint_setup(0, 0, height, RCT2_GLOBAL(0x00F441A0, uint32), NULL); - if (branch == 0) { - imageId = SPR_20502 | RCT2_GLOBAL(0x00F44198, uint32); + if (!isStart && !isEnd) { + imageId = ((direction == 0) ? SPR_20502 : SPR_20504) | RCT2_GLOBAL(0x00F44198, uint32); sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); } imageId = SPR_METAL_FLOOR | RCT2_GLOBAL(0x00F4419C, uint32); sub_98197C(imageId, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); - if (paint_util_has_fence(EDGE_NW, pos, mapElement, ride, get_current_rotation())) { + bool hasFence = paint_util_has_fence(EDGE_NW, pos, mapElement, ride, get_current_rotation()); + if (hasFence) { imageId = SPR_METAL_FENCE_NW | RCT2_GLOBAL(0x00F44198, uint32); sub_98199C(imageId, 0, 0, 32, 1, 7, height, 0, 2, height + 2, get_current_rotation()); - RCT2_GLOBAL(0x00F441E8, uint32)++; } + paint_util_draw_station_covers(EDGE_NW, hasFence, entranceStyle, direction, height); - imageId = RCT2_GLOBAL(0x00F441E8, uint32); - if (imageId > 0x20) { - if (imageId & 0x40000000) { - // save imageId; - uint32 tempImageId = imageId & 0xBFFFFFFF; - sub_98197C(tempImageId, 0, 0, 30, 1, 30, height, 1, 0, height + 1, get_current_rotation()); - - uint32 edi = RCT2_GLOBAL(0x00F4419C, uint32) & (0b11111 << 19); - - // weird jump - if (true) { - imageId = imageId | edi + 0x380000C; - sub_98199C(imageId, 0, 0, 30, 1, 30, height, 1, 0, height + 1, get_current_rotation()); - } - } else { - imageId |= RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 30, 1, 30, height, 1, 0, height + 1, get_current_rotation()); - } - } if (RCT2_GLOBAL(0x0141E9DB, uint8) & 3) { - // Something with ghosting? - imageId = SPR_METAL_FENCE_SE | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 32, 1, 27, height, 0, 30, height + 2, get_current_rotation()); - - uint32 ebx = RCT2_GLOBAL(0x00F441E4, uint32); - if (ebx >= 0x20) { - if (ebx & 0x40000000) { - - } else { - imageId = (ebx | RCT2_GLOBAL(0x00F44198, uint32)) + 2; - sub_98197C(imageId, 0, 0, 32, 32, 0, height, 0, 0, height + 31, get_current_rotation()); - } + hasFence = paint_util_has_fence(EDGE_NW, pos, mapElement, ride, get_current_rotation()); + if (hasFence) { + imageId = SPR_METAL_FENCE_SE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 1, 27, height, 0, 30, height + 2, get_current_rotation()); } + paint_util_draw_station_covers(EDGE_SE, hasFence, entranceStyle, direction, height); } - if (branch == 1) { + if ((direction == 0 && isStart) || (direction == 2 && isEnd)) { imageId = SPR_METAL_FENCE_SW | RCT2_GLOBAL(0x00F44198, uint32); sub_98197C(imageId, 0, 0, 1, 28, 27, height, 30, 2, height + 4, get_current_rotation()); @@ -361,7 +392,7 @@ static void chairlift_paint_station(uint8 rideIndex, uint8 trackSequence, uint8 imageId = SPR_CHAIRLIFT_STATION_COLUMN_NE_SW | RCT2_GLOBAL(0x00F44198, uint32); sub_98197C(imageId, 0, 16, 1, 1, 7, height + 2, 1, 16, height + 2, get_current_rotation()); - if (branch == 0) { + if (!isStart && !isEnd) { imageId = SPR_CHAIRLIFT_STATION_COLUMN_NE_SW | RCT2_GLOBAL(0x00F44198, uint32); sub_98197C(imageId, 30, 16, 1, 1, 7, height + 2, 1, 16, height + 2, get_current_rotation()); // bound offset x is wrong? } @@ -371,6 +402,15 @@ static void chairlift_paint_station(uint8 rideIndex, uint8 trackSequence, uint8 paint_util_set_support_height(height + 32, 0x20); } +static void chairlift_paint_station(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + if (direction % 2) { + + } else { + chairlift_paint_station_ne_sw(rideIndex, trackSequence, direction, height, mapElement); + } +} + static void chairlift_paint_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { uint32 imageId; From de8b5b0aaf09feee771050e5fad730cac842d795 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 7 May 2016 16:15:48 +0200 Subject: [PATCH 4/8] Finish drawing station for rot 0 and 2 --- src/ride/transport/chairlift.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/ride/transport/chairlift.c b/src/ride/transport/chairlift.c index a337a67313..e3ebb4656a 100644 --- a/src/ride/transport/chairlift.c +++ b/src/ride/transport/chairlift.c @@ -299,7 +299,7 @@ static bool paint_util_draw_station_covers(EDGE edge, bool hasFence, rct_ride_en imageId = baseImageId & 0xBFFFFFFF + imageOffset; sub_98197C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation()); - uint32 edi = RCT2_GLOBAL(0x00F4419C, uint32) & (0b11111 << 19); + uint32 edi = RCT2_GLOBAL(0x00F44198, uint32) & (0b11111 << 19); // weird jump imageId = baseImageId | edi + 0x3800000 + imageOffset + 12; @@ -368,6 +368,10 @@ static void chairlift_paint_station_ne_sw(uint8 rideIndex, uint8 trackSequence, } paint_util_draw_station_covers(EDGE_NW, hasFence, entranceStyle, direction, height); + if ((direction == 2 && isStart) || (direction == 0 && isEnd)) { + imageId = SPR_METAL_FENCE_NE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 1, 28, 7, height, 2, 2, height + 4, get_current_rotation()); + } if (RCT2_GLOBAL(0x0141E9DB, uint8) & 3) { hasFence = paint_util_has_fence(EDGE_NW, pos, mapElement, ride, get_current_rotation()); @@ -378,6 +382,8 @@ static void chairlift_paint_station_ne_sw(uint8 rideIndex, uint8 trackSequence, paint_util_draw_station_covers(EDGE_SE, hasFence, entranceStyle, direction, height); } + bool drawFrontColumn = true; + bool drawBackColumn = true; if ((direction == 0 && isStart) || (direction == 2 && isEnd)) { imageId = SPR_METAL_FENCE_SW | RCT2_GLOBAL(0x00F44198, uint32); sub_98197C(imageId, 0, 0, 1, 28, 27, height, 30, 2, height + 4, get_current_rotation()); @@ -387,12 +393,24 @@ static void chairlift_paint_station_ne_sw(uint8 rideIndex, uint8 trackSequence, imageId = SPR_CHAIRLIFT_STATION_END_CAP_NE | RCT2_GLOBAL(0x00F44198, uint32); sub_98199C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + + drawFrontColumn = false; + } else if ((direction == 2 && isStart) || (direction == 0 && isEnd)) { + imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + + imageId = SPR_CHAIRLIFT_STATION_END_CAP_SW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + + drawBackColumn = false; } - imageId = SPR_CHAIRLIFT_STATION_COLUMN_NE_SW | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 16, 1, 1, 7, height + 2, 1, 16, height + 2, get_current_rotation()); + if (drawBackColumn) { + imageId = SPR_CHAIRLIFT_STATION_COLUMN_NE_SW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 16, 1, 1, 7, height + 2, 1, 16, height + 2, get_current_rotation()); + } - if (!isStart && !isEnd) { + if (drawFrontColumn) { imageId = SPR_CHAIRLIFT_STATION_COLUMN_NE_SW | RCT2_GLOBAL(0x00F44198, uint32); sub_98197C(imageId, 30, 16, 1, 1, 7, height + 2, 1, 16, height + 2, get_current_rotation()); // bound offset x is wrong? } From 4ceb186ebfcd72d1b1aef6b8cd9a215851be6e58 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 7 May 2016 16:53:57 +0200 Subject: [PATCH 5/8] Implement NE<->SW station --- src/ride/transport/chairlift.c | 161 ++++++++++++++++++++++++++------- 1 file changed, 128 insertions(+), 33 deletions(-) diff --git a/src/ride/transport/chairlift.c b/src/ride/transport/chairlift.c index e3ebb4656a..9e6e4f61fc 100644 --- a/src/ride/transport/chairlift.c +++ b/src/ride/transport/chairlift.c @@ -258,8 +258,7 @@ enum SPR_STATION_COVER_OFFSET_SE_NW_BACK_0, SPR_STATION_COVER_OFFSET_SE_NW_BACK_1, SPR_STATION_COVER_OFFSET_SE_NW_FRONT, - SPR_STATION_COVER_OFFSET_HIGH, - SPR_STATION_COVER_OFFSET_FLASS + SPR_STATION_COVER_OFFSET_HIGH } SPR_STATION_COVER; static bool paint_util_draw_station_covers(EDGE edge, bool hasFence, rct_ride_entrance_definition * entranceStyle, uint8 direction, uint16 height) @@ -272,6 +271,9 @@ static bool paint_util_draw_station_covers(EDGE edge, bool hasFence, rct_ride_en offset = (rct_xyz16) {0, 0, height}; switch (edge) { case EDGE_NE: + bounds = (rct_xyz16) {1, 30, 0}; + boundsOffset = (rct_xyz16) {0, 1, height + 1}; + imageOffset = hasFence ? SPR_STATION_COVER_OFFSET_SE_NW_BACK_1 : SPR_STATION_COVER_OFFSET_SE_NW_BACK_0; break; case EDGE_SE: bounds = (rct_xyz16) {32, 32, 0}; @@ -279,6 +281,9 @@ static bool paint_util_draw_station_covers(EDGE edge, bool hasFence, rct_ride_en imageOffset = SPR_STATION_COVER_OFFSET_NE_SW_FRONT; break; case EDGE_SW: + bounds = (rct_xyz16) {32, 32, 0}; + boundsOffset = (rct_xyz16) {0, 0, height + 31}; + imageOffset = SPR_STATION_COVER_OFFSET_SE_NW_FRONT; break; case EDGE_NW: bounds = (rct_xyz16) {30, 1, 30}; @@ -312,6 +317,40 @@ static bool paint_util_draw_station_covers(EDGE edge, bool hasFence, rct_ride_en return true; } +bool paint_utils_is_first_track(uint8 rideIndex, const rct_map_element * mapElement, rct_xy16 pos, uint8 trackType) +{ + if (mapElement->properties.track.type != TRACK_ELEM_BEGIN_STATION) { + return false; + } + + rct_xy16 delta = TileDirectionDelta[map_element_get_direction(mapElement)]; + rct_xy16 newPos = { + .x = pos.x - delta.x, + .y = pos.y - delta.y, + }; + + rct_map_element * nextTrack = map_get_track_element_at_from_ride_fuzzy(newPos.x, newPos.y, mapElement->base_height, rideIndex); + + return nextTrack == NULL; +} + +bool paint_utils_is_last_track(uint8 rideIndex, const rct_map_element * mapElement, rct_xy16 pos, uint8 trackType) +{ + if (mapElement->properties.track.type != TRACK_ELEM_END_STATION) { + return false; + } + + rct_xy16 delta = TileDirectionDelta[map_element_get_direction(mapElement)]; + rct_xy16 newPos = { + .x = pos.x + delta.x, + .y = pos.y + delta.y, + }; + + rct_map_element * nextTrack = map_get_track_element_at_from_ride_fuzzy(newPos.x, newPos.y, mapElement->base_height, rideIndex); + + return nextTrack == NULL; +} + static void chairlift_paint_station_ne_sw(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { const rct_xy16 pos = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; @@ -319,38 +358,11 @@ static void chairlift_paint_station_ne_sw(uint8 rideIndex, uint8 trackSequence, rct_ride * ride = get_ride(rideIndex); uint32 imageId; - bool isStart = false; - bool isEnd = false; - - if (trackType == TRACK_ELEM_BEGIN_STATION || trackType == TRACK_ELEM_END_STATION) { - rct_xy16 delta = TileDirectionDelta[map_element_get_direction(mapElement)]; - - rct_xy16 newPos; - if (trackType == TRACK_ELEM_BEGIN_STATION) { - newPos = (rct_xy16) { - .x = pos.x - delta.x, - .y = pos.y - delta.y, - }; - } else { - newPos = (rct_xy16) { - .x = pos.x + delta.x, - .y = pos.y + delta.y, - }; - } - - rct_map_element * nextTrack = map_get_track_element_at_from_ride_fuzzy(newPos.x, newPos.y, mapElement->base_height, rideIndex); - if (nextTrack == NULL && trackType == TRACK_ELEM_BEGIN_STATION) { - isStart = true; - } - - if (nextTrack == NULL && trackType == TRACK_ELEM_END_STATION) { - isEnd = true; - } - } + bool isStart = paint_utils_is_first_track(rideIndex, mapElement, pos, trackType);; + bool isEnd = paint_utils_is_last_track(rideIndex, mapElement, pos, trackType); const rct_ride_entrance_definition * entranceStyle = &RideEntranceDefinitions[ride->entrance_style]; - wooden_a_supports_paint_setup(0, 0, height, RCT2_GLOBAL(0x00F441A0, uint32), NULL); if (!isStart && !isEnd) { @@ -374,7 +386,7 @@ static void chairlift_paint_station_ne_sw(uint8 rideIndex, uint8 trackSequence, } if (RCT2_GLOBAL(0x0141E9DB, uint8) & 3) { - hasFence = paint_util_has_fence(EDGE_NW, pos, mapElement, ride, get_current_rotation()); + hasFence = paint_util_has_fence(EDGE_SE, pos, mapElement, ride, get_current_rotation()); if (hasFence) { imageId = SPR_METAL_FENCE_SE | RCT2_GLOBAL(0x00F44198, uint32); sub_98197C(imageId, 0, 0, 32, 1, 27, height, 0, 30, height + 2, get_current_rotation()); @@ -420,10 +432,93 @@ static void chairlift_paint_station_ne_sw(uint8 rideIndex, uint8 trackSequence, paint_util_set_support_height(height + 32, 0x20); } +static void chairlift_paint_station_se_nw(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) +{ + const rct_xy16 pos = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; + uint8 trackType = mapElement->properties.track.type; + rct_ride * ride = get_ride(rideIndex); + uint32 imageId; + + bool isStart = paint_utils_is_first_track(rideIndex, mapElement, pos, trackType);; + bool isEnd = paint_utils_is_last_track(rideIndex, mapElement, pos, trackType); + + const rct_ride_entrance_definition * entranceStyle = &RideEntranceDefinitions[ride->entrance_style]; + + wooden_a_supports_paint_setup(1, 0, height, RCT2_GLOBAL(0x00F441A0, uint32), NULL); + + if (!isStart && !isEnd) { + imageId = ((direction == 1) ? SPR_20503 : SPR_20505) | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + } + + imageId = SPR_METAL_FLOOR | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); + + bool hasFence = paint_util_has_fence(EDGE_NE, pos, mapElement, ride, get_current_rotation()); + if (hasFence) { + imageId = SPR_METAL_FENCE_NE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 1, 32, 7, height, 2, 0, height + 2, get_current_rotation()); + } + paint_util_draw_station_covers(EDGE_NE, hasFence, entranceStyle, direction, height); + + if ((direction == 1 && isStart) || (direction == 3 && isEnd)) { + imageId = SPR_METAL_FENCE_NW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 28, 1, 7, height, 2, 2, height + 4, get_current_rotation()); + } + + if (RCT2_GLOBAL(0x0141E9DB, uint8) & 3) { + hasFence = paint_util_has_fence(EDGE_SW, pos, mapElement, ride, get_current_rotation()); + if (hasFence) { + imageId = SPR_METAL_FENCE_SW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 1, 32, 27, height, 30, 0, height + 2, get_current_rotation()); + } + paint_util_draw_station_covers(EDGE_SW, hasFence, entranceStyle, direction, height); + } + + bool drawRightColumn = true; + bool drawLeftColumn = true; + if ((direction == 1 && isStart) || (direction == 3 && isEnd)) { + imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + + imageId = SPR_CHAIRLIFT_STATION_END_CAP_SE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + + drawLeftColumn = false; + } else if ((direction == 3 && isStart) || (direction == 1 && isEnd)) { + imageId = SPR_METAL_FENCE_SE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 28, 1, 27, height, 2, 30, height + 4, get_current_rotation()); + + imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + + imageId = SPR_CHAIRLIFT_STATION_END_CAP_NW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + + drawRightColumn = false; + } + + if (drawLeftColumn) { + imageId = SPR_CHAIRLIFT_STATION_COLUMN_SE_NW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 16, 0, 1, 1, 7, height + 2, 16, 1, height + 2, get_current_rotation()); + } + + if (drawRightColumn) { + imageId = SPR_CHAIRLIFT_STATION_COLUMN_SE_NW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 16, 30, 1, 1, 7, height + 2, 16, 1, height + 2, get_current_rotation()); // bound offset x is wrong? + + paint_util_push_tunnel_right(height, TUNNEL_FLAT); + } + + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_support_height(height + 32, 0x20); +} + +/** rct2: 0x00744068 */ static void chairlift_paint_station(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { if (direction % 2) { - + chairlift_paint_station_se_nw(rideIndex, trackSequence, direction, height, mapElement); } else { chairlift_paint_station_ne_sw(rideIndex, trackSequence, direction, height, mapElement); } From 45df10dfd4de48e19e88a292a8a2d8f6f42b264e Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Sat, 7 May 2016 16:58:40 +0200 Subject: [PATCH 6/8] Fix abstract station covers --- src/ride/transport/chairlift.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ride/transport/chairlift.c b/src/ride/transport/chairlift.c index 9e6e4f61fc..6cb0c26bb9 100644 --- a/src/ride/transport/chairlift.c +++ b/src/ride/transport/chairlift.c @@ -301,13 +301,13 @@ static bool paint_util_draw_station_covers(EDGE edge, bool hasFence, rct_ride_en } if (baseImageId & 0x40000000) { - imageId = baseImageId & 0xBFFFFFFF + imageOffset; + imageId = (baseImageId & 0xBFFFFFFF) + imageOffset; sub_98197C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation()); uint32 edi = RCT2_GLOBAL(0x00F44198, uint32) & (0b11111 << 19); // weird jump - imageId = baseImageId | edi + 0x3800000 + imageOffset + 12; + imageId = (baseImageId | edi) + 0x3800000 + imageOffset + 12; sub_98199C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation()); return true; } From a32aad2274980d4889e11f9ca1b0417317e47dfd Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 18 May 2016 23:28:13 +0200 Subject: [PATCH 7/8] Rebase onto develop and fix indentation --- src/paint/map_element/map_element.h | 4 + src/ride/track_paint.h | 6 + src/ride/transport/chairlift.c | 1001 +++++++++++---------------- 3 files changed, 411 insertions(+), 600 deletions(-) diff --git a/src/paint/map_element/map_element.h b/src/paint/map_element/map_element.h index 0e13cf8d72..d053b2001f 100644 --- a/src/paint/map_element/map_element.h +++ b/src/paint/map_element/map_element.h @@ -46,11 +46,15 @@ enum }; extern const int SEGMENTS_ALL; +extern const uint16 segment_offsets[9]; enum { TUNNEL_0 = 0, TUNNEL_6 = 6, + TUNNEL_7 = 7, + TUNNEL_8 = 8, + TUNNEL_14 = 0x0E }; void paint_util_push_tunnel_left(uint16 height, uint8 type); diff --git a/src/ride/track_paint.h b/src/ride/track_paint.h index a158dad197..ace39091dd 100644 --- a/src/ride/track_paint.h +++ b/src/ride/track_paint.h @@ -32,6 +32,12 @@ extern const uint8 track_map_4x4[][16]; extern const uint8 edges_4x4[]; enum { + SPR_FLOOR_METAL = 14567, + SPR_FENCE_METAL_NE = 14568, + SPR_FENCE_METAL_SE = 14569, + SPR_FENCE_METAL_SW = 14570, + SPR_FENCE_METAL_NW = 14571, + SPR_FLOOR_CORK_SE_SW = 22134, SPR_FLOOR_CORK_SW = 22135, SPR_FLOOR_CORK_SE = 22136, diff --git a/src/ride/transport/chairlift.c b/src/ride/transport/chairlift.c index 6cb0c26bb9..7dc8650939 100644 --- a/src/ride/transport/chairlift.c +++ b/src/ride/transport/chairlift.c @@ -25,784 +25,585 @@ enum { - SPR_METAL_FLOOR = 14567, - SPR_METAL_FENCE_NE = 14568, - SPR_METAL_FENCE_SE = 14569, - SPR_METAL_FENCE_SW = 14570, - SPR_METAL_FENCE_NW = 14571 -}; - -enum -{ - SPR_CHAIRLIFT_CABLE_FLAT_SW_NE = 20500, - SPR_CHAIRLIFT_CABLE_FLAT_SE_NW, - SPR_20502, - SPR_20503, - SPR_20504, - SPR_20505, - SPR_CHAIRLIFT_STATION_COLUMN_NE_SW, - SPR_CHAIRLIFT_STATION_COLUMN_SE_NW, - SPR_20508, - SPR_20509, - SPR_20510, - SPR_20511, - SPR_20512, - SPR_20513, - SPR_20514, - SPR_20515, - SPR_CHAIRLIFT_CABLE_UP_SW_NE, - SPR_CHAIRLIFT_CABLE_UP_NW_SE, - SPR_CHAIRLIFT_CABLE_UP_NE_SW, - SPR_CHAIRLIFT_CABLE_UP_SE_NW, - SPR_20520, - SPR_20521, - SPR_20522, - SPR_20523, - SPR_20524, - SPR_20525, - SPR_20526, - SPR_20527, - SPR_CHAIRLIFT_CORNER_NW_SW, - SPR_CHAIRLIFT_CORNER_NW_NE, - SPR_CHAIRLIFT_CORNER_SE_NE, - SPR_CHAIRLIFT_CORNER_SW_SE, - SPR_20532, - SPR_20533, - SPR_20534, - SPR_20535, - SPR_20536, - SPR_20537, - SPR_20538, - SPR_20539, - SPR_CHAIRLIFT_BULLWHEEL_FRAME_1, - SPR_CHAIRLIFT_BULLWHEEL_FRAME_2, - SPR_CHAIRLIFT_BULLWHEEL_FRAME_3, - SPR_CHAIRLIFT_BULLWHEEL_FRAME_4, - SPR_CHAIRLIFT_STATION_END_CAP_NE, - SPR_CHAIRLIFT_STATION_END_CAP_SE, - SPR_CHAIRLIFT_STATION_END_CAP_SW, - SPR_CHAIRLIFT_STATION_END_CAP_NW, + SPR_CHAIRLIFT_CABLE_FLAT_SW_NE = 20500, + SPR_CHAIRLIFT_CABLE_FLAT_SE_NW, + SPR_20502, + SPR_20503, + SPR_20504, + SPR_20505, + SPR_CHAIRLIFT_STATION_COLUMN_NE_SW, + SPR_CHAIRLIFT_STATION_COLUMN_SE_NW, + SPR_20508, + SPR_20509, + SPR_20510, + SPR_20511, + SPR_20512, + SPR_20513, + SPR_20514, + SPR_20515, + SPR_CHAIRLIFT_CABLE_UP_SW_NE, + SPR_CHAIRLIFT_CABLE_UP_NW_SE, + SPR_CHAIRLIFT_CABLE_UP_NE_SW, + SPR_CHAIRLIFT_CABLE_UP_SE_NW, + SPR_20520, + SPR_20521, + SPR_20522, + SPR_20523, + SPR_20524, + SPR_20525, + SPR_20526, + SPR_20527, + SPR_CHAIRLIFT_CORNER_NW_SW, + SPR_CHAIRLIFT_CORNER_NW_NE, + SPR_CHAIRLIFT_CORNER_SE_NE, + SPR_CHAIRLIFT_CORNER_SW_SE, + SPR_20532, + SPR_20533, + SPR_20534, + SPR_20535, + SPR_20536, + SPR_20537, + SPR_20538, + SPR_20539, + SPR_CHAIRLIFT_BULLWHEEL_FRAME_1, + SPR_CHAIRLIFT_BULLWHEEL_FRAME_2, + SPR_CHAIRLIFT_BULLWHEEL_FRAME_3, + SPR_CHAIRLIFT_BULLWHEEL_FRAME_4, + SPR_CHAIRLIFT_STATION_END_CAP_NE, + SPR_CHAIRLIFT_STATION_END_CAP_SE, + SPR_CHAIRLIFT_STATION_END_CAP_SW, + SPR_CHAIRLIFT_STATION_END_CAP_NW, } SPR_CHAIRLIFT; const uint32 chairlift_bullwheel_frames[] = { - SPR_CHAIRLIFT_BULLWHEEL_FRAME_1, - SPR_CHAIRLIFT_BULLWHEEL_FRAME_2, - SPR_CHAIRLIFT_BULLWHEEL_FRAME_3, - SPR_CHAIRLIFT_BULLWHEEL_FRAME_4 + SPR_CHAIRLIFT_BULLWHEEL_FRAME_1, + SPR_CHAIRLIFT_BULLWHEEL_FRAME_2, + SPR_CHAIRLIFT_BULLWHEEL_FRAME_3, + SPR_CHAIRLIFT_BULLWHEEL_FRAME_4 }; -enum +static void chairlift_paint_util_draw_supports(int segments, uint16 height) { - SEGMENT_B4 = (1 << 0), - SEGMENT_0 = SEGMENT_B4, - SEGMENT_B8 = (1 << 1), - SEGMENT_1 = SEGMENT_B8, - SEGMENT_BC = (1 << 2), - SEGMENT_2 = SEGMENT_BC, - SEGMENT_C0 = (1 << 3), - SEGMENT_3 = SEGMENT_C0, - SEGMENT_C4 = (1 << 4), - SEGMENT_4 = SEGMENT_C4, - SEGMENT_C8 = (1 << 5), - SEGMENT_5 = SEGMENT_C8, - SEGMENT_CC = (1 << 6), - SEGMENT_6 = SEGMENT_CC, - SEGMENT_D0 = (1 << 7), - SEGMENT_7 = SEGMENT_D0, - SEGMENT_D4 = (1 << 8), - SEGMENT_8 = SEGMENT_D4, -}; + bool success = false; -const int SEGMENTS_ALL = SEGMENT_B4 | SEGMENT_B8 | SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4; + for (int s = 0; s < 9; s++) { + if (!(segments & segment_offsets[s])) { + continue; + } -static void paint_util_set_segment_support_height(int flags, uint16 height, uint8 segment_flags) -{ - for (int s = 0; s < 9; s++) { - if (flags & (1 << s)) { - RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16) = height; - RCT2_GLOBAL(0x0141E9B6 + s * 4, uint8) = segment_flags; - } - } -} + if (metal_a_supports_paint_setup(10, s, 0, height, RCT2_GLOBAL(0x00F4419C, uint32))) { + success = true; + } + } -static void paint_util_set_support_height(uint16 height, uint8 flags) -{ - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) < height) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = flags; - } -} + if (success) { + return; + } -enum -{ - TUNNEL_0, - TUNNEL_FLAT = 6, - TUNNEL_7 = 7, - TUNNEL_UP = 8, - TUNNEL_14 = 0x0E -}; - -static void paint_util_push_tunnel_left(uint16 height, uint8 type) -{ - uint32 eax = 0xFFFF0000 | ((height / 16) & 0xFF) | type << 8; - RCT2_ADDRESS(0x009E3138, uint32)[RCT2_GLOBAL(0x141F56A, uint8) / 2] = eax; - RCT2_GLOBAL(0x141F56A, uint8)++; -} - -static void paint_util_push_tunnel_right(uint16 height, uint8 type) -{ - uint32 eax = 0xFFFF0000 | ((height / 16) & 0xFF) | type << 8; - RCT2_ADDRESS(0x009E30B6, uint32)[RCT2_GLOBAL(0x141F56B, uint8) / 2] = eax; - RCT2_GLOBAL(0x141F56B, uint8)++; -} - -/* rct2: 0x007667AE */ -static rct_xy16 loc_7667AE[] = { - {.x = 0, .y = -1}, - {.x = 1, .y = 0}, - {.x = 0, .y = 1}, - {.x = -1, .y = 0}, -}; - -/* rct2: 0x007667AC */ -static rct_xy16 loc_7667AC[] = { - {.x = -1, .y = 0}, - {.x = 0, .y = -1}, - {.x = 1, .y = 0}, - {.x = 0, .y = 1}, -}; - -typedef enum EDGE -{ - EDGE_NE, - EDGE_SE, - EDGE_SW, - EDGE_NW -} EDGE; - -static bool paint_util_has_fence(EDGE edge, rct_xy16 position, rct_map_element * mapElement, rct_ride * ride, uint8 rotation) -{ - rct_xy16 offset; - switch (edge) { - case EDGE_NE: - offset = loc_7667AC[rotation]; - break; - case EDGE_SE: - offset = loc_7667AC[(rotation + 1) & 3]; - break; - case EDGE_SW: - offset = loc_7667AE[(rotation + 1) & 3]; - break; - case EDGE_NW: - offset = loc_7667AE[rotation]; - break; - }; - - uint16 entranceLoc = - ((position.x / 32) + offset.x) | - (((position.y / 32) + offset.y) << 8); - - uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; - - return (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc); -} - -static void chairlift_paint_util_draw_supports(int supports, uint16 height) -{ - bool success = false; - - for (int s = 0; s < 9; s++) { - if (!(supports & (1 << s))) { - continue; - } - - if (metal_a_supports_paint_setup(10, s, 0, height, RCT2_GLOBAL(0x00F4419C, uint32))) { - success = true; - } - } - - if (success) { - return; - } - - for (int s = 0; s < 9; s++) { - if (!(supports & (1 << s))) { - continue; - } - uint16 temp = RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16); - RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, uint16); - metal_a_supports_paint_setup(10, s, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); - RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16) = temp; - } + for (int s = 0; s < 9; s++) { + if (!(segments & segment_offsets[s])) { + continue; + } + uint16 temp = RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16); + RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, uint16); + metal_a_supports_paint_setup(10, s, 0, height, RCT2_GLOBAL(0x00F4419C, uint32)); + RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16) = temp; + } } rct_map_element * map_get_track_element_at_from_ride_fuzzy(int x, int y, int z, int rideIndex) { - rct_map_element * mapElement = map_get_first_element_at(x >> 5, y >> 5); - do { - if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK) continue; - if (mapElement->properties.track.ride_index != rideIndex) continue; - if (mapElement->base_height != z && mapElement->base_height != z - 1) continue; + rct_map_element * mapElement = map_get_first_element_at(x >> 5, y >> 5); + do { + if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK) continue; + if (mapElement->properties.track.ride_index != rideIndex) continue; + if (mapElement->base_height != z && mapElement->base_height != z - 1) continue; - return mapElement; - } while (!map_element_is_last_for_tile(mapElement++)); + return mapElement; + } while (!map_element_is_last_for_tile(mapElement++)); - return NULL; + return NULL; }; -enum +static bool chairlift_paint_util_is_first_track(uint8 rideIndex, const rct_map_element * mapElement, rct_xy16 pos, uint8 trackType) { - SPR_STATION_COVER_OFFSET_NE_SW_BACK_0 = 0, - SPR_STATION_COVER_OFFSET_NE_SW_BACK_1, - SPR_STATION_COVER_OFFSET_NE_SW_FRONT, - SPR_STATION_COVER_OFFSET_SE_NW_BACK_0, - SPR_STATION_COVER_OFFSET_SE_NW_BACK_1, - SPR_STATION_COVER_OFFSET_SE_NW_FRONT, - SPR_STATION_COVER_OFFSET_HIGH -} SPR_STATION_COVER; + if (mapElement->properties.track.type != TRACK_ELEM_BEGIN_STATION) { + return false; + } -static bool paint_util_draw_station_covers(EDGE edge, bool hasFence, rct_ride_entrance_definition * entranceStyle, uint8 direction, uint16 height) -{ - uint32 imageId; - uint32 baseImageId = entranceStyle->flags; - int imageOffset; - rct_xyz16 offset, bounds, boundsOffset; + rct_xy16 delta = TileDirectionDelta[map_element_get_direction(mapElement)]; + rct_xy16 newPos = { + .x = pos.x - delta.x, + .y = pos.y - delta.y, + }; - offset = (rct_xyz16) {0, 0, height}; - switch (edge) { - case EDGE_NE: - bounds = (rct_xyz16) {1, 30, 0}; - boundsOffset = (rct_xyz16) {0, 1, height + 1}; - imageOffset = hasFence ? SPR_STATION_COVER_OFFSET_SE_NW_BACK_1 : SPR_STATION_COVER_OFFSET_SE_NW_BACK_0; - break; - case EDGE_SE: - bounds = (rct_xyz16) {32, 32, 0}; - boundsOffset = (rct_xyz16) {1, 0, height + 31}; - imageOffset = SPR_STATION_COVER_OFFSET_NE_SW_FRONT; - break; - case EDGE_SW: - bounds = (rct_xyz16) {32, 32, 0}; - boundsOffset = (rct_xyz16) {0, 0, height + 31}; - imageOffset = SPR_STATION_COVER_OFFSET_SE_NW_FRONT; - break; - case EDGE_NW: - bounds = (rct_xyz16) {30, 1, 30}; - boundsOffset = (rct_xyz16) {1, 0, height + 1}; - imageOffset = hasFence ? SPR_STATION_COVER_OFFSET_NE_SW_BACK_1 : SPR_STATION_COVER_OFFSET_NE_SW_BACK_0; - break; - } + rct_map_element * nextTrack = map_get_track_element_at_from_ride_fuzzy(newPos.x, newPos.y, mapElement->base_height, rideIndex); - if (RCT2_GLOBAL(0x00F441A0, uint32) != 0x20000000) { - baseImageId &= 0x7FFFF; - } - - if (baseImageId <= 0x20) { - return false; - } - - if (baseImageId & 0x40000000) { - imageId = (baseImageId & 0xBFFFFFFF) + imageOffset; - sub_98197C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation()); - - uint32 edi = RCT2_GLOBAL(0x00F44198, uint32) & (0b11111 << 19); - - // weird jump - imageId = (baseImageId | edi) + 0x3800000 + imageOffset + 12; - sub_98199C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation()); - return true; - } - - imageId = (baseImageId + imageOffset) | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, offset.x, offset.y, bounds.x, bounds.y, bounds.z, offset.z, boundsOffset.x, boundsOffset.y, boundsOffset.z, get_current_rotation()); - return true; + return nextTrack == NULL; } -bool paint_utils_is_first_track(uint8 rideIndex, const rct_map_element * mapElement, rct_xy16 pos, uint8 trackType) +static bool chairlift_paint_util_is_last_track(uint8 rideIndex, const rct_map_element * mapElement, rct_xy16 pos, uint8 trackType) { - if (mapElement->properties.track.type != TRACK_ELEM_BEGIN_STATION) { - return false; - } + if (mapElement->properties.track.type != TRACK_ELEM_END_STATION) { + return false; + } - rct_xy16 delta = TileDirectionDelta[map_element_get_direction(mapElement)]; - rct_xy16 newPos = { - .x = pos.x - delta.x, - .y = pos.y - delta.y, - }; + rct_xy16 delta = TileDirectionDelta[map_element_get_direction(mapElement)]; + rct_xy16 newPos = { + .x = pos.x + delta.x, + .y = pos.y + delta.y, + }; - rct_map_element * nextTrack = map_get_track_element_at_from_ride_fuzzy(newPos.x, newPos.y, mapElement->base_height, rideIndex); + rct_map_element * nextTrack = map_get_track_element_at_from_ride_fuzzy(newPos.x, newPos.y, mapElement->base_height, rideIndex); - return nextTrack == NULL; -} - -bool paint_utils_is_last_track(uint8 rideIndex, const rct_map_element * mapElement, rct_xy16 pos, uint8 trackType) -{ - if (mapElement->properties.track.type != TRACK_ELEM_END_STATION) { - return false; - } - - rct_xy16 delta = TileDirectionDelta[map_element_get_direction(mapElement)]; - rct_xy16 newPos = { - .x = pos.x + delta.x, - .y = pos.y + delta.y, - }; - - rct_map_element * nextTrack = map_get_track_element_at_from_ride_fuzzy(newPos.x, newPos.y, mapElement->base_height, rideIndex); - - return nextTrack == NULL; + return nextTrack == NULL; } static void chairlift_paint_station_ne_sw(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { - const rct_xy16 pos = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; - uint8 trackType = mapElement->properties.track.type; - rct_ride * ride = get_ride(rideIndex); - uint32 imageId; + const rct_xy16 pos = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; + uint8 trackType = mapElement->properties.track.type; + rct_ride * ride = get_ride(rideIndex); + uint32 imageId; - bool isStart = paint_utils_is_first_track(rideIndex, mapElement, pos, trackType);; - bool isEnd = paint_utils_is_last_track(rideIndex, mapElement, pos, trackType); + bool isStart = chairlift_paint_util_is_first_track(rideIndex, mapElement, pos, trackType);; + bool isEnd = chairlift_paint_util_is_last_track(rideIndex, mapElement, pos, trackType); - const rct_ride_entrance_definition * entranceStyle = &RideEntranceDefinitions[ride->entrance_style]; + const rct_ride_entrance_definition * entranceStyle = &RideEntranceDefinitions[ride->entrance_style]; - wooden_a_supports_paint_setup(0, 0, height, RCT2_GLOBAL(0x00F441A0, uint32), NULL); + wooden_a_supports_paint_setup(0, 0, height, RCT2_GLOBAL(0x00F441A0, uint32), NULL); - if (!isStart && !isEnd) { - imageId = ((direction == 0) ? SPR_20502 : SPR_20504) | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); - } + if (!isStart && !isEnd) { + imageId = ((direction == 0) ? SPR_20502 : SPR_20504) | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + } - imageId = SPR_METAL_FLOOR | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); + imageId = SPR_FLOOR_METAL | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); - bool hasFence = paint_util_has_fence(EDGE_NW, pos, mapElement, ride, get_current_rotation()); - if (hasFence) { - imageId = SPR_METAL_FENCE_NW | RCT2_GLOBAL(0x00F44198, uint32); - sub_98199C(imageId, 0, 0, 32, 1, 7, height, 0, 2, height + 2, get_current_rotation()); - } - paint_util_draw_station_covers(EDGE_NW, hasFence, entranceStyle, direction, height); + bool hasFence = track_paint_util_has_fence(EDGE_NW, pos, mapElement, ride, get_current_rotation()); + if (hasFence) { + imageId = SPR_FENCE_METAL_NW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 32, 1, 7, height, 0, 2, height + 2, get_current_rotation()); + } + track_paint_util_draw_station_covers(EDGE_NW, hasFence, entranceStyle, direction, height); - if ((direction == 2 && isStart) || (direction == 0 && isEnd)) { - imageId = SPR_METAL_FENCE_NE | RCT2_GLOBAL(0x00F44198, uint32); - sub_98199C(imageId, 0, 0, 1, 28, 7, height, 2, 2, height + 4, get_current_rotation()); - } + if ((direction == 2 && isStart) || (direction == 0 && isEnd)) { + imageId = SPR_FENCE_METAL_NE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 1, 28, 7, height, 2, 2, height + 4, get_current_rotation()); + } - if (RCT2_GLOBAL(0x0141E9DB, uint8) & 3) { - hasFence = paint_util_has_fence(EDGE_SE, pos, mapElement, ride, get_current_rotation()); - if (hasFence) { - imageId = SPR_METAL_FENCE_SE | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 32, 1, 27, height, 0, 30, height + 2, get_current_rotation()); - } - paint_util_draw_station_covers(EDGE_SE, hasFence, entranceStyle, direction, height); - } + hasFence = track_paint_util_has_fence(EDGE_SE, pos, mapElement, ride, get_current_rotation()); + if (hasFence) { + imageId = SPR_FENCE_METAL_SE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 1, 27, height, 0, 30, height + 2, get_current_rotation()); + } + track_paint_util_draw_station_covers(EDGE_SE, hasFence, entranceStyle, direction, height); - bool drawFrontColumn = true; - bool drawBackColumn = true; - if ((direction == 0 && isStart) || (direction == 2 && isEnd)) { - imageId = SPR_METAL_FENCE_SW | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 1, 28, 27, height, 30, 2, height + 4, get_current_rotation()); + bool drawFrontColumn = true; + bool drawBackColumn = true; + if ((direction == 0 && isStart) || (direction == 2 && isEnd)) { + imageId = SPR_FENCE_METAL_SW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 1, 28, 27, height, 30, 2, height + 4, get_current_rotation()); - imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); - imageId = SPR_CHAIRLIFT_STATION_END_CAP_NE | RCT2_GLOBAL(0x00F44198, uint32); - sub_98199C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + imageId = SPR_CHAIRLIFT_STATION_END_CAP_NE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); - drawFrontColumn = false; - } else if ((direction == 2 && isStart) || (direction == 0 && isEnd)) { - imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + drawFrontColumn = false; + } else if ((direction == 2 && isStart) || (direction == 0 && isEnd)) { + imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); - imageId = SPR_CHAIRLIFT_STATION_END_CAP_SW | RCT2_GLOBAL(0x00F44198, uint32); - sub_98199C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + imageId = SPR_CHAIRLIFT_STATION_END_CAP_SW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); - drawBackColumn = false; - } + drawBackColumn = false; + } - if (drawBackColumn) { - imageId = SPR_CHAIRLIFT_STATION_COLUMN_NE_SW | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 16, 1, 1, 7, height + 2, 1, 16, height + 2, get_current_rotation()); - } + if (drawBackColumn) { + imageId = SPR_CHAIRLIFT_STATION_COLUMN_NE_SW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 16, 1, 1, 7, height + 2, 1, 16, height + 2, get_current_rotation()); + } - if (drawFrontColumn) { - imageId = SPR_CHAIRLIFT_STATION_COLUMN_NE_SW | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 30, 16, 1, 1, 7, height + 2, 1, 16, height + 2, get_current_rotation()); // bound offset x is wrong? - } + if (drawFrontColumn) { + imageId = SPR_CHAIRLIFT_STATION_COLUMN_NE_SW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 30, 16, 1, 1, 7, height + 2, 1, 16, height + 2, get_current_rotation()); // bound offset x is wrong? + } - paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); - paint_util_push_tunnel_left(height, TUNNEL_FLAT); - paint_util_set_support_height(height + 32, 0x20); + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_push_tunnel_left(height, TUNNEL_6); + paint_util_set_general_support_height(height + 32, 0x20); } static void chairlift_paint_station_se_nw(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { - const rct_xy16 pos = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; - uint8 trackType = mapElement->properties.track.type; - rct_ride * ride = get_ride(rideIndex); - uint32 imageId; + const rct_xy16 pos = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; + uint8 trackType = mapElement->properties.track.type; + rct_ride * ride = get_ride(rideIndex); + uint32 imageId; - bool isStart = paint_utils_is_first_track(rideIndex, mapElement, pos, trackType);; - bool isEnd = paint_utils_is_last_track(rideIndex, mapElement, pos, trackType); + bool isStart = chairlift_paint_util_is_first_track(rideIndex, mapElement, pos, trackType);; + bool isEnd = chairlift_paint_util_is_last_track(rideIndex, mapElement, pos, trackType); - const rct_ride_entrance_definition * entranceStyle = &RideEntranceDefinitions[ride->entrance_style]; + const rct_ride_entrance_definition * entranceStyle = &RideEntranceDefinitions[ride->entrance_style]; - wooden_a_supports_paint_setup(1, 0, height, RCT2_GLOBAL(0x00F441A0, uint32), NULL); + wooden_a_supports_paint_setup(1, 0, height, RCT2_GLOBAL(0x00F441A0, uint32), NULL); - if (!isStart && !isEnd) { - imageId = ((direction == 1) ? SPR_20503 : SPR_20505) | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); - } + if (!isStart && !isEnd) { + imageId = ((direction == 1) ? SPR_20503 : SPR_20505) | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + } - imageId = SPR_METAL_FLOOR | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); + imageId = SPR_FLOOR_METAL | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); - bool hasFence = paint_util_has_fence(EDGE_NE, pos, mapElement, ride, get_current_rotation()); - if (hasFence) { - imageId = SPR_METAL_FENCE_NE | RCT2_GLOBAL(0x00F44198, uint32); - sub_98199C(imageId, 0, 0, 1, 32, 7, height, 2, 0, height + 2, get_current_rotation()); - } - paint_util_draw_station_covers(EDGE_NE, hasFence, entranceStyle, direction, height); + bool hasFence = track_paint_util_has_fence(EDGE_NE, pos, mapElement, ride, get_current_rotation()); + if (hasFence) { + imageId = SPR_FENCE_METAL_NE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 1, 32, 7, height, 2, 0, height + 2, get_current_rotation()); + } + track_paint_util_draw_station_covers(EDGE_NE, hasFence, entranceStyle, direction, height); - if ((direction == 1 && isStart) || (direction == 3 && isEnd)) { - imageId = SPR_METAL_FENCE_NW | RCT2_GLOBAL(0x00F44198, uint32); - sub_98199C(imageId, 0, 0, 28, 1, 7, height, 2, 2, height + 4, get_current_rotation()); - } + if ((direction == 1 && isStart) || (direction == 3 && isEnd)) { + imageId = SPR_FENCE_METAL_NW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 28, 1, 7, height, 2, 2, height + 4, get_current_rotation()); + } - if (RCT2_GLOBAL(0x0141E9DB, uint8) & 3) { - hasFence = paint_util_has_fence(EDGE_SW, pos, mapElement, ride, get_current_rotation()); - if (hasFence) { - imageId = SPR_METAL_FENCE_SW | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 1, 32, 27, height, 30, 0, height + 2, get_current_rotation()); - } - paint_util_draw_station_covers(EDGE_SW, hasFence, entranceStyle, direction, height); - } + hasFence = track_paint_util_has_fence(EDGE_SW, pos, mapElement, ride, get_current_rotation()); + if (hasFence) { + imageId = SPR_FENCE_METAL_SW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 1, 32, 27, height, 30, 0, height + 2, get_current_rotation()); + } + track_paint_util_draw_station_covers(EDGE_SW, hasFence, entranceStyle, direction, height); - bool drawRightColumn = true; - bool drawLeftColumn = true; - if ((direction == 1 && isStart) || (direction == 3 && isEnd)) { - imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + bool drawRightColumn = true; + bool drawLeftColumn = true; + if ((direction == 1 && isStart) || (direction == 3 && isEnd)) { + imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); - imageId = SPR_CHAIRLIFT_STATION_END_CAP_SE | RCT2_GLOBAL(0x00F44198, uint32); - sub_98199C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + imageId = SPR_CHAIRLIFT_STATION_END_CAP_SE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); - drawLeftColumn = false; - } else if ((direction == 3 && isStart) || (direction == 1 && isEnd)) { - imageId = SPR_METAL_FENCE_SE | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 28, 1, 27, height, 2, 30, height + 4, get_current_rotation()); + drawLeftColumn = false; + } else if ((direction == 3 && isStart) || (direction == 1 && isEnd)) { + imageId = SPR_FENCE_METAL_SE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 28, 1, 27, height, 2, 30, height + 4, get_current_rotation()); - imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + imageId = chairlift_bullwheel_frames[ride->chairlift_bullwheel_rotation / 16384] | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); - imageId = SPR_CHAIRLIFT_STATION_END_CAP_NW | RCT2_GLOBAL(0x00F44198, uint32); - sub_98199C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); + imageId = SPR_CHAIRLIFT_STATION_END_CAP_NW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98199C(imageId, 0, 0, 4, 4, 26, height, 14, 14, height + 4, get_current_rotation()); - drawRightColumn = false; - } + drawRightColumn = false; + } - if (drawLeftColumn) { - imageId = SPR_CHAIRLIFT_STATION_COLUMN_SE_NW | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 16, 0, 1, 1, 7, height + 2, 16, 1, height + 2, get_current_rotation()); - } + if (drawLeftColumn) { + imageId = SPR_CHAIRLIFT_STATION_COLUMN_SE_NW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 16, 0, 1, 1, 7, height + 2, 16, 1, height + 2, get_current_rotation()); + } - if (drawRightColumn) { - imageId = SPR_CHAIRLIFT_STATION_COLUMN_SE_NW | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 16, 30, 1, 1, 7, height + 2, 16, 1, height + 2, get_current_rotation()); // bound offset x is wrong? + if (drawRightColumn) { + imageId = SPR_CHAIRLIFT_STATION_COLUMN_SE_NW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 16, 30, 1, 1, 7, height + 2, 16, 1, height + 2, get_current_rotation()); // bound offset x is wrong? - paint_util_push_tunnel_right(height, TUNNEL_FLAT); - } + paint_util_push_tunnel_right(height, TUNNEL_6); + } - paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); - paint_util_set_support_height(height + 32, 0x20); + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 32, 0x20); } /** rct2: 0x00744068 */ static void chairlift_paint_station(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { - if (direction % 2) { - chairlift_paint_station_se_nw(rideIndex, trackSequence, direction, height, mapElement); - } else { - chairlift_paint_station_ne_sw(rideIndex, trackSequence, direction, height, mapElement); - } + if (direction % 2) { + chairlift_paint_station_se_nw(rideIndex, trackSequence, direction, height, mapElement); + } else { + chairlift_paint_station_ne_sw(rideIndex, trackSequence, direction, height, mapElement); + } } static void chairlift_paint_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { - uint32 imageId; - if (direction & 1) { - imageId = SPR_CHAIRLIFT_CABLE_FLAT_SE_NW | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); - paint_util_push_tunnel_right(height, TUNNEL_FLAT); - } else { - imageId = SPR_CHAIRLIFT_CABLE_FLAT_SW_NE | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); - paint_util_push_tunnel_left(height, TUNNEL_FLAT); - } + uint32 imageId; + if (direction & 1) { + imageId = SPR_CHAIRLIFT_CABLE_FLAT_SE_NW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + paint_util_push_tunnel_right(height, TUNNEL_6); + } else { + imageId = SPR_CHAIRLIFT_CABLE_FLAT_SW_NE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + paint_util_push_tunnel_left(height, TUNNEL_6); + } - paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); - paint_util_set_support_height(height + 32, 0x20); + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 32, 0x20); } /** rct2: 0x00743FD8 */ static void chairlift_paint_25_deg_up(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { - uint32 imageId; + uint32 imageId; - switch (direction) { - case 0: - imageId = SPR_CHAIRLIFT_CABLE_UP_SW_NE | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); - paint_util_push_tunnel_left(height - 8, TUNNEL_7); - break; + switch (direction) { + case 0: + imageId = SPR_CHAIRLIFT_CABLE_UP_SW_NE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + paint_util_push_tunnel_left(height - 8, TUNNEL_7); + break; - case 1: - imageId = SPR_CHAIRLIFT_CABLE_UP_NW_SE | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); - paint_util_push_tunnel_right(height + 8, TUNNEL_UP); - break; + case 1: + imageId = SPR_CHAIRLIFT_CABLE_UP_NW_SE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + paint_util_push_tunnel_right(height + 8, TUNNEL_8); + break; - case 2: - imageId = SPR_CHAIRLIFT_CABLE_UP_NE_SW | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); - paint_util_push_tunnel_left(height + 8, TUNNEL_UP); - break; + case 2: + imageId = SPR_CHAIRLIFT_CABLE_UP_NE_SW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + paint_util_push_tunnel_left(height + 8, TUNNEL_8); + break; - case 3: - imageId = SPR_CHAIRLIFT_CABLE_UP_SE_NW | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); - paint_util_push_tunnel_right(height - 8, TUNNEL_7); - break; - } + case 3: + imageId = SPR_CHAIRLIFT_CABLE_UP_SE_NW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + paint_util_push_tunnel_right(height - 8, TUNNEL_7); + break; + } - paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); - paint_util_set_support_height(height + 56, 0x20); + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 56, 0x20); } /** rct2: 0x00743FD8 */ static void chairlift_paint_flat_to_25_deg_up(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { - uint32 imageId; + uint32 imageId; - switch (direction) { - case 0: - imageId = SPR_20508 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + switch (direction) { + case 0: + imageId = SPR_20508 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); - imageId = SPR_20520 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + imageId = SPR_20520 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); - paint_util_push_tunnel_left(height, TUNNEL_FLAT); - break; + paint_util_push_tunnel_left(height, TUNNEL_6); + break; - case 1: - imageId = SPR_20509 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + case 1: + imageId = SPR_20509 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); - imageId = SPR_20521 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + imageId = SPR_20521 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); - paint_util_push_tunnel_right(height, TUNNEL_UP); - break; + paint_util_push_tunnel_right(height, TUNNEL_8); + break; - case 2: - imageId = SPR_20510 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + case 2: + imageId = SPR_20510 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); - imageId = SPR_20522 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + imageId = SPR_20522 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); - paint_util_push_tunnel_left(height, TUNNEL_UP); - break; + paint_util_push_tunnel_left(height, TUNNEL_8); + break; - case 3: - imageId = SPR_20511 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + case 3: + imageId = SPR_20511 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); - imageId = SPR_20523 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + imageId = SPR_20523 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); - paint_util_push_tunnel_right(height, TUNNEL_FLAT); - break; - } + paint_util_push_tunnel_right(height, TUNNEL_6); + break; + } - chairlift_paint_util_draw_supports(SEGMENT_4, height); - paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); - paint_util_set_support_height(height + 48, 0x20); + chairlift_paint_util_draw_supports(SEGMENT_C4, height); + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 48, 0x20); } /** rct2: 0x00743FF8 */ static void chairlift_paint_25_deg_up_to_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { - uint32 imageId; + uint32 imageId; - switch (direction) { - case 0: - imageId = SPR_20512 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + switch (direction) { + case 0: + imageId = SPR_20512 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); - imageId = SPR_20524 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + imageId = SPR_20524 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); - paint_util_push_tunnel_left(height - 8, TUNNEL_FLAT); - break; + paint_util_push_tunnel_left(height - 8, TUNNEL_6); + break; - case 1: - imageId = SPR_20513 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + case 1: + imageId = SPR_20513 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); - imageId = SPR_20525 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + imageId = SPR_20525 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); - paint_util_push_tunnel_right(height + 8, TUNNEL_14); - break; + paint_util_push_tunnel_right(height + 8, TUNNEL_14); + break; - case 2: - imageId = SPR_20514 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); + case 2: + imageId = SPR_20514 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 32, 6, 2, height, 0, 13, height + 28, get_current_rotation()); - imageId = SPR_20526 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + imageId = SPR_20526 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); - paint_util_push_tunnel_left(height + 8, TUNNEL_14); - break; + paint_util_push_tunnel_left(height + 8, TUNNEL_14); + break; - case 3: - imageId = SPR_20515 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); + case 3: + imageId = SPR_20515 | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 6, 32, 2, height, 13, 0, height + 28, get_current_rotation()); - imageId = SPR_20527 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); + imageId = SPR_20527 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 4, 4, 25, height, 14, 14, height + 1, get_current_rotation()); - paint_util_push_tunnel_right(height - 8, TUNNEL_FLAT); - break; + paint_util_push_tunnel_right(height - 8, TUNNEL_6); + break; - } + } - chairlift_paint_util_draw_supports(SEGMENT_4, height); - paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); - paint_util_set_support_height(height + 40, 0x20); + chairlift_paint_util_draw_supports(SEGMENT_C4, height); + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 40, 0x20); } /** rct2: 0x00744008 */ static void chairlift_paint_25_deg_down(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { - chairlift_paint_25_deg_up(rideIndex, trackSequence, (direction + 2) % 4, height, mapElement); + chairlift_paint_25_deg_up(rideIndex, trackSequence, (direction + 2) % 4, height, mapElement); } /** rct2: 0x00744018 */ static void chairlift_paint_flat_to_25_deg_down(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { - chairlift_paint_25_deg_up_to_flat(rideIndex, trackSequence, (direction + 2) % 4, height, mapElement); + chairlift_paint_25_deg_up_to_flat(rideIndex, trackSequence, (direction + 2) % 4, height, mapElement); } /** rct2: 0x00744028 */ static void chairlift_paint_25_deg_down_to_flat(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { - chairlift_paint_flat_to_25_deg_up(rideIndex, trackSequence, (direction + 2) % 4, height, mapElement); + chairlift_paint_flat_to_25_deg_up(rideIndex, trackSequence, (direction + 2) % 4, height, mapElement); } /** rct2: 0x00744038 */ static void chairlift_paint_left_quarter_turn_1_tile(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { - uint32 imageId; + uint32 imageId; - switch (direction) { - case 0: - imageId = SPR_CHAIRLIFT_CORNER_NW_SW | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 16, 16, 2, height, 16, 0, height + 28, get_current_rotation()); + switch (direction) { + case 0: + imageId = SPR_CHAIRLIFT_CORNER_NW_SW | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 16, 16, 2, height, 16, 0, height + 28, get_current_rotation()); - imageId = SPR_20532 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 2, 2, 27, height, 16, 4, height, get_current_rotation()); + imageId = SPR_20532 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 16, 4, height, get_current_rotation()); - imageId = SPR_20536 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 2, 2, 27, height, 28, 4, height, get_current_rotation()); + imageId = SPR_20536 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 28, 4, height, get_current_rotation()); - paint_util_push_tunnel_left(height, TUNNEL_FLAT); - chairlift_paint_util_draw_supports(SEGMENT_5 | SEGMENT_7, height); - break; + paint_util_push_tunnel_left(height, TUNNEL_6); + break; - case 1: - imageId = SPR_CHAIRLIFT_CORNER_NW_NE | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 16, 16, 2, height, 0, 0, height + 28, get_current_rotation()); + case 1: + imageId = SPR_CHAIRLIFT_CORNER_NW_NE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 16, 16, 2, height, 0, 0, height + 28, get_current_rotation()); - imageId = SPR_20533 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 2, 2, 27, height, 16, 4, height, get_current_rotation()); + imageId = SPR_20533 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 16, 4, height, get_current_rotation()); - imageId = SPR_20537 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 2, 2, 27, height, 4, 16, height, get_current_rotation()); + imageId = SPR_20537 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 4, 16, height, get_current_rotation()); + break; - chairlift_paint_util_draw_supports(SEGMENT_5 | SEGMENT_6, height); - break; + case 2: + imageId = SPR_CHAIRLIFT_CORNER_SE_NE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 16, 16, 2, height, 0, 16, height + 28, get_current_rotation()); - case 2: - imageId = SPR_CHAIRLIFT_CORNER_SE_NE | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 16, 16, 2, height, 0, 16, height + 28, get_current_rotation()); + imageId = SPR_20534 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 4, 16, height, get_current_rotation()); - imageId = SPR_20534 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 2, 2, 27, height, 4, 16, height, get_current_rotation()); + imageId = SPR_20538 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 16, 28, height, get_current_rotation()); - imageId = SPR_20538 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 2, 2, 27, height, 16, 28, height, get_current_rotation()); + paint_util_push_tunnel_right(height, TUNNEL_6); + break; - paint_util_push_tunnel_right(height, TUNNEL_FLAT); - chairlift_paint_util_draw_supports(SEGMENT_6 | SEGMENT_8, height); - break; + case 3: + imageId = SPR_CHAIRLIFT_CORNER_SW_SE | RCT2_GLOBAL(0x00F44198, uint32); + sub_98197C(imageId, 0, 0, 16, 16, 2, height, 16, 16, height + 28, get_current_rotation()); - case 3: - imageId = SPR_CHAIRLIFT_CORNER_SW_SE | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(imageId, 0, 0, 16, 16, 2, height, 16, 16, height + 28, get_current_rotation()); + imageId = SPR_20535 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 28, 16, height, get_current_rotation()); - imageId = SPR_20535 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 2, 2, 27, height, 28, 16, height, get_current_rotation()); + imageId = SPR_20539 | RCT2_GLOBAL(0x00F4419C, uint32); + sub_98197C(imageId, 0, 0, 2, 2, 27, height, 16, 28, height, get_current_rotation()); - imageId = SPR_20539 | RCT2_GLOBAL(0x00F4419C, uint32); - sub_98197C(imageId, 0, 0, 2, 2, 27, height, 16, 28, height, get_current_rotation()); + paint_util_push_tunnel_left(height, TUNNEL_6); + paint_util_push_tunnel_right(height, TUNNEL_6); + break; + } - paint_util_push_tunnel_left(height, TUNNEL_FLAT); - paint_util_push_tunnel_right(height, TUNNEL_FLAT); - chairlift_paint_util_draw_supports(SEGMENT_7 | SEGMENT_8, height); - break; - } + chairlift_paint_util_draw_supports(paint_util_rotate_segments(SEGMENT_C8 | SEGMENT_D0, direction), height); - paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); - paint_util_set_support_height(height + 32, 0x20); + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 32, 0x20); } /** rct2: 0x00744048 */ static void chairlift_paint_right_quarter_turn_1_tile(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element * mapElement) { - chairlift_paint_left_quarter_turn_1_tile(rideIndex, trackSequence, (direction + 3) % 4, height, mapElement); + chairlift_paint_left_quarter_turn_1_tile(rideIndex, trackSequence, (direction + 3) % 4, height, mapElement); } /* 0x008AAA0C */ TRACK_PAINT_FUNCTION get_track_paint_function_chairlift(int trackType, int direction) { - switch (trackType) { - case TRACK_ELEM_BEGIN_STATION: - case TRACK_ELEM_MIDDLE_STATION: - case TRACK_ELEM_END_STATION: - return chairlift_paint_station; + switch (trackType) { + case TRACK_ELEM_BEGIN_STATION: + case TRACK_ELEM_MIDDLE_STATION: + case TRACK_ELEM_END_STATION: + return chairlift_paint_station; - case TRACK_ELEM_FLAT: - return chairlift_paint_flat; + case TRACK_ELEM_FLAT: + return chairlift_paint_flat; - case TRACK_ELEM_FLAT_TO_25_DEG_UP: - return chairlift_paint_flat_to_25_deg_up; - case TRACK_ELEM_25_DEG_UP: - return chairlift_paint_25_deg_up; - case TRACK_ELEM_25_DEG_UP_TO_FLAT: - return chairlift_paint_25_deg_up_to_flat; + case TRACK_ELEM_FLAT_TO_25_DEG_UP: + return chairlift_paint_flat_to_25_deg_up; + case TRACK_ELEM_25_DEG_UP: + return chairlift_paint_25_deg_up; + case TRACK_ELEM_25_DEG_UP_TO_FLAT: + return chairlift_paint_25_deg_up_to_flat; - case TRACK_ELEM_FLAT_TO_25_DEG_DOWN: - return chairlift_paint_flat_to_25_deg_down; - case TRACK_ELEM_25_DEG_DOWN: - return chairlift_paint_25_deg_down; - case TRACK_ELEM_25_DEG_DOWN_TO_FLAT: - return chairlift_paint_25_deg_down_to_flat; + case TRACK_ELEM_FLAT_TO_25_DEG_DOWN: + return chairlift_paint_flat_to_25_deg_down; + case TRACK_ELEM_25_DEG_DOWN: + return chairlift_paint_25_deg_down; + case TRACK_ELEM_25_DEG_DOWN_TO_FLAT: + return chairlift_paint_25_deg_down_to_flat; - case TRACK_ELEM_LEFT_QUARTER_TURN_1_TILE: - return chairlift_paint_left_quarter_turn_1_tile; - case TRACK_ELEM_RIGHT_QUARTER_TURN_1_TILE: - return chairlift_paint_right_quarter_turn_1_tile; - } + case TRACK_ELEM_LEFT_QUARTER_TURN_1_TILE: + return chairlift_paint_left_quarter_turn_1_tile; + case TRACK_ELEM_RIGHT_QUARTER_TURN_1_TILE: + return chairlift_paint_right_quarter_turn_1_tile; + } - return NULL; + return NULL; } From a550e2e3b13c1f1bd7d9e17d61ba96ac70f71939 Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Wed, 18 May 2016 23:31:37 +0200 Subject: [PATCH 8/8] Apply suggested corrections --- src/ride/track_paint.c | 2 +- src/ride/transport/chairlift.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ride/track_paint.c b/src/ride/track_paint.c index 5e5d46ab4c..183c92b60b 100644 --- a/src/ride/track_paint.c +++ b/src/ride/track_paint.c @@ -152,7 +152,7 @@ bool track_paint_util_has_fence(enum edge edge, rct_xy16 position, rct_map_eleme ((position.x / 32) + offset.x) | (((position.y / 32) + offset.y) << 8); - uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; + int entranceId = map_get_station(mapElement); return (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc); } diff --git a/src/ride/transport/chairlift.c b/src/ride/transport/chairlift.c index 7dc8650939..f985764cb0 100644 --- a/src/ride/transport/chairlift.c +++ b/src/ride/transport/chairlift.c @@ -111,9 +111,13 @@ static void chairlift_paint_util_draw_supports(int segments, uint16 height) } } -rct_map_element * map_get_track_element_at_from_ride_fuzzy(int x, int y, int z, int rideIndex) +rct_map_element * chairlift_paint_util_map_get_track_element_at_from_ride_fuzzy(int x, int y, int z, int rideIndex) { rct_map_element * mapElement = map_get_first_element_at(x >> 5, y >> 5); + if (mapElement == NULL) { + return NULL; + } + do { if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK) continue; if (mapElement->properties.track.ride_index != rideIndex) continue; @@ -137,7 +141,7 @@ static bool chairlift_paint_util_is_first_track(uint8 rideIndex, const rct_map_e .y = pos.y - delta.y, }; - rct_map_element * nextTrack = map_get_track_element_at_from_ride_fuzzy(newPos.x, newPos.y, mapElement->base_height, rideIndex); + rct_map_element * nextTrack = chairlift_paint_util_map_get_track_element_at_from_ride_fuzzy(newPos.x, newPos.y, mapElement->base_height, rideIndex); return nextTrack == NULL; } @@ -154,7 +158,7 @@ static bool chairlift_paint_util_is_last_track(uint8 rideIndex, const rct_map_el .y = pos.y + delta.y, }; - rct_map_element * nextTrack = map_get_track_element_at_from_ride_fuzzy(newPos.x, newPos.y, mapElement->base_height, rideIndex); + rct_map_element * nextTrack = chairlift_paint_util_map_get_track_element_at_from_ride_fuzzy(newPos.x, newPos.y, mapElement->base_height, rideIndex); return nextTrack == NULL; }