Convert some Guest functions to methods

This commit is contained in:
Gymnasiast 2020-03-13 10:50:22 +01:00
parent cf945f7656
commit 3412c47a9e
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
2 changed files with 27 additions and 33 deletions

View File

@ -2508,26 +2508,18 @@ static void peep_choose_seat_from_car(Peep* peep, Ride* ride, Vehicle* vehicle)
* *
* rct2: 0x00691D27 * rct2: 0x00691D27
*/ */
static void peep_go_to_ride_entrance(Guest* peep, Ride* ride) void Guest::GoToRideEntrance(Ride* ride)
{ {
TileCoordsXYZD location = ride_get_entrance_location(ride, peep->current_ride_station); TileCoordsXYZD tileLocation = ride_get_entrance_location(ride, current_ride_station);
if (location.isNull()) if (tileLocation.isNull())
{ {
peep->RemoveFromQueue(); RemoveFromQueue();
return; return;
} }
int32_t x = location.x;
int32_t y = location.y;
uint8_t direction = location.direction; auto location = tileLocation.ToCoordsXYZD().ToTileCentre();
int16_t x_shift = DirectionOffsets[location.direction].x;
x *= 32; int16_t y_shift = DirectionOffsets[location.direction].y;
y *= 32;
x += 16;
y += 16;
int16_t x_shift = DirectionOffsets[direction].x;
int16_t y_shift = DirectionOffsets[direction].y;
uint8_t shift_multiplier = 21; uint8_t shift_multiplier = 21;
rct_ride_entry* rideEntry = get_ride_entry(ride->subtype); rct_ride_entry* rideEntry = get_ride_entry(ride->subtype);
@ -2544,23 +2536,23 @@ static void peep_go_to_ride_entrance(Guest* peep, Ride* ride)
x_shift *= shift_multiplier; x_shift *= shift_multiplier;
y_shift *= shift_multiplier; y_shift *= shift_multiplier;
x += x_shift; location.x += x_shift;
y += y_shift; location.y += y_shift;
peep->destination_x = x; destination_x = location.x;
peep->destination_y = y; destination_y = location.y;
peep->destination_tolerance = 2; destination_tolerance = 2;
peep->SetState(PEEP_STATE_ENTERING_RIDE); SetState(PEEP_STATE_ENTERING_RIDE);
peep->sub_state = PEEP_RIDE_IN_ENTRANCE; sub_state = PEEP_RIDE_IN_ENTRANCE;
peep->rejoin_queue_timeout = 0; rejoin_queue_timeout = 0;
peep->time_on_ride = 0; time_on_ride = 0;
peep->RemoveFromQueue(); RemoveFromQueue();
} }
static bool peep_find_vehicle_to_enter(Guest* peep, Ride* ride, std::vector<uint8_t>& car_array) bool Guest::FindVehicleToEnter(Ride* ride, std::vector<uint8_t>& car_array)
{ {
uint8_t chosen_train = RideStation::NO_TRAIN; uint8_t chosen_train = RideStation::NO_TRAIN;
@ -2584,14 +2576,14 @@ static bool peep_find_vehicle_to_enter(Guest* peep, Ride* ride, std::vector<uint
} }
else else
{ {
chosen_train = ride->stations[peep->current_ride_station].TrainAtStation; chosen_train = ride->stations[current_ride_station].TrainAtStation;
} }
if (chosen_train == RideStation::NO_TRAIN || chosen_train >= MAX_VEHICLES_PER_RIDE) if (chosen_train == RideStation::NO_TRAIN || chosen_train >= MAX_VEHICLES_PER_RIDE)
{ {
return false; return false;
} }
peep->current_train = chosen_train; current_train = chosen_train;
int32_t i = 0; int32_t i = 0;
@ -2608,9 +2600,9 @@ static bool peep_find_vehicle_to_enter(Guest* peep, Ride* ride, std::vector<uint
num_seats &= VEHICLE_SEAT_NUM_MASK; num_seats &= VEHICLE_SEAT_NUM_MASK;
if (vehicle->next_free_seat & 1) if (vehicle->next_free_seat & 1)
{ {
peep->current_car = i; current_car = i;
peep_choose_seat_from_car(peep, ride, vehicle); peep_choose_seat_from_car(this, ride, vehicle);
peep_go_to_ride_entrance(peep, ride); GoToRideEntrance(ride);
return false; return false;
} }
} }
@ -3508,7 +3500,7 @@ void Guest::UpdateRideAtEntrance()
} }
else else
{ {
if (!peep_find_vehicle_to_enter(this, ride, carArray)) if (!FindVehicleToEnter(ride, carArray))
return; return;
} }
@ -3533,7 +3525,7 @@ void Guest::UpdateRideAtEntrance()
Vehicle* vehicle = peep_choose_car_from_ride(this, ride, carArray); Vehicle* vehicle = peep_choose_car_from_ride(this, ride, carArray);
peep_choose_seat_from_car(this, ride, vehicle); peep_choose_seat_from_car(this, ride, vehicle);
} }
peep_go_to_ride_entrance(this, ride); GoToRideEntrance(ride);
} }
/** rct2: 0x00981FD4, 0x00981FD6 */ /** rct2: 0x00981FD4, 0x00981FD6 */

View File

@ -824,6 +824,8 @@ private:
void GivePassingPeepsIceCream(Guest* passingPeep); void GivePassingPeepsIceCream(Guest* passingPeep);
Ride* FindBestRideToGoOn(); Ride* FindBestRideToGoOn();
std::bitset<MAX_RIDES> FindRidesToGoOn(); std::bitset<MAX_RIDES> FindRidesToGoOn();
bool FindVehicleToEnter(Ride* ride, std::vector<uint8_t>& car_array);
void GoToRideEntrance(Ride* ride);
}; };
struct Staff : Peep struct Staff : Peep