diff --git a/src/addresses.h b/src/addresses.h index 51fbda55ee..665747655f 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 @@ -438,7 +440,7 @@ static void RCT2_CALLPROC_EBPSAFE(int address) #endif } -static void RCT2_CALLPROC_X(int address, int _eax, int _ebx, int _ecx, int _edx, int _esi, int _edi, int _ebp) +static int RCT2_CALLPROC_X(int address, int _eax, int _ebx, int _ecx, int _edx, int _esi, int _edi, int _ebp) { #ifdef _MSC_VER __asm { @@ -451,6 +453,7 @@ static void RCT2_CALLPROC_X(int address, int _eax, int _ebx, int _ecx, int _edx, mov edi, _edi mov ebp, _ebp call [esp] + lahf add esp, 4 } #else @@ -467,6 +470,7 @@ static void RCT2_CALLPROC_X(int address, int _eax, int _ebx, int _ecx, int _edx, mov edi, %[_edi] \n\ mov ebp, %[_ebp] \n\ call [esp] \n\ + lahf \n\ add esp, 4 \n\ pop ebp \n\ pop ebx \n\ 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/game.c b/src/game.c index 621ba79b3c..00ec7cf776 100644 --- a/src/game.c +++ b/src/game.c @@ -925,7 +925,7 @@ static uint32 game_do_command_table[58] = { 0x006A67C0, 0x00663CCD, // 20 0x006B53E9, - 0x00698D6C, + 0x00698D6C, // text input 0x0068C542, 0x0068C6D1, 0x0068BC01, diff --git a/src/gfx.c b/src/gfx.c index ffdb445fdb..53c4942d59 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -1819,7 +1819,7 @@ int gfx_draw_string_centred_wrapped(rct_drawpixelinfo *dpi, void *args, int x, i int half_width = gfx_get_string_width(buffer) / 2; gfx_draw_string(dpi, buffer, 0xFE, x - half_width, line_y); - buffer += strlen(buffer) + 1; + buffer += get_string_length(buffer) + 1; line_y += line_height; } @@ -1874,7 +1874,7 @@ int gfx_draw_string_left_wrapped(rct_drawpixelinfo *dpi, void *args, int x, int for (int line = 0; line <= num_lines; ++line) { gfx_draw_string(dpi, buffer, 0xFE, x, line_y); - buffer += strlen(buffer) + 1; + buffer += get_string_length(buffer) + 1; line_y += line_height; } diff --git a/src/map.h b/src/map.h index 6c2cbf8b32..1546d9e3fe 100644 --- a/src/map.h +++ b/src/map.h @@ -195,6 +195,7 @@ typedef struct { void map_init(); void map_update_tile_pointers(); +rct_map_element *map_get_surface_element_at(int x, int y); int map_element_height(int x, int y); void sub_68B089(); int map_coord_is_connected(uint16 coordinate, uint8 height, uint8 face_direction); 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 6a846ada5e..d9d38c404e 100644 --- a/src/peep.c +++ b/src/peep.c @@ -26,6 +26,7 @@ #include "rct2.h" #include "ride.h" #include "sprite.h" +#include "sprites.h" #include "staff.h" #include "window.h" @@ -178,31 +179,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; @@ -448,8 +449,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; } @@ -589,6 +590,100 @@ int peep_can_be_picked_up(rct_peep* peep){ return RCT2_ADDRESS(0x982004, uint8)[peep->state] & 1; } +enum{ + PEEP_FACE_OFFSET_ANGRY = 0, + PEEP_FACE_OFFSET_VERY_VERY_SICK, + PEEP_FACE_OFFSET_VERY_SICK, + PEEP_FACE_OFFSET_SICK, + PEEP_FACE_OFFSET_VERY_TIRED, + PEEP_FACE_OFFSET_TIRED, + PEEP_FACE_OFFSET_VERY_VERY_UNHAPPY, + PEEP_FACE_OFFSET_VERY_UNHAPPY, + PEEP_FACE_OFFSET_UNHAPPY, + PEEP_FACE_OFFSET_NORMAL, + PEEP_FACE_OFFSET_HAPPY, + PEEP_FACE_OFFSET_VERY_HAPPY, + PEEP_FACE_OFFSET_VERY_VERY_HAPPY, +}; + +const int face_sprite_small[] = { + SPR_PEEP_SMALL_FACE_ANGRY, + SPR_PEEP_SMALL_FACE_VERY_VERY_SICK, + SPR_PEEP_SMALL_FACE_VERY_SICK, + SPR_PEEP_SMALL_FACE_SICK, + SPR_PEEP_SMALL_FACE_VERY_TIRED, + SPR_PEEP_SMALL_FACE_TIRED, + SPR_PEEP_SMALL_FACE_VERY_VERY_UNHAPPY, + SPR_PEEP_SMALL_FACE_VERY_UNHAPPY, + SPR_PEEP_SMALL_FACE_UNHAPPY, + SPR_PEEP_SMALL_FACE_NORMAL, + SPR_PEEP_SMALL_FACE_HAPPY, + SPR_PEEP_SMALL_FACE_VERY_HAPPY, + SPR_PEEP_SMALL_FACE_VERY_VERY_HAPPY, +}; + +const int face_sprite_large[] = { + SPR_PEEP_LARGE_FACE_ANGRY, + SPR_PEEP_LARGE_FACE_VERY_VERY_SICK, + SPR_PEEP_LARGE_FACE_VERY_SICK, + SPR_PEEP_LARGE_FACE_SICK, + SPR_PEEP_LARGE_FACE_VERY_TIRED, + SPR_PEEP_LARGE_FACE_TIRED, + SPR_PEEP_LARGE_FACE_VERY_VERY_UNHAPPY, + SPR_PEEP_LARGE_FACE_VERY_UNHAPPY, + SPR_PEEP_LARGE_FACE_UNHAPPY, + SPR_PEEP_LARGE_FACE_NORMAL, + SPR_PEEP_LARGE_FACE_HAPPY, + SPR_PEEP_LARGE_FACE_VERY_HAPPY, + SPR_PEEP_LARGE_FACE_VERY_VERY_HAPPY, +}; + +int get_face_sprite_offset(rct_peep *peep){ + + // ANGRY + if (peep->var_F3) return PEEP_FACE_OFFSET_ANGRY; + + // VERY_VERY_SICK + if (peep->nausea > 200) return PEEP_FACE_OFFSET_VERY_VERY_SICK; + + // VERY_SICK + if (peep->nausea > 170) return PEEP_FACE_OFFSET_VERY_SICK; + + // SICK + if (peep->nausea > 140) return PEEP_FACE_OFFSET_SICK; + + // VERY_TIRED + if (peep->energy < 46) return PEEP_FACE_OFFSET_VERY_TIRED; + + // TIRED + if (peep->energy < 70) return PEEP_FACE_OFFSET_TIRED; + + int offset = PEEP_FACE_OFFSET_VERY_VERY_UNHAPPY; + //There are 7 different happiness based faces + for (int i = 37; peep->happiness >= i; i += 37) + { + offset++; + } + + return offset; +} + +/** +* Function split into large and small sprite +* rct2: 0x00698721 +*/ +int get_peep_face_sprite_small(rct_peep *peep){ + return face_sprite_small[get_face_sprite_offset(peep)]; +} + +/** +* Function split into large and small sprite +* rct2: 0x00698721 +*/ +int get_peep_face_sprite_large(rct_peep *peep){ + return face_sprite_large[get_face_sprite_offset(peep)]; +} + int peep_is_mechanic(rct_peep *peep) { return ( diff --git a/src/peep.h b/src/peep.h index f5f0d9d5cd..d46040e6e1 100644 --- a/src/peep.h +++ b/src/peep.h @@ -296,10 +296,10 @@ enum PEEP_ITEM { }; typedef struct { - uint8 type; - uint8 item; - uint8 var_2; - uint8 var_3; + uint8 type; //0 + uint8 item; //1 + uint8 var_2; //2 + uint8 var_3; //3 } rct_peep_thought; typedef struct { @@ -332,7 +332,7 @@ typedef struct { uint8 pad_2C; uint8 sprite_type; // 0x2D uint8 type; // 0x2E - uint8 staff_type; // 0x2F + uint8 staff_type; // 0x2F Also used for no_of_rides uint8 tshirt_colour; // 0x30 uint8 trousers_colour; // 0x31 uint16 var_32; @@ -342,7 +342,7 @@ typedef struct { uint8 energy; // 0x38 uint8 energy_growth_rate; // 0x39 uint8 happiness; // 0x3A - uint8 happiness_growth_rate; // 0x3B + sint8 happiness_growth_rate; // 0x3B uint8 nausea; // 0x3C uint8 nausea_growth_rate; // 0x3D uint8 hunger; // 0x3E @@ -351,7 +351,7 @@ typedef struct { uint8 pad_41[0x2]; uint8 intensity; // 0x43 uint8 nausea_tolerance; // 0x44 - uint8 var_45; + uint8 var_45; // Some sort of flags? money16 paid_on_drink; // 0x46 uint8 pad_48[0x10]; uint32 item_extra_flags; // 0x58 @@ -377,16 +377,18 @@ typedef struct { uint8 var_78; uint8 pad_79[0x03]; uint8 rides_been_on[32]; // 0x7C + // 255 bit bitmap of every ride the peep has been on see + // window_peep_rides_update for how to use. uint32 id; // 0x9C money32 cash_in_pocket; // 0xA0 money32 cash_spent; // 0xA4 - uint8 var_A8; // 0xA8 - sint32 time_in_park; // 0xA9 + sint32 time_in_park; // 0xA8 + uint8 var_AC; // 0xAC uint8 var_AD; // creation/hire time? 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 @@ -404,8 +406,8 @@ typedef struct { uint8 no_of_drinks; // 0xED uint8 no_of_souvenirs; // 0xEE uint8 pad_EF; - uint8 var_F0; - uint8 var_F1; + uint8 var_F0; //voucher_type + uint8 var_F1; //voucher_type arguments i.e. ride_id uint8 pad_F2; uint8 var_F3; uint8 pad_F4[0x02]; @@ -445,6 +447,8 @@ void peep_applause(); rct_peep *peep_generate(int x, int y, int z); void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argument_2); void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2); +int get_peep_face_sprite_small(rct_peep *peep); +int get_peep_face_sprite_large(rct_peep *peep); int peep_is_mechanic(rct_peep *peep); #endif diff --git a/src/ride_data.c b/src/ride_data.c index 48ea5644ff..387156f9a7 100644 --- a/src/ride_data.c +++ b/src/ride_data.c @@ -492,6 +492,7 @@ const bool rideUnknownData2[0x60] = { true, // 59 LIM Launched Roller Coaster }; +/* Data at 0x0097E3B8 */ const uint8 rideUnknownData3[0x60] = { 10, // 00 Spiral Roller coaster 10, // 01 Stand Up Coaster 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/string_ids.c b/src/string_ids.c index 3e1277ab64..aa9d50f568 100644 --- a/src/string_ids.c +++ b/src/string_ids.c @@ -1691,4 +1691,59 @@ void reset_saved_strings() { for (int i = 0; i < 1024; i++) { RCT2_ADDRESS(0x135A8F4, uint8)[i * 32] = 0; } +} + +/** +* Return the length of the string in buffer. +* note you can't use strlen as there can be inline sprites! +* +* buffer (esi) +*/ +int get_string_length(char* buffer) +{ + // Length of string + int length = 0; + + for (uint8* curr_char = (uint8*)buffer; *curr_char != (uint8)0; curr_char++) { + length++; + if (*curr_char >= 0x20) { + continue; + } + switch (*curr_char) { + case FORMAT_MOVE_X: + case FORMAT_ADJUST_PALETTE: + case 3: + case 4: + curr_char++; + length++; + break; + case FORMAT_NEWLINE: + case FORMAT_NEWLINE_SMALLER: + case FORMAT_TINYFONT: + case FORMAT_BIGFONT: + case FORMAT_MEDIUMFONT: + case FORMAT_SMALLFONT: + case FORMAT_OUTLINE: + case FORMAT_OUTLINE_OFF: + case FORMAT_WINDOW_COLOUR_1: + case FORMAT_WINDOW_COLOUR_2: + case FORMAT_WINDOW_COLOUR_3: + case 0x10: + continue; + case FORMAT_INLINE_SPRITE: + length += 4; + curr_char += 4; + break; + default: + if (*curr_char <= 0x16) { //case 0x11? FORMAT_NEW_LINE_X_Y + length += 2; + curr_char += 2; + continue; + } + length += 4; + curr_char += 4;//never happens? + break; + } + } + return length; } \ No newline at end of file diff --git a/src/string_ids.h b/src/string_ids.h index e0829b5bf1..c66ca924e2 100644 --- a/src/string_ids.h +++ b/src/string_ids.h @@ -30,6 +30,7 @@ void error_string_quit(int error, rct_string_id format); char format_get_code(const char *token); const char *format_get_token(char code); +int get_string_length(char* buffer); enum { // Font format codes diff --git a/src/window.h b/src/window.h index d019ba38d1..8b9ac54cd9 100644 --- a/src/window.h +++ b/src/window.h @@ -235,7 +235,12 @@ typedef enum { WE_RESIZE = 2, WE_MOUSE_DOWN = 3, WE_DROPDOWN = 4, - WE_UNKNOWN_05 = 5, + WE_UNKNOWN_05 = 5, + // Unknown 05: Used to update tabs that are not being animated + // see window_peep. When the overview tab is not highlighted the + // items being carried such as hats/balloons still need to be shown + // and removed. Probably called after anything that affects items + // being carried. WE_UPDATE = 6, WE_UNKNOWN_07 = 7, WE_UNKNOWN_08 = 8, @@ -493,6 +498,12 @@ void RCT2_CALLPROC_WE_MOUSE_DOWN(int address, int widgetIndex, rct_window*w, rct __asm mov dropdownIndex, ax \ __asm mov widgetIndex, dx \ __asm mov w, esi + + #define window_text_input_get_registers(w, widgetIndex, _cl, text) \ + __asm mov widgetIndex, dx \ + __asm mov _cl, cl \ + __asm mov w, esi \ + __asm mov text, edi #define window_scrollmouse_get_registers(w, x, y) \ __asm mov x, cx \ @@ -527,6 +538,12 @@ void RCT2_CALLPROC_WE_MOUSE_DOWN(int address, int widgetIndex, rct_window*w, rct __asm__ ( "mov %["#widgetIndex"], dx " : [widgetIndex] "+m" (widgetIndex) ); \ __asm__ ( "mov %["#w"], esi " : [w] "+m" (w) ); + #define window_text_input_get_registers(w, widgetIndex, _cl, text) \ + __asm__ ( "mov %[_cl], cl " : [_cl] "+m" (_cl) ); \ + __asm__ ( "mov %[widgetIndex], dx " : [widgetIndex] "+m" (widgetIndex) ); \ + __asm__ ( "mov %[w], esi " : [w] "+m" (w) ); \ + __asm__ ( "mov %[text], edi " : [text] "+m" (text) ); + #define window_scrollmouse_get_registers(w, x, y) \ __asm__ ( "mov %["#x"], cx " : [x] "+m" (x) ); \ __asm__ ( "mov %["#y"], dx " : [y] "+m" (y) ); \ diff --git a/src/window_guest_list.c b/src/window_guest_list.c index 217e7ebb26..97223cb97a 100644 --- a/src/window_guest_list.c +++ b/src/window_guest_list.c @@ -132,8 +132,7 @@ static uint8 _window_guest_list_groups_guest_faces[240 * 58]; static int window_guest_list_is_peep_in_filter(rct_peep* peep); static void window_guest_list_find_groups(); -static int get_guest_face_sprite_small(rct_peep *peep); -static int get_guest_face_sprite_large(rct_peep *peep); + static void get_arguments_from_peep(rct_peep *peep, uint32 *argument_1, uint32* argument_2); /** @@ -626,7 +625,7 @@ static void window_guest_list_scrollpaint() switch (_window_guest_list_selected_view) { case VIEW_ACTIONS: // Guest face - gfx_draw_sprite(dpi, get_guest_face_sprite_small(peep), 118, y, 0); + gfx_draw_sprite(dpi, get_peep_face_sprite_small(peep), 118, y, 0); // Tracking icon if (peep->flags & PEEP_FLAGS_TRACKING) @@ -802,7 +801,7 @@ static void window_guest_list_find_groups() RCT2_ADDRESS(0x00F1AF26, uint8)[groupIndex] = groupIndex; faceIndex = groupIndex * 56; - _window_guest_list_groups_guest_faces[faceIndex++] = get_guest_face_sprite_small(peep) - 5486; + _window_guest_list_groups_guest_faces[faceIndex++] = get_peep_face_sprite_small(peep) - 5486; // Find more peeps that belong to same group FOR_ALL_GUESTS(spriteIndex2, peep2) { @@ -822,7 +821,7 @@ static void window_guest_list_find_groups() // Add face sprite, cap at 56 though if (_window_guest_list_groups_num_guests[groupIndex] >= 56) continue; - _window_guest_list_groups_guest_faces[faceIndex++] = get_guest_face_sprite_small(peep2) - 5486; + _window_guest_list_groups_guest_faces[faceIndex++] = get_peep_face_sprite_small(peep2) - 5486; } if (RCT2_GLOBAL(0x00F1EDF6, uint16) == 0) { @@ -872,75 +871,4 @@ static void window_guest_list_find_groups() nextPeep: ; } -} - -/** - * Function split into large and small sprite - * rct2: 0x00698721 - */ -static int get_guest_face_sprite_small(rct_peep *peep) -{ - int sprite; - sprite = SPR_PEEP_SMALL_FACE_ANGRY; - - if (peep->var_F3) return sprite; - sprite = SPR_PEEP_SMALL_FACE_VERY_VERY_SICK; - - if (peep->nausea > 200) return sprite; - sprite--; //VERY_SICK - - if (peep->nausea > 170) return sprite; - sprite--; //SICK - - if (peep->nausea > 140) return sprite; - sprite = SPR_PEEP_SMALL_FACE_VERY_TIRED; - - if (peep->energy < 46) return sprite; - sprite--; //TIRED - - if (peep->energy < 70) return sprite; - sprite = SPR_PEEP_SMALL_FACE_VERY_VERY_UNHAPPY; - - //There are 7 different happiness based faces - for (int i = 37; peep->happiness >= i; i += 37) - { - sprite++; - } - - return sprite; -} - -/** -* Function split into large and small sprite -* rct2: 0x00698721 -*/ -static int get_guest_face_sprite_large(rct_peep* peep){ - int sprite; - sprite = SPR_PEEP_LARGE_FACE_ANGRY; - - if (peep->var_F3) return sprite; - sprite = SPR_PEEP_LARGE_FACE_VERY_VERY_SICK; - - if (peep->nausea > 200) return sprite; - sprite = SPR_PEEP_LARGE_FACE_VERY_SICK; - - if (peep->nausea > 170) return sprite; - sprite = SPR_PEEP_LARGE_FACE_SICK; - - if (peep->nausea > 140) return sprite; - sprite = SPR_PEEP_LARGE_FACE_VERY_TIRED; - - if (peep->energy < 46) return sprite; - sprite--; //TIRED - - if (peep->energy < 70) return sprite; - sprite = SPR_PEEP_LARGE_FACE_VERY_VERY_UNHAPPY; - - //There are 7 different happiness based faces - for (int i = 37; peep->happiness >= i; i += 37) - { - sprite++; - } - - return sprite; -} +} \ No newline at end of file diff --git a/src/window_peep.c b/src/window_peep.c index 494011da55..55f98e510c 100644 --- a/src/window_peep.c +++ b/src/window_peep.c @@ -23,13 +23,16 @@ #include "map.h" #include "ride.h" #include "peep.h" +#include "scenario.h" #include "string_ids.h" +#include "staff.h" #include "sprite.h" #include "sprites.h" #include "viewport.h" #include "widget.h" #include "window.h" #include "window_dropdown.h" +#include "window_error.h" enum WINDOW_PEEP_PAGE { WINDOW_PEEP_OVERVIEW, @@ -171,34 +174,39 @@ void window_peep_set_page(rct_window* w, int page); void window_peep_disable_widgets(rct_window* w); void window_peep_viewport_init(rct_window* w); -void window_peep_close(); -void window_peep_resize(); +void window_peep_overview_close(); +void window_peep_overview_resize(); void window_peep_overview_mouse_up(); void window_peep_overview_paint(); void window_peep_overview_invalidate(); void window_peep_overview_viewport_init_wrapper(); +void window_peep_overview_update(rct_window* w); +void window_peep_overview_text_input(); +void window_peep_overview_tool_update(); +void window_peep_overview_tool_down(); +void window_peep_overview_tool_abort(); static void* window_peep_overview_events[] = { - window_peep_close, + window_peep_overview_close, window_peep_overview_mouse_up, - window_peep_resize, + window_peep_overview_resize, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*)0x696F45, + window_peep_overview_update, window_peep_emptysub, window_peep_emptysub, - (void*)0x696A5F, - (void*)0x696A54, + window_peep_overview_tool_update,//tool_update + window_peep_overview_tool_down,//tool_down window_peep_emptysub, window_peep_emptysub, - (void*)0x696A49, + window_peep_overview_tool_abort,//tool_abort window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*)0x696A6A, + window_peep_overview_text_input,//text_input window_peep_overview_viewport_init_wrapper, window_peep_emptysub, window_peep_emptysub, @@ -209,14 +217,22 @@ static void* window_peep_overview_events[] = { window_peep_emptysub }; +void window_peep_mouse_up(); +void window_peep_unknown_05(); + +void window_peep_stats_resize(); +void window_peep_stats_update(); +void window_peep_stats_invalidate(); +void window_peep_stats_paint(); + static void* window_peep_stats_events[] = { window_peep_emptysub, - (void*) 0x0069744F, //mouse_up - (void*) 0x00697488, //resize + window_peep_mouse_up, //mouse_up + window_peep_stats_resize, //resize window_peep_emptysub, window_peep_emptysub, - (void*) 0x006974ED, - (void*) 0x0069746A, + window_peep_unknown_05, + window_peep_stats_update, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, @@ -235,19 +251,29 @@ static void* window_peep_stats_events[] = { window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*) 0x0069707D, //invalidate - (void*) 0x0069711D, //paint + window_peep_stats_invalidate, //invalidate + window_peep_stats_paint, //paint window_peep_emptysub }; +void window_peep_rides_resize(); +void window_peep_rides_update(); +void window_peep_rides_tooltip(); +void window_peep_rides_scroll_get_size(); +void window_peep_rides_scroll_mouse_down(); +void window_peep_rides_scroll_mouse_over(); +void window_peep_rides_invalidate(); +void window_peep_rides_paint(); +void window_peep_rides_scroll_paint(); + static void* window_peep_rides_events[] = { window_peep_emptysub, - (void*) 0x00697795, //mouse_up - (void*) 0x006978F4, //resize + window_peep_mouse_up, //mouse_up + window_peep_rides_resize, //resize window_peep_emptysub, window_peep_emptysub, - (void*) 0x00697959, - (void*) 0x006977B0, + window_peep_unknown_05, + window_peep_rides_update, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, @@ -256,29 +282,34 @@ static void* window_peep_rides_events[] = { window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*) 0x0069784E, - (void*) 0x006978CC, + window_peep_rides_scroll_get_size, //scroll_get_size + window_peep_rides_scroll_mouse_down, //scroll_mouse_down window_peep_emptysub, - (void*) 0x0069789C, + window_peep_rides_scroll_mouse_over, //scroll_mouse_over window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*) 0x00697844, + window_peep_rides_tooltip, //tooltip window_peep_emptysub, window_peep_emptysub, - (void*) 0x0069757A, //invalidate - (void*) 0x00697637, //paint - (void*) 0x006976FC + window_peep_rides_invalidate, //invalidate + window_peep_rides_paint, //paint + window_peep_rides_scroll_paint //scroll_paint }; +void window_peep_finance_resize(); +void window_peep_finance_update(); +void window_peep_finance_invalidate(); +void window_peep_finance_paint(); + static void* window_peep_finance_events[] = { window_peep_emptysub, - (void*) 0x00697BDD, //mouse_up - (void*) 0x00697C16, //resize + window_peep_mouse_up, //mouse_up + window_peep_finance_resize, //resize window_peep_emptysub, window_peep_emptysub, - (void*) 0x00697C7B, - (void*) 0x00697BF8, + window_peep_unknown_05, + window_peep_finance_update, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, @@ -297,19 +328,24 @@ static void* window_peep_finance_events[] = { window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*) 0x00697968, //invalidate - (void*) 0x00697A08, //paint + window_peep_finance_invalidate, //invalidate + window_peep_finance_paint, //paint window_peep_emptysub }; +void window_peep_thoughts_resize(); +void window_peep_thoughts_update(); +void window_peep_thoughts_invalidate(); +void window_peep_thoughts_paint(); + static void* window_peep_thoughts_events[] = { window_peep_emptysub, - (void*) 0x00697E18, //mouse_up - (void*) 0x00697E33, //resize + window_peep_mouse_up, //mouse_up + window_peep_thoughts_resize, //resize window_peep_emptysub, window_peep_emptysub, - (void*) 0x00697ED2, - (void*) 0x00697EB4, + window_peep_unknown_05, + window_peep_thoughts_update, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, @@ -328,19 +364,24 @@ static void* window_peep_thoughts_events[] = { window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*) 0x00697C8A, //invalidate - (void*) 0x00697D2A, //paint + window_peep_thoughts_invalidate, //invalidate + window_peep_thoughts_paint, //paint window_peep_emptysub }; +void window_peep_inventory_resize(); +void window_peep_inventory_update(); +void window_peep_inventory_invalidate(); +void window_peep_inventory_paint(); + static void* window_peep_inventory_events[] = { window_peep_emptysub, - (void*) 0x00698279, //mouse_up - (void*) 0x00698294, //resize + window_peep_mouse_up, //mouse_up + window_peep_inventory_resize, //resize window_peep_emptysub, window_peep_emptysub, - (void*) 0x00698333, - (void*) 0x00698315, + window_peep_unknown_05, + window_peep_inventory_update, window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, @@ -359,8 +400,8 @@ static void* window_peep_inventory_events[] = { window_peep_emptysub, window_peep_emptysub, window_peep_emptysub, - (void*) 0x00697EE1, //invalidate - (void*) 0x00697F81, //paint + window_peep_inventory_invalidate, //invalidate + window_peep_inventory_paint, //paint window_peep_emptysub }; @@ -460,7 +501,7 @@ void window_peep_open(rct_peep* peep){ window->min_height = 157; window->max_width = 500; window->max_height = 450; - window->flags = 1 << 8; + window->flags = WF_RESIZABLE; window->no_list_items = 0; window->selected_list_item = -1; window->colours[0] = 1; @@ -507,7 +548,7 @@ void window_peep_disable_widgets(rct_window* w){ } /* rct2: 0x00696A75 */ -void window_peep_close(){ +void window_peep_overview_close(){ rct_window* w; window_get_register(w); @@ -520,7 +561,7 @@ void window_peep_close(){ } /* rct2: 0x00696FBE */ -void window_peep_resize(){ +void window_peep_overview_resize(){ rct_window* w; window_get_register(w); @@ -528,7 +569,7 @@ void window_peep_resize(){ window_peep_disable_widgets(w); RCT2_CALLPROC_EBPSAFE(w->event_handlers[WE_INVALIDATE]); - window_invalidate_by_id(0xA97, w->number); + widget_invalidate(WC_PEEP, w->number, WIDX_MARQUEE); window_set_resize(w, 192, 159, 500, 450); @@ -577,7 +618,7 @@ void window_peep_overview_mouse_up(){ return; } - w->var_48C = peep->sprite_identifier; + w->var_48C = peep->x; RCT2_CALLPROC_X(0x0069A512, 0, 0, 0, 0, (int)peep, 0, 0); RCT2_CALLPROC_X(0x006EC473, 0, 0, 0, 0, (int)peep, 0, 0); @@ -600,6 +641,7 @@ void window_peep_overview_mouse_up(){ } } +/* rct2: 0x696AA0 */ void window_peep_set_page(rct_window* w, int page){ if (RCT2_GLOBAL(0x9DE518,uint32) & (1 << 3)) { @@ -752,23 +794,174 @@ void window_peep_viewport_init(rct_window* w){ window_invalidate(w); } +/** + * rct2: 0x6983dd + * used by window_staff as well + */ +void window_peep_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ + if (w->disabled_widgets & (1<widgets[WIDX_TAB_1]; + int width = widget->right - widget->left - 1; + int height = widget->bottom - widget->top - 1; + int x = widget->left + 1 + w->x; + int y = widget->top + 1 + w->y; + if (w->page == WINDOW_PEEP_OVERVIEW) height++; + + rct_drawpixelinfo* clip_dpi = clip_drawpixelinfo(dpi, x, width, y, height ); + if (!clip_dpi) return; + + x = 14; + y = 20; + + rct_peep* peep = GET_PEEP(w->number); + + if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == STAFF_TYPE_ENTERTAINER) + y++; + + int ebx = *(RCT2_ADDRESS(0x982708, uint32*)[peep->sprite_type * 2]) + 1; + + int eax = 0; + + if (w->page == WINDOW_PEEP_OVERVIEW){ + eax = w->var_494>>16; + eax &= 0xFFFC; + } + ebx += eax; + + int sprite_id = ebx | (peep->tshirt_colour << 19) | (peep->trousers_colour << 24) | 0xA0000000; + gfx_draw_sprite( clip_dpi, sprite_id, x, y, 0); + + // If holding a balloon + if (ebx >= 0x2A1D && ebx < 0x2A3D){ + ebx += 32; + ebx |= (peep->balloon_colour << 19) | 0x20000000; + gfx_draw_sprite( clip_dpi, ebx, x, y, 0); + } + + // If holding umbrella + if (ebx >= 0x2BBD && ebx < 0x2BDD){ + ebx += 32; + ebx |= (peep->umbrella_colour << 19) | 0x20000000; + gfx_draw_sprite(clip_dpi, ebx, x, y, 0); + } + + // If wearing hat + if (ebx >= 0x29DD && ebx < 0x29FD){ + ebx += 32; + ebx |= (peep->hat_colour << 19) | 0x20000000; + gfx_draw_sprite( clip_dpi, ebx, x, y, 0); + } +} + +/* rct2: 0x69869b */ +void window_peep_stats_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ + if (w->disabled_widgets & (1 << WIDX_TAB_2)) + return; + + rct_widget* widget = &w->widgets[WIDX_TAB_2]; + int x = widget->left + w->x; + int y = widget->top + w->y; + + rct_peep* peep = GET_PEEP(w->number); + int image_id = get_peep_face_sprite_large(peep); + if (w->page == WINDOW_PEEP_STATS){ + // If currently viewing this tab animate tab + // if it is very sick or angry. + switch (image_id){ + case SPR_PEEP_LARGE_FACE_VERY_VERY_SICK: + image_id += (w->frame_no / 4) & 0xF; + break; + case SPR_PEEP_LARGE_FACE_VERY_SICK: + image_id += (w->frame_no / 8) & 0x3; + break; + case SPR_PEEP_LARGE_FACE_ANGRY: + image_id += (w->frame_no / 8) & 0x3; + break; + } + } + gfx_draw_sprite(dpi, image_id, x, y, 0); +} + +/* rct2: 0x69861F */ +void window_peep_rides_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ + if (w->disabled_widgets & (1 << WIDX_TAB_3)) return; + + rct_widget* widget = &w->widgets[WIDX_TAB_3]; + int x = widget->left + w->x; + int y = widget->top + w->y; + + int image_id = SPR_TAB_RIDE_0; + + if ( w->page == WINDOW_PEEP_RIDES ){ + image_id += (w->frame_no / 4) & 0xF; + } + + gfx_draw_sprite(dpi, image_id, x, y, 0); +} + +/* rct2: 0x698597 */ +void window_peep_finance_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ + if (w->disabled_widgets & (1 << WIDX_TAB_4)) return; + + rct_widget* widget = &w->widgets[WIDX_TAB_4]; + int x = widget->left + w->x; + int y = widget->top + w->y; + + int image_id = SPR_TAB_FINANCES_SUMMARY_0; + + if ( w->page == WINDOW_PEEP_FINANCE ){ + image_id += (w->frame_no / 2) & 0x7; + } + + gfx_draw_sprite(dpi, image_id, x, y, 0); +} + +/* rct2: 0x6985D8 */ +void window_peep_thoughts_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ + if (w->disabled_widgets & (1 << WIDX_TAB_5)) return; + + rct_widget* widget = &w->widgets[WIDX_TAB_5]; + int x = widget->left + w->x; + int y = widget->top + w->y; + + int image_id = 5269; + + if ( w->page == WINDOW_PEEP_THOUGHTS ){ + image_id += (w->frame_no / 2) & 0x7; + } + + gfx_draw_sprite(dpi, image_id, x, y, 0); +} + +/* rct2: 0x698661 */ +void window_peep_inventory_tab_paint(rct_window* w, rct_drawpixelinfo* dpi){ + if (w->disabled_widgets & (1 << WIDX_TAB_6)) return; + + rct_widget* widget = &w->widgets[WIDX_TAB_6]; + int x = widget->left + w->x; + int y = widget->top + w->y; + + int image_id = 5326; + + gfx_draw_sprite(dpi, image_id, x, y, 0); +} + /* rct2: 0x696887 */ void window_peep_overview_paint(){ rct_window *w; rct_drawpixelinfo *dpi; - //rct_widget *labelWidget; window_paint_get_registers(w, dpi); - RCT2_CALLPROC_X(0x696887, 0, 0, 0, 0, (int)w, (int)dpi, 0); - return; window_draw_widgets(w, dpi); - //6983dd - //698597 - //6985d8 - //69861f - //69869b - //698661 + window_peep_overview_tab_paint(w, dpi); + window_peep_stats_tab_paint(w, dpi); + window_peep_rides_tab_paint(w, dpi); + window_peep_finance_tab_paint(w, dpi); + window_peep_thoughts_tab_paint(w, dpi); + window_peep_inventory_tab_paint(w, dpi); // Draw the viewport no sound sprite if (w->viewport){ @@ -880,45 +1073,1101 @@ void window_peep_overview_invalidate(){ window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6); } -void window_peep_overview_tab_paint( rct_window* w, rct_drawpixelinfo* dpi){ +/* rct2: 0x696F45 */ +void window_peep_overview_update(rct_window* w){ + int var_496 = w->var_494 >> 16; + var_496++; + var_496 %= 24; + w->var_494 &= 0x0000FFFF; + w->var_494 |= var_496 << 16; - if ( w->disabled_widgets & (1ULL<number, WIDX_TAB_1); + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_2); + + w->list_information_type += 2; - //ax - int x = w->widgets[WIDX_TAB_1].left + 1 + w->x; - //cx - int y = w->widgets[WIDX_TAB_1].top + 1 + w->y; - //bx - int width = w->widgets[WIDX_TAB_1].right - 1 - w->widgets[WIDX_TAB_1].left; - //dx - int height = w->widgets[WIDX_TAB_1].bottom - 1 - w->widgets[WIDX_TAB_1].top; + if ((w->var_494 & 0xFFFF) == 0xFFFF) + w->var_494 &= 0xFFFF0000; + else + w->var_494++; - if (w->page == WINDOW_PEEP_OVERVIEW){ - height++; + // Create the "I have the strangest feeling I am being watched thought" + if ((w->var_494 & 0xFFFF) >= 3840){ + if (!(w->var_494 & 0x3FF)){ + int rand = scenario_rand() & 0xFFFF; + if (rand <= 0x2AAA){ + rct_peep* peep = GET_PEEP(w->number); + RCT2_CALLPROC_X(0x699F5A, 0xFF47, 0, 0, 0, (int)peep, 0, 0); + } + } } - - rct_drawpixelinfo* cliped_dpi = clip_drawpixelinfo( dpi, x, width, y, height ); - - if (!cliped_dpi) return; - - int cx = 14; - int dx = 20; - - //ebp - rct_peep* peep = GET_PEEP(w->number); - - if (peep->type == 1 && peep->staff_type == 3) - dx++; - int eax = RCT2_GLOBAL(peep->sprite_type*8 + 0x982708, uint32); - int ebx = *(uint32*)eax; - ebx++; - eax = 0; - - if (w->page == WINDOW_PEEP_OVERVIEW){ - int ax = *((uint16*)w + 496 / 2); - ax &= ~((1<<0)|(1<<1)); - } - ebx += eax; - //698474 +} + +/* rct2:0x696A6A */ +void window_peep_overview_text_input(){ + short widgetIndex; + rct_window *w; + char _cl; + uint32* text; + + window_text_input_get_registers(w, widgetIndex, _cl, text); + + if (widgetIndex != WIDX_RENAME)return; + + if (!_cl) return; + + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, uint16) = 0x5AE; + + game_do_command(1, 1, w->number, *text, 22, *(text + 2), *(text + 1)); + game_do_command(2, 1, 0, *(text + 3), 22, *(text + 5), *(text + 4)); + game_do_command(0, 1, 0, *(text + 6), 22, *(text + 8), *(text + 7)); +} + +/* rct2: 0x696A5F */ +void window_peep_overview_tool_update(){ + short widgetIndex; + rct_window* w; + short x, y; + + window_tool_get_registers(w, widgetIndex, x, y); + + if (widgetIndex != WIDX_PICKUP) return; + + RCT2_CALLPROC_X(0x0068AAE1, x, y, 0, 0, (int)w, 0, 0); + + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= ~(1 << 0); + int temp_y = y + 16; + + int eax = x, ecx = 0, edx = widgetIndex, edi = 0, esi = (int)w, ebp = 0; + RCT2_CALLFUNC_X(0x689726, &eax, &temp_y, &ecx, &edx, &esi, &edi, &ebp); + if (eax != 0x8000){ + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= 1; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, uint16) = eax; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16) = eax; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16) = temp_y; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16) = temp_y; + RCT2_CALLPROC_X(0x0068AAE1, eax, temp_y, 0, 0, (int)w, 0, 0); + } + + RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_SPRITE, sint32) = -1; + eax = x; + int ebx = y; + edx = 0; + RCT2_CALLFUNC_X(0x00685ADC, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + if ((ebx & 0xFF) == 0) return; + + x--; + y += 16; + RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_X, uint16) = x; + RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_Y, uint16) = y; + w->var_492++; + if (w->var_492 >= 48)w->var_492 = 0; + + rct_peep* peep; + peep = GET_PEEP(w->number); + ebx = (RCT2_ADDRESS(0x982708, uint32*)[peep->sprite_type * 2])[22]; + ebx += w->var_492 >> 2; + + ebp = peep->tshirt_colour << 19; + ecx = peep->trousers_colour << 24; + + ebx |= ebp | ecx | 0xA0000000; + RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_SPRITE, uint32) = ebx; +} + +/* rct2: 0x664F72 */ +int sub_664F72(int x, int y, int edx){ + if (x > 0x1FFF || y > 0x1FFF){ + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 0x6C1; + return 1; + } + + rct_map_element* map_element = map_get_surface_element_at(x / 32, y / 32); + if (map_element->properties.surface.ownership & 0x20) return 0; + if (!(map_element->properties.surface.ownership & 0x10)){ + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 0x6C1; + return 1; + } + + edx >>= 3; + if ((edx & 0xFF) < map_element->base_height)return 0; + edx = (edx & 0xFF) - 2; + if (edx > map_element->base_height)return 0; + + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = 0x6C1; + return 1; +} + +/* rct2: 0x696A54 */ +void window_peep_overview_tool_down(){ + short widgetIndex; + rct_window* w; + short x, y; + + window_tool_get_registers(w, widgetIndex, x, y); + + if (widgetIndex != WIDX_PICKUP) return; + + int eax = x, ebx = y, ecx = 0, edx = widgetIndex, edi = 0, esi = (int)w, ebp = 0; + ebx += 16; + RCT2_CALLFUNC_X(0x689726, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + + if (eax == 0x8000)return; + + eax += 16; + ecx = ebx + 16; + edx = ((uint8*)edx)[2] * 8 + 16; + int _eax = eax & 0xFFE0, _ebx = ebx & 0xFFE0; + if (sub_664F72(eax & 0xFFE0, ebx & 0xFFE0, edx)){ + window_error_open(0x785,-1); + return; + } + int _edx = edx>>3; + _edx &= 0xFFFF00FF; + _edx |= edx << 8; + _edx += 0x100; + int flags = RCT2_CALLPROC_X(0x68B93A, eax & 0xFFE0, 0xF, ebx & 0xFFE0, _edx, (int)w, 0, 0); + + if (flags & 0x100){ + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) != 0x3A5 ){ + if (RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) != 0x49B){ + window_error_open(0x785, -1); + return; + } + } + } + + rct_peep* peep = GET_PEEP(w->number); + RCT2_CALLPROC_X(0x0069E9D3, eax, 0, ebx, edx, (int)peep, 0, 0); + 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->state = 0; + RCT2_CALLPROC_X(0x0069A42F, 0, 0, 0, 0, (int)peep, 0, 0); + peep->var_71 = 0xFF; + peep->var_6D = 0; + peep->var_70 = 0; + peep->var_6E = 0xFF; + peep->var_C4 = 0; + + peep->happiness_growth_rate -= 10; + if (peep->happiness_growth_rate < 0)peep->happiness_growth_rate = 0; + + RCT2_CALLPROC_X(0x00693B58, 0, 0, 0, 0, (int)peep, 0, 0); + tool_cancel(); + RCT2_GLOBAL(0x9DE550, sint32) = -1; +} + +/* rct2: 0x696A49 */ +void window_peep_overview_tool_abort(){ + short widgetIndex; + rct_window* w; + short x, y; + + window_tool_get_registers(w, widgetIndex, x, y); + if (widgetIndex != WIDX_PICKUP) return; + + rct_peep* peep = GET_PEEP(w->number); + if (peep->state != PEEP_STATE_PICKED) return; + + RCT2_CALLPROC_X(0x0069E9D3, w->var_48C, 0, peep->y, peep->z + 8, (int)peep, 0, 0); + RCT2_CALLPROC_X(0x006EC473, 0, 0, 0, 0, (int)peep, 0, 0); + + if (peep->x != 0x8000){ + RCT2_CALLPROC_X(0x0069A409, 0, 0, 0, 0, (int)peep, 0, 0); + peep->state = 0; + RCT2_CALLPROC_X(0x0069A42F, 0, 0, 0, 0, (int)peep, 0, 0); + peep->var_71 = 0xFF; + peep->var_6D = 0; + peep->var_70 = 0; + peep->var_6E = 0; + peep->var_C4 = 0; + } + + RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_SPRITE, sint32) = -1; +} + +/* rct2:0x69744F, 0x697795, 0x697BDD, 0x697E18, 0x698279 + * This is a combination of 5 functions that were identical + */ +void window_peep_mouse_up(){ + short widgetIndex; + rct_window* w; + window_widget_get_registers(w, widgetIndex); + + switch (widgetIndex){ + case WIDX_CLOSE: + window_close(w); + break; + case WIDX_TAB_1: + case WIDX_TAB_2: + case WIDX_TAB_3: + case WIDX_TAB_4: + case WIDX_TAB_5: + case WIDX_TAB_6: + window_peep_set_page(w, widgetIndex - WIDX_TAB_1); + break; + } +} + +/* rct2: 0x697488 */ +void window_peep_stats_resize(){ + rct_window* w; + window_get_register(w); + + window_set_resize(w, 192, 162, 192, 162); +} + +/* rct2: 0x6974ED, 0x00697959, 0x00697C7B, 0x00697ED2, 0x00698333 + * This is a combination of 5 functions that were identical + */ +void window_peep_unknown_05(){ + rct_window* w; + window_get_register(w); + + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_1); +} + +/* rct2: 0x69746A */ +void window_peep_stats_update(){ + rct_window* w; + window_get_register(w); + + w->frame_no++; + rct_peep* peep = GET_PEEP(w->number); + peep->var_45 &= ~(1<<1); + + window_invalidate(w); +} + +/* rct2: 0x69707D */ +void window_peep_stats_invalidate(){ + rct_window* w; + window_get_register(w); + + if (w->widgets != window_peep_page_widgets[w->page]) { + w->widgets = window_peep_page_widgets[w->page]; + window_init_scroll_widgets(w); + } + + w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); + + rct_peep* peep = GET_PEEP(w->number); + RCT2_GLOBAL(0x13CE952, uint16) = peep->name_string_idx; + RCT2_GLOBAL(0x13CE954, uint32) = peep->id; + + window_peep_stats_widgets[WIDX_BACKGROUND].right = w->width - 1; + window_peep_stats_widgets[WIDX_BACKGROUND].bottom = w->height - 1; + + window_peep_stats_widgets[WIDX_PAGE_BACKGROUND].right = w->width - 1; + window_peep_stats_widgets[WIDX_PAGE_BACKGROUND].bottom = w->height - 1; + + window_peep_stats_widgets[WIDX_TITLE].right = w->width - 2; + + window_peep_stats_widgets[WIDX_CLOSE].left = w->width - 13; + window_peep_stats_widgets[WIDX_CLOSE].right = w->width - 3; + + window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6); +} + +/* rct2: 0x0069711D */ +void window_peep_stats_paint(){ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + window_peep_overview_tab_paint(w, dpi); + window_peep_stats_tab_paint(w, dpi); + window_peep_rides_tab_paint(w, dpi); + window_peep_finance_tab_paint(w, dpi); + window_peep_thoughts_tab_paint(w, dpi); + window_peep_inventory_tab_paint(w, dpi); + + //ebx + rct_peep* peep = GET_PEEP(w->number); + + // Not sure why this is not stats widgets + //cx + int x = w->x + window_peep_rides_widgets[WIDX_PAGE_BACKGROUND].left + 4; + //dx + int y = w->y + window_peep_rides_widgets[WIDX_PAGE_BACKGROUND].top + 4; + + //Happiness + gfx_draw_string_left(dpi, 1662, (void*)0x13CE952, 0, x, y); + + int happiness = peep->happiness; + if (happiness < 10)happiness = 10; + int ebp = 14; + if (happiness < 50){ + ebp |= 0x80000000; + } + RCT2_CALLPROC_X(0x6974FC, happiness, (int)peep, x, y, (int)w, (int)dpi, ebp); + + //Energy + y += 10; + gfx_draw_string_left(dpi, 1664, (void*)0x13CE952, 0, x, y); + + int energy = ((peep->energy - 32) * 85) / 32; + ebp = 14; + if (energy < 50){ + ebp |= 0x80000000; + } + if (energy < 10)energy = 10; + RCT2_CALLPROC_X(0x6974FC, energy, (int)peep, x, y, (int)w, (int)dpi, ebp); + + //Hunger + y += 10; + gfx_draw_string_left(dpi, 1665, (void*)0x13CE952, 0, x, y); + + int hunger = peep->hunger; + if (hunger > 190) hunger = 190; + + hunger -= 32; + if (hunger < 0) hunger = 0; + hunger *= 51; + hunger /= 32; + hunger = 0xFF & ~hunger; + + ebp = 28; + if (hunger > 170){ + ebp |= 0x80000000; + } + RCT2_CALLPROC_X(0x6974FC, hunger, (int)peep, x, y, (int)w, (int)dpi, ebp); + + //Thirst + y += 10; + gfx_draw_string_left(dpi, 1666, (void*)0x13CE952, 0, x, y); + + int thirst = peep->thirst; + if (thirst > 190) thirst = 190; + + thirst -= 32; + if (thirst < 0) thirst = 0; + thirst *= 51; + thirst /= 32; + thirst = 0xFF & ~thirst; + + ebp = 28; + if (thirst > 170){ + ebp |= 0x80000000; + } + RCT2_CALLPROC_X(0x6974FC, thirst, (int)peep, x, y, (int)w, (int)dpi, ebp); + + //Nausea + y += 10; + gfx_draw_string_left(dpi, 1663, (void*)0x13CE952, 0, x, y); + + int nausea = peep->nausea - 32; + + if (nausea < 0) nausea = 0; + nausea *= 36; + nausea /= 32; + + ebp = 28; + if (nausea > 120){ + ebp |= 0x80000000; + } + RCT2_CALLPROC_X(0x6974FC, nausea, (int)peep, x, y, (int)w, (int)dpi, ebp); + + //Bathroom + y += 10; + gfx_draw_string_left(dpi, 1667, (void*)0x13CE952, 0, x, y); + + int bathroom = peep->bathroom - 32; + if (bathroom > 210) bathroom = 210; + + bathroom -= 32; + if (bathroom < 0) bathroom = 0; + bathroom *= 45; + bathroom /= 32; + + ebp = 28; + if (bathroom > 160){ + ebp |= 0x80000000; + } + RCT2_CALLPROC_X(0x6974FC, bathroom, (int)peep, x, y, (int)w, (int)dpi, ebp); + + // Time in park + y += 11; + if (peep->time_in_park != -1){ + int eax = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, uint32); + eax -= peep->time_in_park; + eax >>= 11; + RCT2_GLOBAL(0x13CE952, uint16) = eax & 0xFFFF; + gfx_draw_string_left(dpi, 1458, (void*)0x13CE952, 0, x, y); + } + + y += 19; + gfx_fill_rect_inset(dpi, x, y - 6, x + 179, y - 5, w->colours[1], 32); + + // Preferred Ride + gfx_draw_string_left(dpi, 1657, (void*)0, 0, x, y); + y += 10; + + // Intensity + int intensity = peep->intensity / 16; + RCT2_GLOBAL(0x13CE952, uint16) = intensity; + int string_id = 1658; + if (peep->intensity & 0xF){ + RCT2_GLOBAL(0x13CE952, uint16) = peep->intensity & 0xF; + RCT2_GLOBAL(0x13CE954, uint16) = intensity; + string_id = 1659; + if (intensity == 15) string_id = 1660; + } + + gfx_draw_string_left(dpi, string_id, (void*)0x13CE952, 0, x + 4, y); + + // Nausea tolerance + y += 10; + int nausea_tolerance = peep->nausea_tolerance & 0x3; + RCT2_GLOBAL(0x13CE952, uint16) = nausea_tolerance + 2368; + gfx_draw_string_left(dpi, 1661, (void*)0x13CE952, 0, x, y); +} + +/* rct2: 0x006978F4 */ +void window_peep_rides_resize(){ + rct_window* w; + window_get_register(w); + + window_set_resize(w, 192, 128, 500, 400); +} + +/* rct2: 0x6977B0 */ +void window_peep_rides_update(){ + rct_window* w; + window_get_register(w); + + w->frame_no++; + + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_2); + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_3); + + rct_peep* peep = GET_PEEP(w->number); + + // Every 2048 ticks do a full window_invalidate + int number_of_ticks = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_TICKS, uint32) - peep->time_in_park; + if (!(number_of_ticks & 0x7FF)) window_invalidate(w); + + uint8 curr_list_position = 0; + for (uint8 ride_id = 0; ride_id < 255; ++ride_id){ + // Offset to the ride_id bit in peep_rides_been_on + uint8 ride_id_bit = ride_id & 0x3; + uint8 ride_id_offset = ride_id / 8; + if (peep->rides_been_on[ride_id_offset] & (1 << ride_id_bit)){ + rct_ride* ride = GET_RIDE(ride_id); + if (RCT2_ADDRESS(0x97C3AF, uint8)[ride->type] == 0){ + w->list_item_positions[curr_list_position] = ride_id; + curr_list_position++; + } + } + } + // If there are new items + if (w->no_list_items != curr_list_position){ + w->no_list_items = curr_list_position; + window_invalidate(w); + } +} + +/* rct2: 0x697844 */ +void window_peep_rides_tooltip(){ + RCT2_GLOBAL(0x013CE952, uint16) = STR_LIST; +} + +/* rct2: 0x69784E */ +void window_peep_rides_scroll_get_size(){ + rct_window *w; + + window_get_register(w); + + int height = w->no_list_items * 10; + + if (w->selected_list_item != -1){ + w->selected_list_item = -1; + window_invalidate(w); + } + + int visable_height = height + - window_peep_rides_widgets[WIDX_RIDE_SCROLL].bottom + + window_peep_rides_widgets[WIDX_RIDE_SCROLL].top + + 21; + + if (visable_height < 0) visable_height = 0; + + if (visable_height < w->scrolls[0].v_top){ + w->scrolls[0].v_top = visable_height; + window_invalidate(w); + } + +#ifdef _MSC_VER + __asm mov ecx, 0 +#else + __asm__("mov ecx, 0 "); +#endif + +#ifdef _MSC_VER + __asm mov edx, height +#else + __asm__("mov edx, %[height] " : [height] "+m" (height)); +#endif +} + +/* rct2: 0x006978CC */ +void window_peep_rides_scroll_mouse_down(){ + int index; + short x, y; + rct_window *w; + + window_scrollmouse_get_registers(w, x, y); + + index = y / 10; + if (index >= w->no_list_items) return; + + window_ride_main_open(w->list_item_positions[index]); +} + +/* rct2: 0x0069789C */ +void window_peep_rides_scroll_mouse_over(){ + int index; + short x, y; + rct_window *w; + + window_scrollmouse_get_registers(w, x, y); + + index = y / 10; + if (index >= w->no_list_items)return; + + if (index == w->selected_list_item)return; + w->selected_list_item = index; + + window_invalidate(w); +} + +/* rct2: 0x0069757A */ +void window_peep_rides_invalidate(){ + rct_window* w; + window_get_register(w); + if (window_peep_page_widgets[w->page] != w->widgets){ + w->widgets = window_peep_page_widgets[w->page]; + window_init_scroll_widgets(w); + } + + w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); + + rct_peep* peep = GET_PEEP(w->number); + RCT2_GLOBAL(0x13CE952, uint16) = peep->name_string_idx; + RCT2_GLOBAL(0x13CE954, uint32) = peep->id; + + window_peep_rides_widgets[WIDX_BACKGROUND].right = w->width - 1; + window_peep_rides_widgets[WIDX_BACKGROUND].bottom = w->height - 1; + + window_peep_rides_widgets[WIDX_PAGE_BACKGROUND].right = w->width - 1; + window_peep_rides_widgets[WIDX_PAGE_BACKGROUND].bottom = w->height - 1; + + window_peep_rides_widgets[WIDX_TITLE].right = w->width - 2; + + window_peep_rides_widgets[WIDX_CLOSE].left = w->width - 13; + window_peep_rides_widgets[WIDX_CLOSE].right = w->width - 3; + + window_peep_rides_widgets[WIDX_RIDE_SCROLL].right = w->width - 4; + window_peep_rides_widgets[WIDX_RIDE_SCROLL].bottom = w->height - 15; + + window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6); +} + +/* rct2: 0x00697637 */ +void window_peep_rides_paint(){ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + window_peep_overview_tab_paint(w, dpi); + window_peep_stats_tab_paint(w, dpi); + window_peep_rides_tab_paint(w, dpi); + window_peep_finance_tab_paint(w, dpi); + window_peep_thoughts_tab_paint(w, dpi); + window_peep_inventory_tab_paint(w, dpi); + + rct_peep* peep = GET_PEEP(w->number); + + //cx + int x = w->x + window_peep_rides_widgets[WIDX_PAGE_BACKGROUND].left + 2; + //dx + int y = w->y + window_peep_rides_widgets[WIDX_PAGE_BACKGROUND].top + 2; + + gfx_draw_string_left(dpi, 2292, (void*)0, 0, x, y); + + y = w->y + window_peep_rides_widgets[WIDX_PAGE_BACKGROUND].bottom - 12; + + int ride_string_id = 3094; + int ride_string_arguments = 0; + if (peep->favourite_ride != 0xFF){ + rct_ride* ride = GET_RIDE(peep->favourite_ride); + ride_string_arguments = ride->name_arguments; + ride_string_id = ride->name; + } + RCT2_GLOBAL(0x13CE952, uint16) = ride_string_id; + RCT2_GLOBAL(0x13CE954, uint32) = ride_string_arguments; + + gfx_draw_string_left_clipped(dpi, 3093, (void*)0x13CE952, 0, x, y, w->width - 14); +} + +/* rct2: 0x006976FC */ +void window_peep_rides_scroll_paint(){ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + // ax + int left = dpi->x; + // bx + int right = dpi->x + dpi->width - 1; + // cx + int top = dpi->y; + // dx + int bottom = dpi->y + dpi->height - 1; + + int colour = RCT2_ADDRESS(0x141FC48, uint8)[w->colours[1] * 8]; + gfx_fill_rect(dpi, left, top, right, bottom, colour); + + for (int list_index = 0; list_index < w->no_list_items; list_index++){ + int y = list_index * 10; + int string_format = 1191; + if (list_index == w->selected_list_item){ + gfx_fill_rect(dpi, 0, y, 800, y + 9, 0x2000031); + string_format = 1193; + } + rct_ride* ride = GET_RIDE(w->list_item_positions[list_index]); + + gfx_draw_string_left(dpi, string_format, (void*)&ride->name, 0, 0, y - 1); + } +} + +/* rct2: 0x00697C16 */ +void window_peep_finance_resize(){ + rct_window* w; + window_get_register(w); + + window_set_resize(w, 210, 134, 210, 134); +} + +/* rct2: 0x00697BF8 */ +void window_peep_finance_update(){ + rct_window* w; + window_get_register(w); + + w->frame_no++; + + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_2); + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_4); +} + +/* rct2: 0x00697968 */ +void window_peep_finance_invalidate(){ + rct_window* w; + window_get_register(w); + + if (window_peep_page_widgets[w->page] != w->widgets){ + w->widgets = window_peep_page_widgets[w->page]; + window_init_scroll_widgets(w); + } + + w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); + + rct_peep* peep = GET_PEEP(w->number); + + RCT2_GLOBAL(0x13CE952, uint16) = peep->name_string_idx; + RCT2_GLOBAL(0x13CE954, uint32) = peep->id; + + window_peep_finance_widgets[WIDX_BACKGROUND].right = w->width - 1; + window_peep_finance_widgets[WIDX_BACKGROUND].bottom = w->height - 1; + + window_peep_finance_widgets[WIDX_PAGE_BACKGROUND].right = w->width - 1; + window_peep_finance_widgets[WIDX_PAGE_BACKGROUND].bottom = w->height - 1; + + window_peep_finance_widgets[WIDX_TITLE].right = w->width - 2; + + window_peep_finance_widgets[WIDX_CLOSE].left = w->width - 13; + window_peep_finance_widgets[WIDX_CLOSE].right = w->width - 3; + + window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6); +} + +/* rct2: 0x00697A08 */ +void window_peep_finance_paint(){ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + window_peep_overview_tab_paint(w, dpi); + window_peep_stats_tab_paint(w, dpi); + window_peep_rides_tab_paint(w, dpi); + window_peep_finance_tab_paint(w, dpi); + window_peep_thoughts_tab_paint(w, dpi); + window_peep_inventory_tab_paint(w, dpi); + + rct_peep* peep = GET_PEEP(w->number); + + //cx + int x = w->x + window_peep_finance_widgets[WIDX_PAGE_BACKGROUND].left + 4; + //dx + int y = w->y + window_peep_finance_widgets[WIDX_PAGE_BACKGROUND].top + 4; + + // Cash in pocket + RCT2_GLOBAL(0x13CE952, money32) = peep->cash_in_pocket; + gfx_draw_string_left(dpi, 1457, (void*)0x13CE952, 0, x, y); + + // Cash spent + y += 10; + RCT2_GLOBAL(0x13CE952, money32) = peep->cash_spent; + gfx_draw_string_left(dpi, 1456, (void*)0x13CE952, 0, x, y); + + y += 20; + gfx_fill_rect_inset(dpi, x, y - 6, x + 179, y - 5, w->colours[1], 32); + + // Paid to enter + RCT2_GLOBAL(0x13CE952, money32) = peep->paid_to_enter; + gfx_draw_string_left(dpi, 2296, (void*)0x13CE952, 0, x, y); + + // Paid on rides + y += 10; + RCT2_GLOBAL(0x13CE952, money32) = peep->paid_on_rides; + RCT2_GLOBAL(0x13CE956, uint16) = peep->staff_type; + if (peep->staff_type != 1){ + gfx_draw_string_left(dpi, 2298, (void*)0x13CE952, 0, x, y); + } + else{ + gfx_draw_string_left(dpi, 2297, (void*)0x13CE952, 0, x, y); + } + + // Paid on food + y += 10; + RCT2_GLOBAL(0x13CE952, money32) = peep->paid_on_food; + RCT2_GLOBAL(0x13CE956, uint16) = peep->no_of_food; + if (peep->no_of_food != 1){ + gfx_draw_string_left(dpi, 2300, (void*)0x13CE952, 0, x, y); + } + else{ + gfx_draw_string_left(dpi, 2299, (void*)0x13CE952, 0, x, y); + } + + // Paid on drinks + y += 10; + RCT2_GLOBAL(0x13CE952, money32) = peep->paid_on_drink; + RCT2_GLOBAL(0x13CE956, uint16) = peep->no_of_drinks; + if (peep->no_of_drinks != 1){ + gfx_draw_string_left(dpi, 2302, (void*)0x13CE952, 0, x, y); + } + else{ + gfx_draw_string_left(dpi, 2301, (void*)0x13CE952, 0, x, y); + } + + // Paid on souvenirs + y += 10; + RCT2_GLOBAL(0x13CE952, money32) = peep->paid_on_souvenirs; + RCT2_GLOBAL(0x13CE956, uint16) = peep->no_of_souvenirs; + if (peep->no_of_souvenirs != 1){ + gfx_draw_string_left(dpi, 2304, (void*)0x13CE952, 0, x, y); + } + else{ + gfx_draw_string_left(dpi, 2303, (void*)0x13CE952, 0, x, y); + } +} + +/* rct2: 0x00697E33 */ +void window_peep_thoughts_resize(){ + rct_window* w; + window_get_register(w); + + rct_peep* peep = GET_PEEP(w->number); + if (peep->var_45 & 1){ + peep->var_45 &=~(1 << 0); + window_invalidate(w); + } + + window_set_resize(w, 192, 159, 500, 450); +} + +/* rct2: 0x00697EB4 */ +void window_peep_thoughts_update(){ + rct_window* w; + window_get_register(w); + + w->frame_no++; + + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_2); + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_5); +} + +/* rct2: 0x00697C8A */ +void window_peep_thoughts_invalidate(){ + rct_window* w; + window_get_register(w); + + if (window_peep_page_widgets[w->page] != w->widgets){ + w->widgets = window_peep_page_widgets[w->page]; + window_init_scroll_widgets(w); + } + + w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); + + rct_peep* peep = GET_PEEP(w->number); + + RCT2_GLOBAL(0x13CE952, uint16) = peep->name_string_idx; + RCT2_GLOBAL(0x13CE954, uint32) = peep->id; + + window_peep_thoughts_widgets[WIDX_BACKGROUND].right = w->width - 1; + window_peep_thoughts_widgets[WIDX_BACKGROUND].bottom = w->height - 1; + + window_peep_thoughts_widgets[WIDX_PAGE_BACKGROUND].right = w->width - 1; + window_peep_thoughts_widgets[WIDX_PAGE_BACKGROUND].bottom = w->height - 1; + + window_peep_thoughts_widgets[WIDX_TITLE].right = w->width - 2; + + window_peep_thoughts_widgets[WIDX_CLOSE].left = w->width - 13; + window_peep_thoughts_widgets[WIDX_CLOSE].right = w->width - 3; + + window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6); +} + +/* rct2: 0x00697D2A */ +void window_peep_thoughts_paint(){ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + window_peep_overview_tab_paint(w, dpi); + window_peep_stats_tab_paint(w, dpi); + window_peep_rides_tab_paint(w, dpi); + window_peep_finance_tab_paint(w, dpi); + window_peep_thoughts_tab_paint(w, dpi); + window_peep_inventory_tab_paint(w, dpi); + + rct_peep* peep = GET_PEEP(w->number); + + //cx + int x = w->x + window_peep_thoughts_widgets[WIDX_PAGE_BACKGROUND].left + 4; + //dx + int y = w->y + window_peep_thoughts_widgets[WIDX_PAGE_BACKGROUND].top + 4; + + gfx_draw_string_left(dpi, 1654, (void*)0, 0, x, y); + + y += 10; + for (rct_peep_thought* thought = peep->thoughts; thought < &peep->thoughts[PEEP_MAX_THOUGHTS]; ++thought){ + if (thought->type == PEEP_THOUGHT_TYPE_NONE) return; + if (thought->var_2 == 0) continue; + + uint32 argument1, argument2; + get_arguments_from_thought(*thought, &argument1, &argument2); + RCT2_GLOBAL(0x13CE952, uint32) = argument1; + RCT2_GLOBAL(0x13CE956, uint32) = argument2; + + int width = window_peep_thoughts_widgets[WIDX_PAGE_BACKGROUND].right + - window_peep_thoughts_widgets[WIDX_PAGE_BACKGROUND].left + - 8; + + y += gfx_draw_string_left_wrapped(dpi, (void*)0x13CE952, x, y, width, 1191, 0); + + // If this is the last visable line end drawing. + if (y > w->y + window_peep_thoughts_widgets[WIDX_PAGE_BACKGROUND].bottom - 32) return; + } +} + + +/* rct2: 0x00698294 */ +void window_peep_inventory_resize(){ + rct_window* w; + window_get_register(w); + + rct_peep* peep = GET_PEEP(w->number); + if (peep->var_45 & (1<<3)){ + peep->var_45 &= ~(1 << 3); + window_invalidate(w); + } + + window_set_resize(w, 192, 159, 500, 450); +} + +/* rct2: 0x00698315 */ +void window_peep_inventory_update(){ + rct_window* w; + window_get_register(w); + + w->frame_no++; + + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_2); + widget_invalidate(WC_PEEP, w->number, WIDX_TAB_6); +} + +/* rct2: 0x00697EE1 */ +void window_peep_inventory_invalidate(){ + rct_window* w; + window_get_register(w); + + if (window_peep_page_widgets[w->page] != w->widgets){ + w->widgets = window_peep_page_widgets[w->page]; + window_init_scroll_widgets(w); + } + + w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1); + + rct_peep* peep = GET_PEEP(w->number); + + RCT2_GLOBAL(0x13CE952, uint16) = peep->name_string_idx; + RCT2_GLOBAL(0x13CE954, uint32) = peep->id; + + window_peep_inventory_widgets[WIDX_BACKGROUND].right = w->width - 1; + window_peep_inventory_widgets[WIDX_BACKGROUND].bottom = w->height - 1; + + window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].right = w->width - 1; + window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].bottom = w->height - 1; + + window_peep_inventory_widgets[WIDX_TITLE].right = w->width - 2; + + window_peep_inventory_widgets[WIDX_CLOSE].left = w->width - 13; + window_peep_inventory_widgets[WIDX_CLOSE].right = w->width - 3; + + window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_6); +} + +/* rct2: 0x00697F81 */ +void window_peep_inventory_paint(){ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + window_peep_overview_tab_paint(w, dpi); + window_peep_stats_tab_paint(w, dpi); + window_peep_rides_tab_paint(w, dpi); + window_peep_finance_tab_paint(w, dpi); + window_peep_thoughts_tab_paint(w, dpi); + window_peep_inventory_tab_paint(w, dpi); + + rct_peep* peep = GET_PEEP(w->number); + + //cx + int x = w->x + window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].left + 4; + //dx + int y = w->y + window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].top + 2; + + int max_y = w->y + w->height - 22; + int no_items = 0; + + gfx_draw_string_left(dpi, 1810, (void*)0, 0, x, y); + + y += 10; + + for (int i = 0; y < max_y && i < 28; ++i){ + int item_flag = 1 << i; + if (!(peep->item_standard_flags & item_flag))continue; + no_items++; + + RCT2_GLOBAL(0x13CE952, uint32) = 5061 + i; + + switch (item_flag){ + case PEEP_ITEM_TSHIRT: + RCT2_GLOBAL(0x13CE952, uint32) |= 0x20000000 | peep->tshirt_colour << 19; + break; + case PEEP_ITEM_HAT: + RCT2_GLOBAL(0x13CE952, uint32) |= 0x20000000 | peep->hat_colour << 19; + break; + case PEEP_ITEM_BALLOON: + RCT2_GLOBAL(0x13CE952, uint32) |= 0x20000000 | peep->balloon_colour << 19; + break; + case PEEP_ITEM_UMBRELLA: + RCT2_GLOBAL(0x13CE952, uint32) |= 0x20000000 | peep->umbrella_colour << 19; + break; + } + + int string_format = 2072 + i; + if (string_format >= 2104) string_format += 84; //??? i is never 32 + + RCT2_GLOBAL(0x13CE956, uint16) = string_format; + RCT2_GLOBAL(0x13CE958, uint16) = RCT2_GLOBAL(0x13573D4, uint16); + RCT2_GLOBAL(0x13CE95A, uint32) = RCT2_GLOBAL(0x13573D8, uint32); + rct_ride* ride; + + switch (item_flag){ + case PEEP_ITEM_PHOTO: + ride = GET_RIDE(peep->photo1_ride_ref); + RCT2_GLOBAL(0x13CE958, uint16) = ride->name; + RCT2_GLOBAL(0x13CE95A, uint32) = ride->name_arguments; + break; + case PEEP_ITEM_VOUCHER: + RCT2_GLOBAL(0x13CE958, uint16) = peep->var_F0 + 2418; + RCT2_GLOBAL(0x13CE95A, uint16) = RCT2_GLOBAL(0x13573D4, uint16); + RCT2_GLOBAL(0x13CE95C, uint32) = RCT2_GLOBAL(0x13573D8, uint32); + + if (peep->var_F0 == 0 || peep->var_F0 == 2)break; + + int voucher_id = peep->var_F1 + 1988; + if (voucher_id >= 2020) voucher_id += 102; + + RCT2_GLOBAL(0x13CE95A, uint16) = voucher_id; + + if (peep->var_F0 == 3)break; + ride = GET_RIDE(peep->var_F1); + RCT2_GLOBAL(0x13CE95A, uint16) = ride->name; + RCT2_GLOBAL(0x13CE95C, uint32) = ride->name_arguments; + break; + } + + int width = window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].right + - window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].left + - 8; + + y += gfx_draw_string_left_wrapped(dpi, (void*)0x13CE952, x, y, width, 1875, 0); + } + + for (int i = 0; y < max_y && i < 22; ++i){ + int item_flag = 1 << i; + + if (!(peep->item_extra_flags & item_flag))continue; + no_items++; + + RCT2_GLOBAL(0x13CE952, uint32) = 5089 + i; + RCT2_GLOBAL(0x13CE956, uint16) = 2188; + RCT2_GLOBAL(0x13CE958, uint16) = RCT2_GLOBAL(0x13573D4, uint16); + RCT2_GLOBAL(0x13CE95A, uint32) = RCT2_GLOBAL(0x13573D8, uint32); + + if (i < 3){ + int ride_id = 0; + switch (item_flag){ + case PEEP_ITEM_PHOTO2: + ride_id = peep->photo2_ride_ref; + break; + case PEEP_ITEM_PHOTO3: + ride_id = peep->photo3_ride_ref; + break; + case PEEP_ITEM_PHOTO4: + ride_id = peep->photo4_ride_ref; + break; + } + + rct_ride* ride = GET_RIDE(ride_id); + RCT2_GLOBAL(0x13CE958, uint16) = ride->name; + RCT2_GLOBAL(0x13CE95A, uint32) = ride->name_arguments; + } + + int width = window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].right + - window_peep_inventory_widgets[WIDX_PAGE_BACKGROUND].left + - 8; + + y += gfx_draw_string_left_wrapped(dpi, (void*)0x13CE952, x, y, width, 1875, 0); + } + + if (!no_items){ + gfx_draw_string_left(dpi, 2293, (void*)0, 0, x, y); + } } 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..1b899f99b0 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, @@ -332,7 +333,7 @@ void window_staff_peep_disable_widgets(rct_window* w) } /** - * Same as window_peep_close. + * Same as window_peep_overview_close. * rct2: 0x006BDFF8 */ void window_staff_peep_overview_close() @@ -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)) { diff --git a/src/window_title_scenarioselect.c b/src/window_title_scenarioselect.c index 38246736e7..870a17f795 100644 --- a/src/window_title_scenarioselect.c +++ b/src/window_title_scenarioselect.c @@ -223,6 +223,7 @@ static void window_scenarioselect_scrollgetsize() } +/* rct2: 0x6780FE */ static void window_scenarioselect_scrollmousedown() { int i; @@ -249,6 +250,7 @@ static void window_scenarioselect_scrollmousedown() } } +/* rct2: 0x678162 */ static void window_scenarioselect_scrollmouseover() { int i;