mirror of https://github.com/OpenRCT2/OpenRCT2.git
Finished sub_state_0. Still requires some goto fixing.
This commit is contained in:
parent
6855f83b01
commit
98ab1dda24
160
src/peep/peep.c
160
src/peep/peep.c
|
@ -29,6 +29,7 @@
|
|||
#include "../sprites.h"
|
||||
#include "../world/sprite.h"
|
||||
#include "../world/scenery.h"
|
||||
#include "../management/marketing.h"
|
||||
#include "peep.h"
|
||||
#include "staff.h"
|
||||
|
||||
|
@ -850,6 +851,8 @@ static void peep_leaving_ride_sub_state_0(rct_peep* peep){
|
|||
}
|
||||
}
|
||||
|
||||
uint8 no_cars_available = 0xFF;
|
||||
|
||||
if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & RIDE_TYPE_FLAG_13){
|
||||
if (ride->num_riders >= ride->var_0D0)
|
||||
return;
|
||||
|
@ -866,7 +869,7 @@ static void peep_leaving_ride_sub_state_0(rct_peep* peep){
|
|||
for (int i = 0; i < ride->num_vehicles; ++i){
|
||||
rct_vehicle* vehicle = GET_VEHICLE(ride->vehicles[i]);
|
||||
|
||||
if (vehicle->var_B4 >= vehicle->var_B2)
|
||||
if (vehicle->next_free_seat >= vehicle->num_seats)
|
||||
continue;
|
||||
|
||||
if (vehicle->status != VEHICLE_STATUS_WAITING_FOR_PASSENGERS)
|
||||
|
@ -891,14 +894,15 @@ static void peep_leaving_ride_sub_state_0(rct_peep* peep){
|
|||
vehicle = GET_VEHICLE(vehicle->next_vehicle_on_train),
|
||||
i++){
|
||||
|
||||
uint8 al = vehicle->var_B2;
|
||||
uint8 al = vehicle->num_seats;
|
||||
if (al & 0x80){
|
||||
al &= ~0x80;
|
||||
if (vehicle->var_B4 & 1){
|
||||
//goto 0x691CCE
|
||||
peep->current_car = i;
|
||||
//goto 0x691CD1
|
||||
}
|
||||
}
|
||||
if (al == vehicle->var_B4)
|
||||
if (al == vehicle->next_free_seat)
|
||||
continue;
|
||||
|
||||
if (ride->mode == RIDE_MODE_FORWARD_ROTATION ||
|
||||
|
@ -912,9 +916,153 @@ static void peep_leaving_ride_sub_state_0(rct_peep* peep){
|
|||
*edx++ = i;
|
||||
}
|
||||
|
||||
// 0x00691B36
|
||||
no_cars_available = edx - RCT2_ADDRESS(0xF1AD78, uint8);
|
||||
|
||||
if (no_cars_available == 0)return;
|
||||
}
|
||||
//691bc7
|
||||
|
||||
if (ride->status != RIDE_STATUS_OPEN ||
|
||||
ride->var_1CA != 0){
|
||||
if (peep->destination_tolerence == 0){
|
||||
RCT2_CALLPROC_X(0x6966A9, 0, 0, 0, 0, (int)peep, 0, 0);
|
||||
peep_decrement_num_riders(peep);
|
||||
peep->state = PEEP_STATE_FALLING;
|
||||
peep_window_state_update(peep);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN)
|
||||
return;
|
||||
|
||||
if (ride->price != 0){
|
||||
if (!(peep->item_standard_flags & PEEP_ITEM_VOUCHER) ||
|
||||
!(peep->voucher_type == VOUCHER_TYPE_RIDE_FREE) ||
|
||||
!(peep->voucher_arguments == peep->current_ride)){
|
||||
|
||||
if (peep->cash_in_pocket <= 0){
|
||||
peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_SPENT_MONEY, 0xFF);
|
||||
if (peep->destination_tolerence == 0){
|
||||
RCT2_CALLPROC_X(0x6966A9, 0, 0, 0, 0, (int)peep, 0, 0);
|
||||
peep_decrement_num_riders(peep);
|
||||
peep->state = PEEP_STATE_FALLING;
|
||||
peep_window_state_update(peep);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (ride->price > peep->cash_in_pocket){
|
||||
peep_insert_new_thought(peep, 0, peep->current_ride);
|
||||
if (peep->destination_tolerence == 0){
|
||||
RCT2_CALLPROC_X(0x6966A9, 0, 0, 0, 0, (int)peep, 0, 0);
|
||||
peep_decrement_num_riders(peep);
|
||||
peep->state = PEEP_STATE_FALLING;
|
||||
peep_window_state_update(peep);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
uint16 reliability = ride->reliability;
|
||||
if (reliability != 0xFFFF){
|
||||
if (reliability * 2 < ride->price){
|
||||
peep_insert_new_thought(peep, PEEP_THOUGHT_TYPE_BAD_VALUE, peep->current_ride);
|
||||
if (peep->destination_tolerence == 0){
|
||||
RCT2_CALLPROC_X(0x6966A9, 0, 0, 0, 0, (int)peep, 0, 0);
|
||||
peep_decrement_num_riders(peep);
|
||||
peep->state = PEEP_STATE_FALLING;
|
||||
peep_window_state_update(peep);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & RIDE_TYPE_FLAG_13){
|
||||
// goto 691D27
|
||||
}
|
||||
|
||||
uint8 chosen_car = scenario_rand();
|
||||
if (RCT2_ADDRESS(RCT2_ADDRESS_RIDE_FLAGS, uint32)[ride->type * 2] & RIDE_TYPE_FLAG_HAS_G_FORCES
|
||||
&& ((chosen_car & 0xC) != 0xC)){
|
||||
chosen_car = (scenario_rand() & 1) ? 0 : no_cars_available - 1;
|
||||
}
|
||||
else{
|
||||
chosen_car = (chosen_car * (uint16)no_cars_available) >> 8;
|
||||
}
|
||||
|
||||
peep->current_car = RCT2_ADDRESS(0xF1AD78, uint8)[chosen_car];
|
||||
|
||||
rct_vehicle* vehicle = GET_VEHICLE(ride->vehicles[peep->current_train]);
|
||||
|
||||
for (int i = peep->current_car; i > 0; --i){
|
||||
vehicle = GET_VEHICLE(vehicle->next_vehicle_on_train);
|
||||
}
|
||||
|
||||
//691CD1 see above
|
||||
uint8 chosen_seat = vehicle->next_free_seat;
|
||||
|
||||
if (ride->mode == RIDE_MODE_FORWARD_ROTATION ||
|
||||
ride->mode == RIDE_MODE_BACKWARD_ROTATION){
|
||||
|
||||
chosen_seat = (((~vehicle->var_1F + 1) >> 3) & 0xF) * 2;
|
||||
if (vehicle->var_B4 & 1){
|
||||
chosen_seat++;
|
||||
}
|
||||
}
|
||||
peep->current_seat = chosen_seat;
|
||||
vehicle->next_free_seat++;
|
||||
|
||||
vehicle->peep[peep->current_seat] = peep->sprite_index;
|
||||
vehicle->peep_tshirt_colours[peep->current_seat] = peep->tshirt_colour;
|
||||
|
||||
//691D27 see above.
|
||||
int x = ride->entrances[peep->current_ride_station] & 0xFF;
|
||||
int y = ride->entrances[peep->current_ride_station] >> 8;
|
||||
int z = ride->station_heights[peep->current_ride_station];
|
||||
|
||||
rct_map_element* map_element = map_get_first_element_at(x, y);
|
||||
for (;; map_element++){
|
||||
if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_ENTRANCE)
|
||||
continue;
|
||||
if (map_element->base_height == z)
|
||||
break;
|
||||
}
|
||||
|
||||
uint8 direction = map_element->type & MAP_ELEMENT_DIRECTION_MASK;
|
||||
x *= 32;
|
||||
y *= 32;
|
||||
x += 16;
|
||||
y += 16;
|
||||
|
||||
sint16 x_shift = RCT2_ADDRESS(0x00981D6C, sint16)[direction];
|
||||
sint16 y_shift = RCT2_ADDRESS(0x00981D6E, sint16)[direction];
|
||||
|
||||
uint8 shift_multiplier = 21;
|
||||
rct_ride_type* ride_type = GET_RIDE_ENTRY(ride->subtype);
|
||||
if (ride_type->vehicles[ride_type->var_014].var_12 & (1 << 3)||
|
||||
ride_type->vehicles[ride_type->var_014].var_14 & 0x5000){
|
||||
shift_multiplier = 32;
|
||||
}
|
||||
|
||||
x_shift *= shift_multiplier;
|
||||
y_shift *= shift_multiplier;
|
||||
|
||||
x += x_shift;
|
||||
y += y_shift;
|
||||
|
||||
peep->destination_x = x;
|
||||
peep->destination_y = y;
|
||||
peep->destination_tolerence = 2;
|
||||
|
||||
peep_decrement_num_riders(peep);
|
||||
peep->state = PEEP_STATE_ENTERING_RIDE;
|
||||
peep->sub_state = 1;
|
||||
peep_window_state_update(peep);
|
||||
|
||||
peep->var_AC = 0;
|
||||
peep->var_E2 = 0;
|
||||
|
||||
RCT2_CALLPROC_X(0x6966A9, 0, 0, 0, 0, (int)peep, 0, 0);
|
||||
}
|
||||
|
||||
/* rct2: 0x691A30
|
||||
|
|
|
@ -108,7 +108,8 @@ typedef struct {
|
|||
uint8 var_011;
|
||||
uint8 var_012;
|
||||
uint8 var_013;
|
||||
uint8 pad_014[0x6];
|
||||
uint8 var_014;
|
||||
uint8 pad_015[0x5];
|
||||
rct_ride_type_vehicle vehicles[4]; // 0x1A
|
||||
uint32 var_1AE;
|
||||
sint8 excitement_multipler; // 0x1B2
|
||||
|
|
|
@ -68,10 +68,13 @@ typedef struct {
|
|||
uint8 status; // 0x50
|
||||
uint8 var_51;
|
||||
uint16 peep[32]; // 0x52
|
||||
uint8 pad_92[0x20];
|
||||
uint8 var_B2;
|
||||
uint8 peep_tshirt_colours[32]; // 0x92
|
||||
uint8 num_seats; // 0xB2
|
||||
uint8 num_peeps; // 0xB3
|
||||
uint8 var_B4;
|
||||
union{
|
||||
uint8 var_B4; // When Forward/Backward rotation this variable is used differently
|
||||
uint8 next_free_seat; // 0xB4
|
||||
};
|
||||
uint8 pad_B5[0x06];
|
||||
uint8 sound1_id; // 0xBB
|
||||
uint8 sound1_volume; // 0xBC
|
||||
|
|
Loading…
Reference in New Issue