From dbfca8997a447c1369ac3e02ae6903a3416134da Mon Sep 17 00:00:00 2001 From: Marijn van der Werf Date: Tue, 17 May 2016 21:05:45 +0200 Subject: [PATCH] Use support-setting functions in more places --- src/paint/map_element/entrance.c | 32 +++------------------- src/paint/map_element/map_element.c | 42 +++++++++-------------------- src/paint/map_element/map_element.h | 6 ++--- 3 files changed, 19 insertions(+), 61 deletions(-) diff --git a/src/paint/map_element/entrance.c b/src/paint/map_element/entrance.c index 349fa36b27..d3d39bc9c7 100644 --- a/src/paint/map_element/entrance.c +++ b/src/paint/map_element/entrance.c @@ -149,21 +149,10 @@ void ride_entrance_exit_paint(uint8 direction, int height, rct_map_element* map_ } wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); height += is_exit ? 40 : 56; - 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) = 32; - } + paint_util_set_general_support_height(height, 0x20); } /** @@ -246,21 +235,8 @@ void park_entrance_paint(uint8 direction, int height, rct_map_element* map_eleme } wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); - RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9B8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9BC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C4, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9C8, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9CC, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D0, uint16) = 0xFFFF; - RCT2_GLOBAL(0x141E9D4, uint16) = 0xFFFF; - - height += 80; - 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) = 32; - } + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_set_general_support_height(height + 80, 0x20); } /** diff --git a/src/paint/map_element/map_element.c b/src/paint/map_element/map_element.c index afa44b9754..0679189255 100644 --- a/src/paint/map_element/map_element.c +++ b/src/paint/map_element/map_element.c @@ -48,17 +48,8 @@ void map_element_paint_setup(int x, int y) x >= 32 && y >= 32 ) { - RCT2_GLOBAL(0x0141E9B4, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9B8, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9BC, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C0, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C4, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C8, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9CC, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9D0, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9D4, uint32) = 0xFFFF; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = -1; - RCT2_GLOBAL(0x0141E9DA, sint16) = 0; + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_force_set_general_support_height(-1, 0); RCT2_GLOBAL(0x0141E9DC, uint32) = 0xFFFF; sub_68B3FB(x, y); @@ -79,17 +70,8 @@ void sub_68B2B7(int x, int y) x >= 32 && y >= 32 ) { - RCT2_GLOBAL(0x0141E9B4, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9B8, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9BC, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C0, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C4, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9C8, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9CC, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9D0, uint32) = 0xFFFF; - RCT2_GLOBAL(0x0141E9D4, uint32) = 0xFFFF; - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = -1; - RCT2_GLOBAL(0x0141E9DA, uint16) = 0; + paint_util_set_segment_support_height(SEGMENTS_ALL, 0xFFFF, 0); + paint_util_force_set_general_support_height(-1, 0); RCT2_GLOBAL(0x0141E9DC, uint32) = 0xFFFF; RCT2_GLOBAL(0x0141E9DB, uint8) |= 2; @@ -292,19 +274,19 @@ void paint_util_push_tunnel_right(uint16 height, uint8 type) RCT2_GLOBAL(0x141F56B, uint8)++; } -void paint_util_set_general_support_height(uint16 height, uint8 flags) +void paint_util_set_general_support_height(sint16 height, uint8 slope) { - if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, uint16) >= height) { + if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) >= height) { return; } - paint_util_force_set_general_support_height(height, flags); + paint_util_force_set_general_support_height(height, slope); } -void paint_util_force_set_general_support_height(uint16 height, uint8 flags) +void paint_util_force_set_general_support_height(sint16 height, uint8 slope) { - RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, uint16) = height; - RCT2_GLOBAL(0x141E9DA, uint8) = flags; + RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PAINT_TILE_MAX_HEIGHT, sint16) = height; + RCT2_GLOBAL(0x141E9DA, uint8) = slope; } const uint segment_offsets[9] = { @@ -319,13 +301,13 @@ const uint segment_offsets[9] = { SEGMENT_D4 }; -void paint_util_set_segment_support_height(int segments, uint16 height, uint8 flags) +void paint_util_set_segment_support_height(int segments, uint16 height, uint8 slope) { for (int s = 0; s < 9; s++) { if (segments & segment_offsets[s]) { RCT2_GLOBAL(0x0141E9B4 + s * 4, uint16) = height; if (height != 0xFFFF) { - RCT2_GLOBAL(0x0141E9B6 + s * 4, uint8) = flags; + RCT2_GLOBAL(0x0141E9B6 + s * 4, uint8) = slope; } } } diff --git a/src/paint/map_element/map_element.h b/src/paint/map_element/map_element.h index 44e0a9d8ca..810574ba74 100644 --- a/src/paint/map_element/map_element.h +++ b/src/paint/map_element/map_element.h @@ -55,9 +55,9 @@ enum void paint_util_push_tunnel_left(uint16 height, uint8 type); void paint_util_push_tunnel_right(uint16 height, uint8 type); -void paint_util_set_general_support_height(uint16 height, uint8 flags); -void paint_util_force_set_general_support_height(uint16 height, uint8 flags); -void paint_util_set_segment_support_height(int segments, uint16 height, uint8 flags); +void paint_util_set_general_support_height(sint16 height, uint8 slope); +void paint_util_force_set_general_support_height(sint16 height, uint8 slope); +void paint_util_set_segment_support_height(int segments, uint16 height, uint8 slope); void map_element_paint_setup(int x, int y);