From f267af33560a88ebbaedd22c089a618db9c0d045 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Thu, 18 Feb 2016 20:32:04 +0000 Subject: [PATCH] Fix chairlift bullwheel rotation animation. Issue caused by incorrect check for breakdown --- src/rct1.c | 4 ++-- src/ride/ride.c | 39 +++++++++++++++++++-------------------- src/ride/ride.h | 8 +++----- src/ride/vehicle.c | 12 ++++++------ src/world/map.h | 7 ++++++- 5 files changed, 36 insertions(+), 34 deletions(-) diff --git a/src/rct1.c b/src/rct1.c index 4c9b981753..c5310efc29 100644 --- a/src/rct1.c +++ b/src/rct1.c @@ -717,8 +717,8 @@ static void rct1_fix_z() if (ride->var_11F != 255) { ride->var_11F /= 2; } - ride->var_13E /= 2; - ride->var_13F /= 2; + ride->chairlift_bullwheel_z[0] /= 2; + ride->chairlift_bullwheel_z[1] /= 2; } for (int i = 0; i < RCT2_GLOBAL(0x0138B580, uint16); i++) { diff --git a/src/ride/ride.c b/src/ride/ride.c index 6416cb566a..4ff1bc1f52 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -1925,30 +1925,27 @@ static void ride_update(int rideIndex) */ static void ride_chairlift_update(rct_ride *ride) { - int x, y, z, ax, bx, cx; + int x, y, z; if (!(ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK)) return; - if (!(ride->lifecycle_flags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED))) - return; - if (ride->breakdown_reason_pending == 0) + if ((ride->lifecycle_flags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) && + ride->breakdown_reason_pending == 0) return; - ax = ride->operation_option * 2048; - bx = ride->var_148; - cx = bx + ax; - ride->var_148 = cx; - if (bx >> 14 == cx >> 14) + uint16 old_chairlift_bullwheel_rotation = ride->chairlift_bullwheel_rotation >> 14; + ride->chairlift_bullwheel_rotation += ride->speed * 2048; + if (old_chairlift_bullwheel_rotation == ride->speed / 8) return; - x = (ride->var_13A & 0xFF) * 32; - y = (ride->var_13A >> 8) * 32; - z = ride->var_13E * 8; + x = ride->chairlift_bullwheel_location[0].x * 32; + y = ride->chairlift_bullwheel_location[0].y * 32; + z = ride->chairlift_bullwheel_z[0] * 8; map_invalidate_tile_zoom1(x, y, z, z + (4 * 8)); - x = (ride->var_13C & 0xFF) * 32; - y = (ride->var_13C >> 8) * 32; - z = ride->var_13F * 8; + x = ride->chairlift_bullwheel_location[1].x * 32; + y = ride->chairlift_bullwheel_location[1].y * 32; + z = ride->chairlift_bullwheel_z[1] * 8; map_invalidate_tile_zoom1(x, y, z, z + (4 * 8)); } @@ -4099,8 +4096,9 @@ bool ride_check_start_and_end_is_station(rct_xy_element *input, rct_xy_element * if (!(RCT2_GLOBAL(0x0099BA64 + (trackType * 16), uint32) & 0x10)) { return false; } - ride->var_13A = (trackBack.x >> 5) | ((trackBack.y >> 5) << 8); - ride->var_13E = trackBack.element->base_height; + ride->chairlift_bullwheel_location[0].x = trackBack.x >> 5; + ride->chairlift_bullwheel_location[0].y = trackBack.y >> 5; + ride->chairlift_bullwheel_z[0] = trackBack.element->base_height; // Check front of the track track_get_front(input, &trackFront); @@ -4108,8 +4106,9 @@ bool ride_check_start_and_end_is_station(rct_xy_element *input, rct_xy_element * if (!(RCT2_GLOBAL(0x0099BA64 + (trackType * 16), uint32) & 0x10)) { return false; } - ride->var_13C = (trackFront.x >> 5) | ((trackFront.y >> 5) << 8); - ride->var_13F = trackFront.element->base_height; + ride->chairlift_bullwheel_location[1].x = trackFront.x >> 5; + ride->chairlift_bullwheel_location[1].y = trackFront.y >> 5; + ride->chairlift_bullwheel_z[1] = trackFront.element->base_height; return true; } @@ -5843,7 +5842,7 @@ foundRideEntry: ride->excitement = (ride_rating)-1; ride->cur_num_customers = 0; ride->num_customers_timeout = 0; - ride->var_148 = 0; + ride->chairlift_bullwheel_rotation = 0; ride->price = 0; ride->price_secondary = 0; diff --git a/src/ride/ride.h b/src/ride/ride.h index a2d53940a0..bc4647b2e4 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -225,10 +225,8 @@ typedef struct { // Customer count in the last 10 * 960 game ticks (sliding window) uint16 num_customers[10]; // 0x124 money16 price; // 0x138 - sint16 var_13A; - sint16 var_13C; - uint8 var_13E; - uint8 var_13F; + rct_xy8 chairlift_bullwheel_location[2]; // 0x13A + uint8 chairlift_bullwheel_z[2]; // 0x13E union { rating_tuple ratings; // 0x140 struct { @@ -238,7 +236,7 @@ typedef struct { }; }; uint16 value; // 0x146 - uint16 var_148; + uint16 chairlift_bullwheel_rotation; // 0x148 uint8 satisfaction; // 0x14A uint8 satisfaction_time_out; // 0x14B uint8 satisfaction_next; // 0x14C diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index b9ff66e59c..f04c2a1dbf 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -6797,8 +6797,8 @@ loc_6DB41D: regs.cx >>= 5; regs.ah = regs.cl; regs.dx >>= 3; - if (regs.ax != ride->var_13C || regs.dl != ride->var_13F) { - if (regs.ax == ride->var_13A && regs.dl == ride->var_13E) { + if (regs.ax != ride->chairlift_bullwheel_location[1].xy || regs.dl != ride->chairlift_bullwheel_z[1]) { + if (regs.ax == ride->chairlift_bullwheel_location[0].xy && regs.dl == ride->chairlift_bullwheel_z[0]) { vehicle->var_CD = 4; } } @@ -7144,14 +7144,14 @@ bool vehicle_update_track_motion_backwards_get_new_track(rct_vehicle *vehicle, u vehicle->var_CD < 5 ) { sint16 xy = (x >> 5) | ((y >> 5) << 8); - if (ride->var_13C == xy && - ride->var_13F == (z >> 3) + if (ride->chairlift_bullwheel_location[1].xy == xy && + ride->chairlift_bullwheel_z[1] == (z >> 3) ) { vehicle->var_CD = 3; } else if ( - ride->var_13A == xy && - ride->var_13E == (z >> 3) + ride->chairlift_bullwheel_location[0].xy == xy && + ride->chairlift_bullwheel_z[1] == (z >> 3) ) { vehicle->var_CD = 4; } diff --git a/src/world/map.h b/src/world/map.h index b03965ecec..2fe835bca8 100644 --- a/src/world/map.h +++ b/src/world/map.h @@ -233,7 +233,12 @@ enum { #define TILE_UNDEFINED_MAP_ELEMENT (rct_map_element*)-1 typedef struct { - uint8 x, y; + union { + struct { + uint8 x, y; + }; + uint16 xy; + }; } rct_xy8; typedef struct{