From 3ce979504ada2ab420868218b01222fe4007f1c9 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 21 Mar 2015 12:26:28 +0000 Subject: [PATCH] Small tidy up of vehicles related to using in pairs --- src/peep/peep.c | 18 +++++++++--------- src/ride/vehicle.c | 5 +++++ src/ride/vehicle.h | 10 +++++----- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/peep/peep.c b/src/peep/peep.c index f1a77835a8..327c3f7aa7 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -883,7 +883,7 @@ static void peep_choose_seat_from_car(rct_peep* peep, rct_ride* ride, rct_vehicl ride->mode == RIDE_MODE_BACKWARD_ROTATION){ chosen_seat = (((~vehicle->var_1F + 1) >> 3) & 0xF) * 2; - if (vehicle->var_B4 & 1){ + if (vehicle->next_free_seat & 1){ chosen_seat++; } } @@ -1014,17 +1014,17 @@ static void peep_update_ride_sub_state_0(rct_peep* peep){ i++){ vehicle = GET_VEHICLE(vehicle_id); - uint8 al = vehicle->num_seats; - if (al & 0x80){ - al &= ~0x80; - if (vehicle->var_B4 & 1){ + uint8 num_seats = vehicle->num_seats; + if (vehicle_is_used_in_pairs(vehicle)){ + num_seats &= VEHICLE_SEAT_NUM_MASK; + if (vehicle->next_free_seat & 1){ peep->current_car = i; peep_choose_seat_from_car(peep, ride, vehicle); peep_go_to_ride_entrance(peep, ride); return; } } - if (al == vehicle->next_free_seat) + if (num_seats == vehicle->next_free_seat) continue; if (ride->mode == RIDE_MODE_FORWARD_ROTATION || @@ -1481,7 +1481,7 @@ static void peep_update_ride_sub_state_2(rct_peep* peep){ } } - if (!(vehicle->num_seats & 0x80)){ + if (!vehicle_is_used_in_pairs(vehicle)){ peep_update_ride_sub_state_2_enter_ride(peep, ride); return; } @@ -1489,7 +1489,7 @@ static void peep_update_ride_sub_state_2(rct_peep* peep){ if (ride->mode == RIDE_MODE_FORWARD_ROTATION || ride->mode == RIDE_MODE_BACKWARD_ROTATION){ if (peep->current_seat & 1 || - !(vehicle->var_B4 & 1)){ + !(vehicle->next_free_seat & 1)){ peep_update_ride_sub_state_2_enter_ride(peep, ride); return; } @@ -1534,7 +1534,7 @@ static void peep_update_ride_sub_state_5(rct_peep* peep){ return; } - if (vehicle->num_seats & 0x80){ + if (vehicle_is_used_in_pairs(vehicle)){ rct_peep* seated_peep = GET_PEEP(vehicle->peep[peep->current_seat ^ 1]); if (seated_peep->sub_state != 5) return; diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 6894c4fe9a..7d3070fe8b 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -632,4 +632,9 @@ rct_vehicle *vehicle_get_head(rct_vehicle *vehicle) } return vehicle; +} + +int vehicle_is_used_in_pairs(rct_vehicle *vehicle) +{ + return vehicle->num_seats & VEHICLE_SEAT_PAIR_FLAG; } \ No newline at end of file diff --git a/src/ride/vehicle.h b/src/ride/vehicle.h index 7af0aa24db..4121b22570 100644 --- a/src/ride/vehicle.h +++ b/src/ride/vehicle.h @@ -71,10 +71,7 @@ typedef struct { uint8 peep_tshirt_colours[32]; // 0x92 uint8 num_seats; // 0xB2 uint8 num_peeps; // 0xB3 - union{ - uint8 var_B4; // When Forward/Backward rotation this variable is used differently - uint8 next_free_seat; // 0xB4 - }; + uint8 next_free_seat; // 0xB4 uint8 pad_B5[0x06]; uint8 sound1_id; // 0xBB uint8 sound1_volume; // 0xBC @@ -129,13 +126,16 @@ enum { VEHICLE_STATUS_STOPPED_BY_BLOCK_BRAKES }; +#define VEHICLE_SEAT_PAIR_FLAG 0x80 +#define VEHICLE_SEAT_NUM_MASK 0x7F + void vehicle_update_all(); int sub_6BC2F3(rct_vehicle* vehicle); void sub_6BB9FF(rct_vehicle* vehicle); void vehicle_sounds_update(); void vehicle_get_g_forces(rct_vehicle *vehicle, int *verticalG, int *lateralG); void vehicle_set_map_toolbar(rct_vehicle *vehicle); - +int vehicle_is_used_in_pairs(rct_vehicle *vehicle); rct_vehicle *vehicle_get_head(rct_vehicle *vehicle); /** Helper macro until rides are stored in this module. */