mirror of https://github.com/OpenRCT2/OpenRCT2.git
Refactor peep_update_buying
This commit is contained in:
parent
d33d892931
commit
b10f85f4ea
105
src/peep/peep.c
105
src/peep/peep.c
|
@ -1329,64 +1329,7 @@ static void peep_update_buying(rct_peep* peep)
|
|||
peep_window_state_update(peep);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ride->type == RIDE_TYPE_ATM){
|
||||
if (peep->sub_state == 1){
|
||||
if (peep->action != 0xFF){
|
||||
sint16 x, y;
|
||||
sub_6939EB(&x, &y, peep);
|
||||
return;
|
||||
}
|
||||
|
||||
if (peep->current_ride != peep->var_AD){
|
||||
peep->cash_in_pocket += 500;
|
||||
}
|
||||
|
||||
window_invalidate_by_number(WC_PEEP, peep->sprite_index);
|
||||
peep->sprite_direction ^= 0x10;
|
||||
peep->destination_x = peep->next_x + 16;
|
||||
peep->destination_y = peep->next_y + 16;
|
||||
peep->var_78 ^= 2;
|
||||
|
||||
peep_decrement_num_riders(peep);
|
||||
peep->state = PEEP_STATE_WALKING;
|
||||
peep_window_state_update(peep);
|
||||
return;
|
||||
}
|
||||
|
||||
if (peep->current_ride == peep->var_AD){
|
||||
ride_update_popularity(ride, 0);
|
||||
peep->sub_state = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
uint8 atm_used = 0;
|
||||
atm_used = !(RCT2_CALLPROC_X(0x0069AEB7, peep->current_ride << 8, 0, 0, 0, (int)peep, 0, 0) & 0x100);
|
||||
|
||||
if (atm_used){
|
||||
peep->var_AD = peep->current_ride;
|
||||
peep->var_AE = 0;
|
||||
ride_update_popularity(ride, 0);
|
||||
peep->sub_state = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
peep->action = PEEP_ACTION_30;
|
||||
peep->action_frame = 0;
|
||||
peep->var_70 = 0;
|
||||
|
||||
sub_693B58(peep);
|
||||
invalidate_sprite((rct_sprite*)peep);
|
||||
|
||||
ride->no_primary_items_sold++;
|
||||
ride_update_popularity(ride, 1);
|
||||
|
||||
// Peep thought related
|
||||
RCT2_CALLPROC_X(0x00699FE3, ride->type, 0, 0, 0, (int)peep, 0, 0);
|
||||
peep->sub_state = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (peep->sub_state == 1){
|
||||
if (peep->action != 0xFF){
|
||||
sint16 x, y;
|
||||
|
@ -1394,6 +1337,12 @@ static void peep_update_buying(rct_peep* peep)
|
|||
return;
|
||||
}
|
||||
|
||||
if (ride->type == RIDE_TYPE_ATM){
|
||||
if (peep->current_ride != peep->var_AD){
|
||||
peep->cash_in_pocket += 500;
|
||||
}
|
||||
window_invalidate_by_number(WC_PEEP, peep->sprite_index);
|
||||
}
|
||||
peep->sprite_direction ^= 0x10;
|
||||
peep->destination_x = peep->next_x + 16;
|
||||
peep->destination_y = peep->next_y + 16;
|
||||
|
@ -1408,24 +1357,44 @@ static void peep_update_buying(rct_peep* peep)
|
|||
uint8 item_bought = 0;
|
||||
|
||||
if (peep->current_ride != peep->var_AD){
|
||||
rct_ride_type* ride_type = gRideTypeList[ride->subtype];
|
||||
if (ride_type->shop_item_secondary != 0xFF){
|
||||
money16 price = ride->price_secondary;
|
||||
if (ride->type == RIDE_TYPE_ATM){
|
||||
item_bought = !(RCT2_CALLPROC_X(0x0069AEB7, peep->current_ride << 8, 0, 0, 0, (int)peep, 0, 0) & 0x100);
|
||||
|
||||
item_bought = !(RCT2_CALLPROC_X(0x0069AF1E, ride_type->shop_item_secondary | (peep->current_ride << 8), 0, price, 0, (int)peep, 0, 0) & 0x100);
|
||||
if (!item_bought){
|
||||
peep->var_AD = peep->current_ride;
|
||||
peep->var_AE = 0;
|
||||
}
|
||||
else{
|
||||
peep->action = PEEP_ACTION_30;
|
||||
peep->action_frame = 0;
|
||||
peep->var_70 = 0;
|
||||
|
||||
if (item_bought){
|
||||
ride->no_secondary_items_sold++;
|
||||
sub_693B58(peep);
|
||||
invalidate_sprite((rct_sprite*)peep);
|
||||
|
||||
ride->no_primary_items_sold++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
rct_ride_type* ride_type = gRideTypeList[ride->subtype];
|
||||
if (ride_type->shop_item_secondary != 0xFF){
|
||||
money16 price = ride->price_secondary;
|
||||
|
||||
if (!item_bought && ride_type->shop_item != 0xFF){
|
||||
money16 price = ride->price;
|
||||
item_bought = !(RCT2_CALLPROC_X(0x0069AF1E, ride_type->shop_item_secondary | (peep->current_ride << 8), 0, price, 0, (int)peep, 0, 0) & 0x100);
|
||||
|
||||
item_bought = !(RCT2_CALLPROC_X(0x0069AF1E, ride_type->shop_item | (peep->current_ride << 8), 0, price, 0, (int)peep, 0, 0) & 0x100);
|
||||
if (item_bought){
|
||||
ride->no_secondary_items_sold++;
|
||||
}
|
||||
}
|
||||
|
||||
if (item_bought){
|
||||
ride->no_primary_items_sold++;
|
||||
if (!item_bought && ride_type->shop_item != 0xFF){
|
||||
money16 price = ride->price;
|
||||
|
||||
item_bought = !(RCT2_CALLPROC_X(0x0069AF1E, ride_type->shop_item | (peep->current_ride << 8), 0, price, 0, (int)peep, 0, 0) & 0x100);
|
||||
|
||||
if (item_bought){
|
||||
ride->no_primary_items_sold++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue