diff --git a/src/ride/ride.c b/src/ride/ride.c index 40afe2965d..d97a21fc0d 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -5908,6 +5908,7 @@ void increment_turn_count_1_element(rct_ride* ride, uint8 type){ } uint16 value = (*turn_count & TURN_MASK_1_ELEMENT) + 1; *turn_count &= ~TURN_MASK_1_ELEMENT; + if (value > TURN_MASK_1_ELEMENT) value = TURN_MASK_1_ELEMENT; *turn_count |= value; @@ -5928,7 +5929,7 @@ void increment_turn_count_2_elements(rct_ride* ride, uint8 type){ } uint16 value = (*turn_count & TURN_MASK_2_ELEMENTS) + 0x20; *turn_count &= ~TURN_MASK_2_ELEMENTS; - value <<= 5; + if (value > TURN_MASK_2_ELEMENTS) value = TURN_MASK_2_ELEMENTS; *turn_count |= value; @@ -5949,7 +5950,7 @@ void increment_turn_count_3_elements(rct_ride* ride, uint8 type){ } uint16 value = (*turn_count & TURN_MASK_3_ELEMENTS) + 0x100; *turn_count &= ~TURN_MASK_3_ELEMENTS; - value <<= 8; + if (value > TURN_MASK_3_ELEMENTS) value = TURN_MASK_3_ELEMENTS; *turn_count |= value; @@ -5969,7 +5970,7 @@ void increment_turn_count_4_plus_elements(rct_ride* ride, uint8 type){ } uint16 value = (*turn_count & TURN_MASK_4_PLUS_ELEMENTS) + 0x800; *turn_count &= ~TURN_MASK_4_PLUS_ELEMENTS; - value <<= 11; + if (value > TURN_MASK_4_PLUS_ELEMENTS) value = TURN_MASK_4_PLUS_ELEMENTS; *turn_count |= value; diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index f8376f9251..e22f57415d 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -478,14 +478,14 @@ static void vehicle_update_measurements(rct_vehicle *vehicle) rct_ride *ride; ride = GET_RIDE(vehicle->ride); - //RCT2_CALLPROC_X(0x006D6D1F, 0, 0, 0, 0, (int)vehicle, (int)vehicle->ride, 0); + //RCT2_CALLPROC_X(0x006D6D1F, 0, 0, 0, 0, (int)vehicle, (int)vehicle->ride * sizeof(rct_ride), 0); //return; if (vehicle->status == VEHICLE_STATUS_TRAVELLING_07){ ride->lifecycle_flags |= RIDE_LIFECYCLE_TESTED; ride->lifecycle_flags |= RIDE_LIFECYCLE_NO_RAW_STATS; ride->lifecycle_flags &= ~RIDE_LIFECYCLE_TEST_IN_PROGRESS; - vehicle->var_48 &= ~(1 << 1); + vehicle->var_48 &= ~(1 << 5); window_invalidate_by_number(WC_RIDE, vehicle->ride); return; } @@ -742,16 +742,16 @@ static void vehicle_update_measurements(rct_vehicle *vehicle) y = vehicle->y; if (x == SPRITE_LOCATION_NULL){ - ride->testing_flags &= RIDE_TESTING_FLAG_0; + ride->testing_flags &= ~RIDE_TESTING_FLAG_0; return; } rct_map_element* map_element = map_get_surface_element_at(x / 32, y / 32); - if (map_element->base_height * 8 > vehicle->z){ + if (map_element->base_height * 8 <= vehicle->z){ for (;; map_element++){ if (map_element_is_last_for_tile(map_element)){ - ride->testing_flags &= RIDE_TESTING_FLAG_0; + ride->testing_flags &= ~RIDE_TESTING_FLAG_0; return; }