diff --git a/src/addresses.h b/src/addresses.h index 51fbda55ee..68a4bcacef 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -423,6 +423,8 @@ #define RCT2_ADDRESS_COMMON_FORMAT_ARGS 0x013CE952 +#define RCT2_ADDRESS_STAFF_MODE_ARRAY 0x013CA672 + static void RCT2_CALLPROC_EBPSAFE(int address) { #ifdef _MSC_VER diff --git a/src/editor.c b/src/editor.c index db3ead3c26..138eeb1162 100644 --- a/src/editor.c +++ b/src/editor.c @@ -34,6 +34,7 @@ #include "audio.h" #include "sprite.h" #include "string_ids.h" +#include "staff.h" static void set_all_land_owned(); @@ -182,10 +183,11 @@ static void set_all_land_owned() */ void sub_6BD3A4() { for (short i = 0; i < 200; i++) { - RCT2_ADDRESS(0x013CA672, uint8)[i] = 0; + RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[i] = STAFF_MODE_NONE; } for (short i = 200; i < 204; i++) { - RCT2_ADDRESS(0x013CA672, uint8)[i] = 1; + RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[i] = STAFF_MODE_WALK; } - RCT2_CALLPROC_EBPSAFE(0x006C0C3F); + //RCT2_CALLPROC_EBPSAFE(0x006C0C3F); + sub_6C0C3F(); } diff --git a/src/marketing.c b/src/marketing.c index 5d94454cae..af6179fc1c 100644 --- a/src/marketing.c +++ b/src/marketing.c @@ -113,7 +113,7 @@ void marketing_set_guest_campaign(rct_peep *peep, int campaign) peep->item_standard_flags |= PEEP_ITEM_VOUCHER; peep->var_F0 = 1; peep->var_F1 = RCT2_ADDRESS(0x01358116, uint8)[campaign]; - peep->var_C5 = RCT2_ADDRESS(0x01358116, uint8)[campaign]; + peep->staff_id = RCT2_ADDRESS(0x01358116, uint8)[campaign]; peep->var_C6 = 240; break; case ADVERTISING_CAMPAIGN_PARK_ENTRY_HALF_PRICE: @@ -128,7 +128,7 @@ void marketing_set_guest_campaign(rct_peep *peep, int campaign) case ADVERTISING_CAMPAIGN_PARK: break; case ADVERTISING_CAMPAIGN_RIDE: - peep->var_C5 = RCT2_ADDRESS(0x01358116, uint8)[campaign]; + peep->staff_id = RCT2_ADDRESS(0x01358116, uint8)[campaign]; peep->var_C6 = 240; break; } diff --git a/src/peep.c b/src/peep.c index aa2d252b6a..629426280a 100644 --- a/src/peep.c +++ b/src/peep.c @@ -177,31 +177,31 @@ void peep_problem_warnings_update() break; case PEEP_THOUGHT_TYPE_HUNGRY: // 0x14 - if (peep->var_C5 == -1){ + if (peep->staff_id == -1){ hunger_counter++; break; } - ride = &g_ride_list[peep->var_C5]; + ride = &g_ride_list[peep->staff_id]; if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x80000)) hunger_counter++; break; case PEEP_THOUGHT_TYPE_THIRSTY: - if (peep->var_C5 == -1){ + if (peep->staff_id == -1){ thirst_counter++; break; } - ride = &g_ride_list[peep->var_C5]; + ride = &g_ride_list[peep->staff_id]; if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x1000000)) thirst_counter++; break; case PEEP_THOUGHT_TYPE_BATHROOM: - if (peep->var_C5 == -1){ + if (peep->staff_id == -1){ bathroom_counter++; break; } - ride = &g_ride_list[peep->var_C5]; + ride = &g_ride_list[peep->staff_id]; if (!(RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + ride->type * 8, uint32) & 0x2000000)) bathroom_counter++; break; @@ -447,8 +447,8 @@ void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argum break; case PEEP_STATE_WALKING: case 0x14: - if (peep->var_C5 != 0xFF){ - ride = g_ride_list[peep->var_C5]; + if (peep->staff_id != 0xFF){ + ride = g_ride_list[peep->staff_id]; *argument_1 = STR_HEADING_FOR | (ride.name << 16); *argument_2 = ride.name_arguments; } diff --git a/src/peep.h b/src/peep.h index 30a34cb7bb..a938440268 100644 --- a/src/peep.h +++ b/src/peep.h @@ -386,7 +386,7 @@ typedef struct { uint16 var_AE; rct_peep_thought thoughts[PEEP_MAX_THOUGHTS]; // 0xB0 uint8 var_C4; // 0xC4 - uint8 var_C5; + uint8 staff_id; uint8 var_C6; uint8 photo1_ride_ref; // 0xC7 uint32 flags; // 0xC8 diff --git a/src/scenario.h b/src/scenario.h index cbd5b5d764..6f0fdd33f7 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -330,7 +330,7 @@ typedef struct { uint8 ride_measurements[0x25860]; uint32 dword_13B0E6C; uint16 word_13B0E70; - uint32 dword_13B0E72[0x6600]; + uint32 dword_13B0E72[0x6600]; // 512 bytes per staff peep uint8 byte_13CA672[116]; uint8 byte_13CA6E6[84]; uint8 byte_13CA73A[4]; diff --git a/src/staff.c b/src/staff.c index ce46f47525..3871dfb080 100644 --- a/src/staff.c +++ b/src/staff.c @@ -99,7 +99,7 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, int i; for (i = 0; i < STAFF_MAX_COUNT; i++) { - if (!(RCT2_ADDRESS(0x013CA672, uint8)[i] & 1)) + if (!(RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[i] & 1)) break; } @@ -220,9 +220,9 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, RCT2_CALLPROC_X(0x00699115, (uint32)ebp & 0xFFFFFF3F, 0, 0, 0, (int)newPeep, 0, (*ebp << 25) | (*ebp >> 6)); - newPeep->var_C5 = newStaffId; + newPeep->staff_id = newStaffId; - RCT2_ADDRESS(0x013CA672, uint8)[newStaffId] = 1; + RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[newStaffId] = STAFF_MODE_WALK; for (int edi = 0; edi < 0x80; edi++) { int addr = 0x013B0E72 + (newStaffId << 9) + edi * 4; @@ -267,4 +267,27 @@ uint16 hire_new_staff_member(uint8 staff_type) return 0xFFFF; return edi; +} + +void sub_6C0C3F() +{ + register rct_peep* peep; + + for (register uint8 staff_type = 0; staff_type < STAFF_TYPE_COUNT; ++staff_type) + { + for (register uint8 i = 0; i < 128; ++i) + RCT2_ADDRESS(0x13B0E72 + (staff_type + STAFF_MAX_COUNT) * 512, uint32)[i] = 0; + + for (register uint16 sprite_index = RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_START_PEEP, uint16); sprite_index != SPRITE_INDEX_NULL; sprite_index = peep->next) + { + peep = GET_PEEP(sprite_index); + + if (peep->type == PEEP_TYPE_STAFF && staff_type == peep->staff_type) + { + for (register uint8 i = 0; i < 128; ++i) + RCT2_ADDRESS(0x13B0E72 + (staff_type + STAFF_MAX_COUNT) * 512, uint32)[i] |= RCT2_ADDRESS(0x13B0E72 + (peep->staff_id * 512) * 512, uint32)[i]; + + } + } + } } \ No newline at end of file diff --git a/src/staff.h b/src/staff.h index 533c0b4a8f..b8ef29af0c 100644 --- a/src/staff.h +++ b/src/staff.h @@ -24,6 +24,13 @@ #include "rct2.h" #define STAFF_MAX_COUNT 0xC8 +#define STAFF_TYPE_COUNT 0x04 + +enum STAFF_MODE { + STAFF_MODE_NONE, + STAFF_MODE_WALK, + STAFF_MODE_PATROL = 3 +}; enum STAFF_TYPE { STAFF_TYPE_HANDYMAN, @@ -37,5 +44,6 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, void update_staff_colour(uint8 staff_type, uint16 color); uint16 hire_new_staff_member(uint8 staff_type); +void sub_6C0C3F(); #endif \ No newline at end of file diff --git a/src/window_staff.c b/src/window_staff.c index eed1574ee7..57cc1c1e2a 100644 --- a/src/window_staff.c +++ b/src/window_staff.c @@ -626,7 +626,7 @@ void window_staff_scrollpaint() gfx_draw_string_left_clipped(dpi, format, (void*)0x013CE952, 0, 175, y - 1, 305); // True if a patrol path is set for the worker - if (RCT2_ADDRESS(0x013CA672, uint8)[peep->var_C5] & 2) { + if (RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[peep->staff_id] & 2) { gfx_draw_sprite(dpi, 0x13FD, 110, y - 1, 0); } diff --git a/src/window_staff_peep.c b/src/window_staff_peep.c index 555818c920..59da317802 100644 --- a/src/window_staff_peep.c +++ b/src/window_staff_peep.c @@ -28,6 +28,7 @@ #include "widget.h" #include "window.h" #include "window_dropdown.h" +#include "staff.h" enum WINDOW_STAFF_PEEP_PAGE { WINDOW_STAFF_PEEP_OVERVIEW, @@ -543,7 +544,7 @@ void window_staff_peep_overview_mousedown(int widgetIndex, rct_window* w, rct_wi rct_peep* peep = GET_PEEP(w->number); // Disable clear patrol area if no area is set. - if (!(RCT2_ADDRESS(0x013CA672, uint8)[peep->var_C5] & 2)) { + if (!(RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[peep->staff_id] & 2)) { RCT2_GLOBAL(0x009DED34, sint32) |= 1 << 1; } } @@ -563,17 +564,18 @@ void window_staff_peep_overview_dropdown() // Clear patrol if (dropdownIndex == 1) { rct_peep* peep = GET_PEEP(w->number); - int edi = peep->var_C5; + int edi = peep->staff_id; int ebx = edi << 9; for (int i = 0; i < 128; i++) { RCT2_GLOBAL(0x13B0E72 + ebx + i * 4, uint32) = 0; } - RCT2_GLOBAL(0x13CA672 + edi, uint16) &= 0xFD; // bug?? + RCT2_GLOBAL(RCT2_ADDRESS_STAFF_MODE_ARRAY + edi, uint16) &= 0xFD; // bug?? window_invalidate(w); - RCT2_CALLPROC_EBPSAFE(0x006C0C3F); + //RCT2_CALLPROC_EBPSAFE(0x006C0C3F); + sub_6C0C3F(); } else { if (!tool_set(w, widgetIndex, 22)) {