From 481fd08ab54f670d3e99ad63e777773dea253cfd Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 18 Oct 2014 09:11:35 +0100 Subject: [PATCH] Added update_picked and update_entering_park. Added new entries to peep struct --- src/peep/peep.c | 60 +++++++++++++++++++++++++++++++++++++-------- src/peep/peep.h | 31 ++++++++++++++++++----- src/windows/guest.c | 2 +- src/windows/staff.c | 24 +++++++++++------- 4 files changed, 91 insertions(+), 26 deletions(-) diff --git a/src/peep/peep.c b/src/peep/peep.c index 2248a1e4fe..d689bf5058 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -129,14 +129,14 @@ void peep_decrement_num_riders(rct_peep* peep){ */ void peep_window_state_update(rct_peep* peep){ - rct_window* w = window_find_by_id(WC_PEEP, peep->sprite_index); + rct_window* w = window_find_by_number(WC_PEEP, peep->sprite_index); if (w){ RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)w, 0, 0); } if (peep->type == PEEP_TYPE_GUEST){ // Update action label - widget_invalidate(WC_PEEP, peep->sprite_index, 12); + widget_invalidate_by_number(WC_PEEP, peep->sprite_index, 12); if (peep->state == PEEP_STATE_ON_RIDE || peep->state == PEEP_STATE_ENTERING_RIDE){ rct_ride* ride = GET_RIDE(peep->current_ride); @@ -144,12 +144,12 @@ void peep_window_state_update(rct_peep* peep){ ride->var_14D |= 0xC; } - window_invalidate_by_id(WC_GUEST_LIST,0); + window_invalidate_by_class(WC_GUEST_LIST); } else{ // Update action label - widget_invalidate(WC_PEEP, peep->sprite_index, 9); - window_invalidate_by_id(WC_STAFF_LIST, 0); + widget_invalidate_by_number(WC_PEEP, peep->sprite_index, 9); + window_invalidate_by_class(WC_STAFF_LIST); } } @@ -289,9 +289,8 @@ void peep_try_get_up_from_sitting(rct_peep* peep){ // Eats all food first if (peep_has_food(peep))return; - (*((uint16*)&peep->current_car))--; - // Checks time we have been sitting on seat - if (*((uint16*)&peep->current_car)) return; + peep->time_to_sitdown--; + if (peep->time_to_sitdown) return; peep_decrement_num_riders(peep); peep->state = PEEP_STATE_WALKING; @@ -333,7 +332,7 @@ void peep_update_sitting(rct_peep* peep){ peep->var_2C++; // Sets time to sit on seat - *((uint16*)&peep->current_car) = (129 - peep->energy) * 16 + 50; + peep->time_to_sitdown = (129 - peep->energy) * 16 + 50; } else if (peep->var_2C == 1){ if (peep->var_71 < 0xFE){ @@ -504,6 +503,47 @@ void peep_update_queuing(rct_peep* peep){ } } +/** + * rct2: 0x690009 + */ +static void peep_update_picked(rct_peep* peep){ + if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TICKS, uint32) & 0x1F) return; + peep->var_2C++; + if (peep->var_2C == 13){ + peep_insert_new_thought(peep, PEEP_THOUGHT_HELP, 0xFF); + } +} + +/** +* rct2: 0x691451 +*/ +static void peep_update_entering_park(rct_peep* peep){ + if (peep->var_37 != 1){ + RCT2_CALLPROC_X(0x693C9E, 0, 0, 0, 0, (int)peep, 0, 0); + if ((RCT2_GLOBAL(0xF1EE18, uint16) & 2)){ + RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_HEADING_FOR_PARK, uint16)--; + RCT2_CALLPROC_X(0x69A535, 0, 0, 0, 0, (int)peep, 0, 0); + } + return; + } + if (RCT2_CALLPROC_X(0x6939EB, 0, 0, 0, 0, (int)peep, 0, 0) & 0x100){ + RCT2_CALLPROC_X(0x006EC473, 0, 0, 0, 0, (int)peep, 0, 0); + sub_69E9D3(0, 0, peep->z, (rct_sprite*)peep); + RCT2_CALLPROC_X(0x006EC473, 0, 0, 0, 0, (int)peep, 0, 0); + return; + } + peep_decrement_num_riders(peep); + peep->state = PEEP_STATE_FALLING; + peep_window_state_update(peep); + + peep->var_2A = 0; + peep->time_in_park = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, sint32); + RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_IN_PARK, uint16); + RCT2_GLOBAL(RCT2_ADDRESS_GUESTS_HEADING_FOR_PARK, uint16)--; + RCT2_GLOBAL(0x9A9804, uint16) |= (1 << 2); + window_invalidate_by_class(WC_GUEST_LIST); +} + /** * * rct2: 0x0068FC1E @@ -605,7 +645,7 @@ static void peep_update(rct_peep *peep) peep_update_sitting(peep); break; case PEEP_STATE_PICKED: - RCT2_CALLPROC_X(0x00690009, 0, 0, 0, 0, (int)peep, 0, 0); + peep_update_picked(peep); break; case PEEP_STATE_PATROLLING: RCT2_CALLPROC_X(0x006BF1FD, 0, 0, 0, 0, (int)peep, 0, 0); diff --git a/src/peep/peep.h b/src/peep/peep.h index 0e20dff1b5..e89ee8f93d 100644 --- a/src/peep/peep.h +++ b/src/peep/peep.h @@ -367,8 +367,13 @@ typedef struct { uint8 current_ride; // 0x68 uint8 current_ride_station; // 0x69 uint8 current_train; // 0x6A - uint8 current_car; // 0x6B - uint8 current_seat; // 0x6C + union{ + struct{ + uint8 current_car; // 0x6B + uint8 current_seat; // 0x6C + }; + uint16 time_to_sitdown; //0x6B + }; uint8 var_6D; // 0x6D uint8 var_6E; // 0x6E uint8 var_6F; @@ -411,10 +416,24 @@ typedef struct { uint8 pad_E1; uint8 var_E2; // 0xE2 uint8 pad_E3; - money16 paid_to_enter; // 0xE4 - money16 paid_on_rides; // 0xE6 - money16 paid_on_food; // 0xE8 - money16 paid_on_souvenirs; // 0xEA + union{ + money16 paid_to_enter; // 0xE4 + uint16 staff_lawns_mown; // 0xE4 + uint16 staff_rides_fixed; // 0xE4 + }; + union{ + money16 paid_on_rides; // 0xE6 + uint16 staff_gardens_watered; // 0xE6 + uint16 staff_rides_inspected; // 0xE6 + }; + union { + money16 paid_on_food; // 0xE8 + uint16 staff_litter_swept; // 0xE8 + }; + union{ + money16 paid_on_souvenirs; // 0xEA + uint16 staff_bins_emptied; // 0xEA + }; uint8 no_of_food; // 0xEC uint8 no_of_drinks; // 0xED uint8 no_of_souvenirs; // 0xEE diff --git a/src/windows/guest.c b/src/windows/guest.c index 04b76557ea..05034d516a 100644 --- a/src/windows/guest.c +++ b/src/windows/guest.c @@ -626,7 +626,7 @@ void window_guest_overview_mouse_up(){ sub_69E9D3(0x8000, peep->y, peep->z, (rct_sprite*)peep); peep_decrement_num_riders(peep); - peep->state = 9; + peep->state = PEEP_STATE_PICKED; peep->var_2C = 0; peep_window_state_update(peep); break; diff --git a/src/windows/staff.c b/src/windows/staff.c index bf64ba40c7..4f0ed8c3bf 100644 --- a/src/windows/staff.c +++ b/src/windows/staff.c @@ -1049,18 +1049,24 @@ void window_staff_stats_paint(){ switch (peep->staff_type){ case STAFF_TYPE_HANDYMAN: - gfx_draw_string_left(dpi, 2351, (void*)&peep->paid_to_enter, 0, x, y); + // Lawns mown + gfx_draw_string_left(dpi, 2351, (void*)&peep->staff_lawns_mown, 0, x, y); y += 10; - gfx_draw_string_left(dpi, 2352, (void*)&peep->paid_on_rides, 0, x, y); + // Gardens Watered + gfx_draw_string_left(dpi, 2352, (void*)&peep->staff_gardens_watered, 0, x, y); y += 10; - gfx_draw_string_left(dpi, 2353, (void*)&peep->paid_on_food, 0, x, y); + // Litter Swept + gfx_draw_string_left(dpi, 2353, (void*)&peep->staff_litter_swept, 0, x, y); y += 10; - gfx_draw_string_left(dpi, 2354, (void*)&peep->paid_on_souvenirs, 0, x, y); + // Bins Emptied + gfx_draw_string_left(dpi, 2354, (void*)&peep->staff_bins_emptied, 0, x, y); break; case STAFF_TYPE_MECHANIC: - gfx_draw_string_left(dpi, 2356, (void*)&peep->paid_on_rides, 0, x, y); + // Rides Inspected + gfx_draw_string_left(dpi, 2356, (void*)&peep->staff_rides_inspected, 0, x, y); y += 10; - gfx_draw_string_left(dpi, 2355, (void*)&peep->paid_to_enter, 0, x, y); + // Rides Fixed + gfx_draw_string_left(dpi, 2355, (void*)&peep->staff_rides_fixed, 0, x, y); break; } } @@ -1143,11 +1149,11 @@ void window_staff_overview_tool_down(){ } rct_peep* peep = GET_PEEP(w->number); - RCT2_CALLPROC_X(0x0069E9D3, dest_x, 0, dest_y, dest_z, (int)peep, 0, 0); + sub_69E9D3(dest_x, dest_y, dest_z, (rct_sprite*)peep); RCT2_CALLPROC_X(0x006EC473, 0, 0, 0, 0, (int)peep, 0, 0); - RCT2_CALLPROC_X(0x0069A409, 0, 0, 0, 0, (int)peep, 0, 0); + peep_decrement_num_riders(peep); peep->state = 0; - RCT2_CALLPROC_X(0x0069A42F, 0, 0, 0, 0, (int)peep, 0, 0); + peep_window_state_update(peep); peep->var_71 = 0xFF; peep->var_6D = 0; peep->var_70 = 0;