From 930bdc16693b17362afe4ba27269f2516fa8c3b3 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Wed, 28 Oct 2015 19:57:02 +0000 Subject: [PATCH] Make suggested changes. Invis huts now correctly remove fence --- src/interface/viewport.c | 8 +- src/ride/track_paint.c | 375 ++++++++++++++++++++++----------------- src/ride/track_paint.h | 4 +- 3 files changed, 216 insertions(+), 171 deletions(-) diff --git a/src/interface/viewport.c b/src/interface/viewport.c index 9ebf407c62..9de5abdec6 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -1419,10 +1419,12 @@ void viewport_track_paint_setup(uint8 direction, int height, rct_map_element *ma RCT2_GLOBAL(0x00F441A4, uint32) = ghost_id; } - TRACK_PAINT_FUNCTION ***trackTypeList = (TRACK_PAINT_FUNCTION***)RideTypeTrackPaintFunctionsOld[ride->type]; + TRACK_PAINT_FUNCTION **trackTypeList = (TRACK_PAINT_FUNCTION**)RideTypeTrackPaintFunctionsOld[ride->type]; if (trackTypeList == NULL) { - trackTypeList = (TRACK_PAINT_FUNCTION***)RideTypeTrackPaintFunctions[ride->type]; - trackTypeList[trackType][direction](rideIndex, trackSequence, direction, height, mapElement); + trackTypeList = (TRACK_PAINT_FUNCTION**)RideTypeTrackPaintFunctions[ride->type]; + + if (trackTypeList[trackType] != NULL) + trackTypeList[trackType][direction](rideIndex, trackSequence, direction, height, mapElement); } else { uint32 *trackDirectionList = (uint32*)trackTypeList[trackType]; diff --git a/src/ride/track_paint.c b/src/ride/track_paint.c index 54b1d6d9cf..c923988399 100644 --- a/src/ride/track_paint.c +++ b/src/ride/track_paint.c @@ -32,152 +32,143 @@ #include "../interface/window.h" #include "track_paint.h" -void dummy_paint_setup_function(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement) {} - -TRACK_PAINT_FUNCTION* dummy_rotation[] = { - dummy_paint_setup_function, - dummy_paint_setup_function, - dummy_paint_setup_function, - dummy_paint_setup_function, -}; - void top_spin_paint_setup_rot_0(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement); void top_spin_paint_setup_rot_1(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement); void top_spin_paint_setup_rot_2(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement); void top_spin_paint_setup_rot_3(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement); /* 0x0076679C */ -TRACK_PAINT_FUNCTION* top_spin_base_functions[] = { +TRACK_PAINT_FUNCTION top_spin_base_functions[] = { top_spin_paint_setup_rot_0, top_spin_paint_setup_rot_1, top_spin_paint_setup_rot_2, top_spin_paint_setup_rot_3, }; -TRACK_PAINT_FUNCTION** top_spin_track_paint_functions[] = { - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, - dummy_rotation, +TRACK_PAINT_FUNCTION* top_spin_track_paint_functions[] = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, top_spin_base_functions // 123 }; @@ -655,12 +646,19 @@ void top_spin_paint_tile_3(uint8 rideIndex, uint8 trackSequence, uint8 direction sub_98199C(0, 7, image_id, 0, height, 32, 1, 0); } - image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); + entranceLoc = + ((x / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].x) | + (((y / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].y) << 8); - RCT2_GLOBAL(0x009DEA52, uint16) = 0; - RCT2_GLOBAL(0x009DEA54, uint16) = 30; - RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; - sub_98197C(0, 7, image_id, 0, height, 1, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { + + image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); + + RCT2_GLOBAL(0x009DEA52, uint16) = 0; + RCT2_GLOBAL(0x009DEA54, uint16) = 30; + RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; + sub_98197C(0, 7, image_id, 0, height, 1, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + } top_spin_paint_vehicle(32, -32, rideIndex, direction, height, mapElement); @@ -696,12 +694,22 @@ void top_spin_paint_tile_5(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA56, uint16) = height; sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); - image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); + sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); + uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; + rct_ride* ride = GET_RIDE(rideIndex); - RCT2_GLOBAL(0x009DEA52, uint16) = 0; - RCT2_GLOBAL(0x009DEA54, uint16) = 30; - RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; - sub_98197C(0, 7, image_id, 0, height, 1, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + uint16 entranceLoc = + ((x / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].x) | + (((y / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].y) << 8); + + if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { + image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); + + RCT2_GLOBAL(0x009DEA52, uint16) = 0; + RCT2_GLOBAL(0x009DEA54, uint16) = 30; + RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; + sub_98197C(0, 7, image_id, 0, height, 1, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + } top_spin_paint_vehicle(0, -32, rideIndex, direction, height, mapElement); @@ -752,13 +760,20 @@ void top_spin_paint_tile_6(uint8 rideIndex, uint8 trackSequence, uint8 direction sub_98199C(0, 7, image_id, 0, height, 1, 32, 0); } - image_id = 22140 | RCT2_GLOBAL(0x00F441A0, uint32); - RCT2_GLOBAL(0x009DEA52, uint16) = 30; - RCT2_GLOBAL(0x009DEA54, uint16) = 2; - RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; + entranceLoc = + ((x / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].x) | + (((y / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].y) << 8); + + if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { + + image_id = 22140 | RCT2_GLOBAL(0x00F441A0, uint32); + RCT2_GLOBAL(0x009DEA52, uint16) = 30; + RCT2_GLOBAL(0x009DEA54, uint16) = 2; + RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; + + sub_98197C(0, 7, image_id, 0, height, 32, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + } - sub_98197C(0,7 , image_id, 0, height, 32, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); - top_spin_paint_vehicle(-32, 32, rideIndex, direction, height, mapElement); RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; @@ -793,19 +808,37 @@ void top_spin_paint_tile_7(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA56, uint16) = height; sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); - image_id = 22140 | RCT2_GLOBAL(0x00F441A0, uint32); + sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); + uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; + rct_ride* ride = GET_RIDE(rideIndex); - RCT2_GLOBAL(0x009DEA52, uint16) = 29; - RCT2_GLOBAL(0x009DEA54, uint16) = 0; - RCT2_GLOBAL(0x009DEA56, uint16) = height + 3; - sub_98197C(0, 7, image_id, 0, height, 28, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); - - image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); + uint16 entranceLoc = + ((x / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].x) | + (((y / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].y) << 8); - RCT2_GLOBAL(0x009DEA52, uint16) = 0; - RCT2_GLOBAL(0x009DEA54, uint16) = 29; - RCT2_GLOBAL(0x009DEA56, uint16) = height + 3; - sub_98197C(0, 7, image_id, 0, height, 1, 28, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { + + image_id = 22140 | RCT2_GLOBAL(0x00F441A0, uint32); + + RCT2_GLOBAL(0x009DEA52, uint16) = 29; + RCT2_GLOBAL(0x009DEA54, uint16) = 0; + RCT2_GLOBAL(0x009DEA56, uint16) = height + 3; + sub_98197C(0, 7, image_id, 0, height, 28, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + } + + entranceLoc = + ((x / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].x) | + (((y / 32) + loc_7667AC[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 3) & 3].y) << 8); + + if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { + + image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); + + RCT2_GLOBAL(0x009DEA52, uint16) = 0; + RCT2_GLOBAL(0x009DEA54, uint16) = 29; + RCT2_GLOBAL(0x009DEA56, uint16) = height + 3; + sub_98197C(0, 7, image_id, 0, height, 1, 28, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + } top_spin_paint_vehicle(-32, -32, rideIndex, direction, height, mapElement); @@ -841,13 +874,23 @@ void top_spin_paint_tile_8(uint8 rideIndex, uint8 trackSequence, uint8 direction RCT2_GLOBAL(0x009DEA56, uint16) = height; sub_98197C(0, 1, image_id, 0, height, 32, 32, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); - image_id = 22140 | RCT2_GLOBAL(0x00F441A0, uint32); - RCT2_GLOBAL(0x009DEA52, uint16) = 30; - RCT2_GLOBAL(0x009DEA54, uint16) = 0; - RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; + sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); + uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; + rct_ride* ride = GET_RIDE(rideIndex); - sub_98197C(0, 7, image_id, 0, height, 32, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + uint16 entranceLoc = + ((x / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].x) | + (((y / 32) + loc_7667AE[(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) + 1) & 3].y) << 8); + if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { + + image_id = 22140 | RCT2_GLOBAL(0x00F441A0, uint32); + RCT2_GLOBAL(0x009DEA52, uint16) = 30; + RCT2_GLOBAL(0x009DEA54, uint16) = 0; + RCT2_GLOBAL(0x009DEA56, uint16) = height + 2; + + sub_98197C(0, 7, image_id, 0, height, 32, 1, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32)); + } top_spin_paint_vehicle(-32, 0, rideIndex, direction, height, mapElement); RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; diff --git a/src/ride/track_paint.h b/src/ride/track_paint.h index 28084a1f5d..f020078c8a 100644 --- a/src/ride/track_paint.h +++ b/src/ride/track_paint.h @@ -3,8 +3,8 @@ #include "../common.h" -typedef void (TRACK_PAINT_FUNCTION)(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement); +typedef void (*TRACK_PAINT_FUNCTION)(uint8 rideIndex, uint8 trackSequence, uint8 direction, int height, rct_map_element* mapElement); -extern TRACK_PAINT_FUNCTION** top_spin_track_paint_functions[]; +extern TRACK_PAINT_FUNCTION* top_spin_track_paint_functions[]; #endif \ No newline at end of file