From c74640d9c465f1df1f0eacd1f8574aa62af61741 Mon Sep 17 00:00:00 2001 From: qcz Date: Sun, 10 Aug 2014 14:31:41 +0200 Subject: [PATCH 01/13] Start to decompile hire new staff member command (not working yet) --- src/game.c | 375 ++++++++++++++++++++++++++++++++++++++++++++++- src/peep.h | 23 +-- src/string_ids.h | 9 +- 3 files changed, 392 insertions(+), 15 deletions(-) diff --git a/src/game.c b/src/game.c index 101d760904..d986cf8a12 100644 --- a/src/game.c +++ b/src/game.c @@ -45,6 +45,7 @@ int _gameSpeed = 1; +int previousPeepSpriteIndex = 0; void game_handle_input(); void game_handle_keyboard_input(); @@ -2079,6 +2080,8 @@ static int game_check_affordability(int cost) } static uint32 game_do_command_table[58]; +typedef void (GAME_COMMAND_POINTER)(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp); +static GAME_COMMAND_POINTER* new_game_command_table[58]; /** * @@ -2120,7 +2123,11 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int * *ebx &= ~1; // Primary command - RCT2_CALLFUNC_X(game_do_command_table[command], eax, ebx, ecx, edx, esi, edi, ebp); + if (game_do_command_table[command] == 0) { + new_game_command_table[command](eax, ebx, ecx, edx, esi, edi, ebp); + } else { + RCT2_CALLFUNC_X(game_do_command_table[command], eax, ebx, ecx, edx, esi, edi, ebp); + } cost = *ebx; if (cost != 0x80000000) { @@ -2143,7 +2150,11 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int * } // Secondary command - RCT2_CALLFUNC_X(game_do_command_table[command], eax, ebx, ecx, edx, esi, edi, ebp); + if (game_do_command_table[command] == 0) { + new_game_command_table[command](eax, ebx, ecx, edx, esi, edi, ebp); + } else { + RCT2_CALLFUNC_X(game_do_command_table[command], eax, ebx, ecx, edx, esi, edi, ebp); + } *edx = *ebx; if (*edx != 0x80000000 && *edx < cost) @@ -2266,6 +2277,301 @@ static void game_load_or_quit() } +/** +* +* rct2: 0x0069ED0B +*/ +static void sub_69ED0B(rct_peep* sprite, int cl) +{ + if (sprite->var_08 == 0) + return; + + int ebx = sprite->var_08; + int ax = sprite->next; + + if (sprite->previous != 0xFFFF) { + g_sprite_list[sprite->previous].peep.next = ax; + } + else { + RCT2_ADDRESS(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)[ebx] = ax; + } + + sprite->previous = 0xFFFF; + sprite->var_08 = cl; + + // set next sprite to the delimiter + int tmp_ax = RCT2_ADDRESS(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)[cl]; + RCT2_ADDRESS(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)[cl] = sprite->sprite_index; + sprite->next = tmp_ax; + + if (tmp_ax != 0xFFFF) { + g_sprite_list[tmp_ax].peep.previous = ax; + } + + RCT2_ADDRESS(0x013573C8, uint16)[ebx]--; + RCT2_ADDRESS(0x013573C8, uint16)[cl]++; +} + +/** +* +* rct2: 0x0069EC6B +* bl +* return: new peep sprite (esi) +*/ +static rct_peep* create_peep_sprite(short bl) +{ + int ecx = 0; + rct_peep* newSprite; + + if (!(bl & 2)) { + if (RCT2_GLOBAL(0x013573C8, short) < 0) + return NULL; + + *newSprite = g_sprite_list[RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)].peep; + ecx = 10; + } + else { + if (0x12C - RCT2_GLOBAL(0x0013573CE, short) >= RCT2_GLOBAL(0x013573C8, short)) + return NULL; + + *newSprite = g_sprite_list[RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)].peep; + ecx = 6; + } + + sub_69ED0B(newSprite, ecx); + + newSprite->x = 0x8000; + newSprite->y = 0x8000; + newSprite->z = 0; + newSprite->var_02 = previousPeepSpriteIndex; + previousPeepSpriteIndex = newSprite->sprite_index; + newSprite->name_string_idx = 0; + newSprite->var_14 = 10; + newSprite->var_09 = 0x14; + newSprite->var_15 = 10; + newSprite->var_0C = 10; + newSprite->var_16 = 0x8000; + + return newSprite; +} + +static void sub_6C42AC(uint16 name_string_idx) +{ + if (name_string_idx < 0x8000 || name_string_idx >= 0x9000) + return; + + RCT2_ADDRESS(0x0095AFB8, uint32)[(name_string_idx + 0x3FF) * 20] = 0; +} + +static void sub_69EDB6(rct_peep* peep) { + sub_69ED0B(peep, 0); + sub_6C42AC(peep->name_string_idx); + peep->sprite_identifier = 0; + + int x = peep->x; + if (x == 0x8000) + x = 0x10000; + x &= 0x1FE0; + + uint32* edi = RCT2_ADDRESS(0xF1EF60, uint32)[(x << 3) | (peep->y >> 5)]; + + rct_peep* peepSprite = NULL; + while (peepSprite != peep) { + peepSprite = g_sprite_list + (*edi << 8); + *edi = peepSprite->var_02; + } + peepSprite->sprite_identifier = peep->var_02; +} + +/** +* +* rct2: 0x0069E9D3 +*/ +static void sub_69E9D3(rct_peep* peep, int ax) { + +} + +/** +* +* rct2: 0x006EC473 +*/ +static void sub_6EC473(rct_peep* peep) { + +} + +/** +* +* rct2: 0x00699115 +*/ +static void sub_699115(rct_peep* peep) { + +} + +/** +* +* rct2: 0x006BEFA1 +*/ +static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, + int* esi, int* edi, int* ebp) +{ + uint8 _bl = *ebx & 0xF, tabIndex = (*ebx & 0xF0) >> 8; + uint16 _ax = *eax & 0xFF, _cx = *ecx & 0xFF, _dx = *edx & 0xFF; + + RCT2_GLOBAL(0x0141F56C, uint8) = 0x28; + RCT2_GLOBAL(0x009DEA5E, uint16) = _ax; + RCT2_GLOBAL(0x009DEA60, uint16) = _cx; + RCT2_GLOBAL(0x009DEA62, uint16) = _dx; + + if (RCT2_GLOBAL(0x13573C8, uint16) < 0x190) { + *ebx = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_PEOPLE_IN_GAME; + return; + } + + int i; + for (i = 0; i < 0xC8; i++) { + if (!(RCT2_ADDRESS(0x013CA672, uint8)[i] & 1)) + break; + } + + if (i == 0xC8) { + *ebx = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_STAFF_IN_GAME; + return; + } + + int newStaffId = i; + + int _eax, _ebx, _ecx, _edx, _esi, _edi, _ebp; + _esi = 0; + _ebx = _bl; + RCT2_CALLFUNC_X(0x0069EC6B, &_eax, &_ebx, &_ecx, &_edx, &_esi, &_edi, &_ebp); + rct_peep* newPeep = (rct_peep*)_esi; + + //if ((newPeep = create_peep_sprite(_bl)) == NULL) + if (_esi == 0) + { + #ifdef _MSC_VER + __asm mov ebx, 0x80000000 + #else + __asm__("mov ebx, 0x80000000 "); + #endif + + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_PEOPLE_IN_GAME; + return; + } + + if (_bl & 1) { + // TODO + RCT2_CALLPROC_X(0x0069EDB6, 0, 0, 0, 0, (int)newPeep, 0, 0); + //sub_69EDB6(newPeep); + // 69EDB6 + } else { + _ecx = 4; + //sub_69ED0B(newPeep, 4); + RCT2_CALLPROC_X(0x0069ED0B, 0, 0, &_ecx, 0, (int)newPeep, 0, 0); + + newPeep->sprite_identifier = 1; + newPeep->var_09 = 0x0F; + newPeep->var_15 = 5; + newPeep->var_14 = 8; + newPeep->var_1E = 0; + + _eax = _ax; + _ecx = _cx; + _edx = _dx; + RCT2_CALLPROC_X(0x0069E9D3, &_eax, 0, &_ecx, &_edx, (int)newPeep, 0, 0); + + newPeep->state = PEEP_STATE_PICKED; + if (newPeep->x != 0x8000) { + newPeep->state = 0; + } + newPeep->var_45 = 0; + newPeep->var_71 = 0xFF; + newPeep->var_6D = 0; + newPeep->var_70 = 0; + newPeep->var_E0 = 0; + newPeep->var_6E = 0; + newPeep->var_C4 = 0; + newPeep->type == PEEP_TYPE_STAFF; + newPeep->var_2A = 0; + newPeep->flags = 0; + newPeep->paid_to_enter = 0; + newPeep->paid_on_rides = 0; + newPeep->paid_on_food = 0; + newPeep->paid_on_souvenirs = 0; + + newPeep->var_C6 = 0; + if (tabIndex == 0) { + newPeep->var_C6 = 7; + } + else if (tabIndex != 1) { + newPeep->var_C6 = 3; + } + newPeep->staff_type = 0xFF; + + uint16 idSearchSpriteIndex; + rct_peep* idSearchPeep; + + // We search for the first available id for the given staff type + int newId = 0; + BOOL newIdFound = FALSE; + do { + FOR_ALL_STAFF(idSearchSpriteIndex, idSearchPeep) { + newIdFound = TRUE; + + if (idSearchPeep->staff_type == tabIndex && idSearchPeep->id == newId) { + newIdFound = FALSE; + break; + } + } + } while (newIdFound == FALSE); + + newPeep->staff_type = tabIndex; + + + _eax = RCT2_ADDRESS(0x009929FC, uint8)[(tabIndex << 8) + _bl]; + newPeep->name_string_idx = (tabIndex << 8) + _bl + 0x300; + newPeep->sprite_type = _eax; + + _edx = RCT2_ADDRESS(0x0098270C, uint32)[_eax * 8]; + newPeep->var_14 = *((int*)_edx); + newPeep->var_09 = *((int*)(_edx + 1)); + newPeep->var_15 = *((int*)(_edx + 2)); + + //sub_69E9D3(newPeep); + RCT2_CALLPROC_X(0x0069E9D3, 0, 0, 0, 0, (int)newPeep, 0, 0); + //sub_6EC473(newPeep); + RCT2_CALLPROC_X(0x006EC473, 0, 0, 0, 0, (int)newPeep, 0, 0); + + newPeep->var_AD = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint8); + newPeep->var_CC = 0xFFFFFFFF; + + uint8 colour = RCT2_ADDRESS(RCT2_ADDRESS_HANDYMAN_COLOUR, uint8)[tabIndex]; + newPeep->tshirt_colour = colour; + newPeep->trousers_colour = colour; + + _eax = *ebp & 0x3F; + _ebp = (*ebp << 26) | (*ebp >> 6); + + //sub_699115(newPeep); + RCT2_CALLPROC_X(0x00699115, 0, 0, 0, 0, (int)newPeep, 0, &_ebp); + + newPeep->var_C5 = newStaffId; + + RCT2_ADDRESS(0x013CA672, uint8)[newStaffId] = 1; + + for (int edi = 0; edi < 0x80; edi++) { + int addr = 0x013B0E72 + (newStaffId << 9) + edi * 4; + RCT2_ADDRESS(addr, uint32) = 0; + } + } + + *ebx = 0; + *edi = newPeep->sprite_index; +} + + /** * * rct2: 0x00669E55 @@ -2624,7 +2930,7 @@ static uint32 game_do_command_table[58] = { 0x006E66A0, 0x006E6878, 0x006C5AE9, - 0x006BEFA1, + 0, 0x006C09D1, // 30 0x006C0B83, 0x006C0BB5, @@ -2655,4 +2961,67 @@ static uint32 game_do_command_table[58] = { 0x0068DF91 }; +game_command_emptysub(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp) {} + +static GAME_COMMAND_POINTER* new_game_command_table[58] = { + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_hire_new_staff_member, //game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, //(uint32)game_update_staff_colour, // 40 + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub, + game_command_emptysub +}; + #pragma endregion diff --git a/src/peep.h b/src/peep.h index dab4b3f66f..99d4aa2b07 100644 --- a/src/peep.h +++ b/src/peep.h @@ -314,17 +314,18 @@ typedef struct { typedef struct { uint8 sprite_identifier; // 0x00 uint8 pad_01; - uint16 pad_02; + uint16 var_02; // 0x02 - it seems that it is used uint16 next; // 0x04 uint16 previous; // 0x06 uint8 var_08; - uint8 pad_09; + uint8 var_09; // 0x09 uint16 sprite_index; // 0x0A uint16 var_0C; sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 - sint16 pad_14; + uint8 var_14; // 0x14 + uint8 var_15; // 0x15 sint16 var_16; sint16 var_18; sint16 var_1A; @@ -372,7 +373,9 @@ typedef struct { uint8 current_train; // 0x6A uint8 current_car; // 0x6B uint8 current_seat; // 0x6C - uint8 pad_6D[3]; + uint8 var_6D; // 0x6D + uint8 var_6E; // 0x6E + uint8 pad_6F; uint8 var_70; uint8 var_71; uint8 var_72; @@ -386,18 +389,20 @@ typedef struct { uint32 id; // 0x9C money32 cash_in_pocket; // 0xA0 money32 cash_spent; // 0xA4 - uint8 pad_A8; + uint8 var_A8; // 0xA8 sint32 time_in_park; // 0xA9 - uint8 var_AD; + uint8 var_AD; // creation/hire time? uint16 var_AE; rct_peep_thought thoughts[PEEP_MAX_THOUGHTS]; // 0xB0 - uint8 pad_C4; + uint8 var_C4; // 0xC4 uint8 var_C5; uint8 var_C6; uint8 photo1_ride_ref; // 0xC7 uint32 flags; // 0xC8 - uint8 var_CC; - uint8 pad_CD[0x17]; + uint8 var_CC; + uint8 pad_CD[0x13]; + uint8 var_E0; // 0xE0 + uint8 pad_E1[0x3]; money16 paid_to_enter; // 0xE4 money16 paid_on_rides; // 0xE6 money16 paid_on_food; // 0xE8 diff --git a/src/string_ids.h b/src/string_ids.h index de7114a9a1..070f76b229 100644 --- a/src/string_ids.h +++ b/src/string_ids.h @@ -336,12 +336,15 @@ enum { STR_GUESTS_TIP = 1693, STR_STAFF_TIP = 1694, + STR_TOO_MANY_PEOPLE_IN_GAME = 1699, STR_HIRE_HANDYMAN = 1700, - STR_HIRE_MECHANIC = 1700, - STR_HIRE_SECURITY_GUARD = 1700, - STR_HIRE_ENTERTAINER = 1700, + STR_HIRE_MECHANIC = 1701, + STR_HIRE_SECURITY_GUARD = 1702, + STR_HIRE_ENTERTAINER = 1703, STR_CANT_HIRE_NEW_STAFF = 1704, + STR_TOO_MANY_STAFF_IN_GAME = 1707, + STR_CANT_RENAME_PARK = 1717, STR_PARK_NAME = 1718, STR_ENTER_PARK_NAME = 1719, From a992e31113806ed37be31b77a07248d943b80f39 Mon Sep 17 00:00:00 2001 From: qcz Date: Mon, 11 Aug 2014 22:50:13 +0200 Subject: [PATCH 02/13] Fixes on the hire staff command (there is still a bug when hiring entertainers) --- src/game.c | 94 +++++++++++++++++++++++++++++++----------------------- src/peep.h | 10 +++--- 2 files changed, 60 insertions(+), 44 deletions(-) diff --git a/src/game.c b/src/game.c index d986cf8a12..76f2b113d7 100644 --- a/src/game.c +++ b/src/game.c @@ -2121,7 +2121,7 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int * RCT2_GLOBAL(0x009A8C28, uint8)++; *ebx &= ~1; - + // Primary command if (game_do_command_table[command] == 0) { new_game_command_table[command](eax, ebx, ecx, edx, esi, edi, ebp); @@ -2414,8 +2414,12 @@ static void sub_699115(rct_peep* peep) { static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp) { - uint8 _bl = *ebx & 0xF, tabIndex = (*ebx & 0xF0) >> 8; - uint16 _ax = *eax & 0xFF, _cx = *ecx & 0xFF, _dx = *edx & 0xFF; + //RCT2_CALLFUNC_X(0x006BEFA1, eax, ebx, ecx, edx, esi, edi, ebp); + //return; + + + uint8 _bl = *ebx & 0xFF, tabIndex = (*ebx & 0xFF00) >> 8; + uint16 _ax = *eax & 0xFFFF, _cx = *ecx & 0xFFFF, _dx = *edx & 0xFFFF; RCT2_GLOBAL(0x0141F56C, uint8) = 0x28; RCT2_GLOBAL(0x009DEA5E, uint16) = _ax; @@ -2442,10 +2446,10 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, int newStaffId = i; - int _eax, _ebx, _ecx, _edx, _esi, _edi, _ebp; + int _eax, _ebx, _ecx = _cx, _edx, _esi, _edi, _ebp; _esi = 0; _ebx = _bl; - RCT2_CALLFUNC_X(0x0069EC6B, &_eax, &_ebx, &_ecx, &_edx, &_esi, &_edi, &_ebp); + RCT2_CALLFUNC_X(0x0069EC6B, &_eax, &_bl, &_ecx, &_edx, &_esi, &_edi, &_ebp); rct_peep* newPeep = (rct_peep*)_esi; //if ((newPeep = create_peep_sprite(_bl)) == NULL) @@ -2461,15 +2465,10 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, return; } - if (_bl & 1) { - // TODO - RCT2_CALLPROC_X(0x0069EDB6, 0, 0, 0, 0, (int)newPeep, 0, 0); - //sub_69EDB6(newPeep); - // 69EDB6 + if (_bl == 0) { + RCT2_CALLPROC_X(0x0069EDB6, 0, 0, _ecx, 0, (int)newPeep, 0, 0); } else { - _ecx = 4; - //sub_69ED0B(newPeep, 4); - RCT2_CALLPROC_X(0x0069ED0B, 0, 0, &_ecx, 0, (int)newPeep, 0, 0); + RCT2_CALLPROC_X(0x0069ED0B, 0, 0, 4, 0, (int)newPeep, 0, 0); newPeep->sprite_identifier = 1; newPeep->var_09 = 0x0F; @@ -2478,14 +2477,18 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, newPeep->var_1E = 0; _eax = _ax; - _ecx = _cx; _edx = _dx; - RCT2_CALLPROC_X(0x0069E9D3, &_eax, 0, &_ecx, &_edx, (int)newPeep, 0, 0); + _ecx = *ecx; + // ax (cmp ax, 8000h) + // esi (peep) + // cx (shr cx, 5) + RCT2_CALLPROC_X(0x0069E9D3, _eax, 0, _ecx, *edx, (int)newPeep, 0, 0); newPeep->state = PEEP_STATE_PICKED; - if (newPeep->x != 0x8000) { + if (newPeep->x != -32768) { newPeep->state = 0; } + newPeep->var_45 = 0; newPeep->var_71 = 0xFF; newPeep->var_6D = 0; @@ -2493,7 +2496,7 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, newPeep->var_E0 = 0; newPeep->var_6E = 0; newPeep->var_C4 = 0; - newPeep->type == PEEP_TYPE_STAFF; + newPeep->type = PEEP_TYPE_STAFF; newPeep->var_2A = 0; newPeep->flags = 0; newPeep->paid_to_enter = 0; @@ -2502,47 +2505,54 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, newPeep->paid_on_souvenirs = 0; newPeep->var_C6 = 0; - if (tabIndex == 0) { + /*if (tabIndex == 0) { newPeep->var_C6 = 7; - } - else if (tabIndex != 1) { + } else if (tabIndex == 1) { newPeep->var_C6 = 3; - } + }*/ + newPeep->staff_type = 0xFF; uint16 idSearchSpriteIndex; rct_peep* idSearchPeep; - // We search for the first available id for the given staff type - int newId = 0; - BOOL newIdFound = FALSE; - do { - FOR_ALL_STAFF(idSearchSpriteIndex, idSearchPeep) { - newIdFound = TRUE; + // We search for the first available id for a given staff type + int newStaffIndex = 0; + for (;;) { + int found = 0; + newStaffIndex++; - if (idSearchPeep->staff_type == tabIndex && idSearchPeep->id == newId) { - newIdFound = FALSE; + FOR_ALL_STAFF(idSearchSpriteIndex, idSearchPeep) { + if (idSearchPeep->staff_type != tabIndex) { + continue; + } + + if (idSearchPeep->id == newStaffIndex) { + found = 1; break; } } - } while (newIdFound == FALSE); + if (found == 0) + break; + } + + newPeep->id = newStaffIndex; newPeep->staff_type = tabIndex; - - _eax = RCT2_ADDRESS(0x009929FC, uint8)[(tabIndex << 8) + _bl]; - newPeep->name_string_idx = (tabIndex << 8) + _bl + 0x300; + _eax = RCT2_ADDRESS(0x009929FC, uint8)[tabIndex]; + newPeep->name_string_idx = tabIndex + 0x300; newPeep->sprite_type = _eax; - _edx = RCT2_ADDRESS(0x0098270C, uint32)[_eax * 8]; + _edx = RCT2_ADDRESS(0x0098270C, uint32)[_eax * 2]; newPeep->var_14 = *((int*)_edx); newPeep->var_09 = *((int*)(_edx + 1)); newPeep->var_15 = *((int*)(_edx + 2)); //sub_69E9D3(newPeep); - RCT2_CALLPROC_X(0x0069E9D3, 0, 0, 0, 0, (int)newPeep, 0, 0); + RCT2_CALLPROC_X(0x0069E9D3, newPeep->x, 0, newPeep->y, newPeep->z, (int)newPeep, 0, 0); //sub_6EC473(newPeep); - RCT2_CALLPROC_X(0x006EC473, 0, 0, 0, 0, (int)newPeep, 0, 0); + RCT2_CALLPROC_X(0x006EC473, *eax, 0, 0, 0, (int)newPeep, 0, 0); newPeep->var_AD = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint8); newPeep->var_CC = 0xFFFFFFFF; @@ -2551,11 +2561,15 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, newPeep->tshirt_colour = colour; newPeep->trousers_colour = colour; - _eax = *ebp & 0x3F; - _ebp = (*ebp << 26) | (*ebp >> 6); + _eax = (uint32)ebp & 0xFFFFFF3F; + _ebp = (*ebp << 25) | (*ebp >> 6); + + newPeep->energy = 0x60; + newPeep->energy_growth_rate = 0x60; + newPeep->var_E2 = 0; //sub_699115(newPeep); - RCT2_CALLPROC_X(0x00699115, 0, 0, 0, 0, (int)newPeep, 0, &_ebp); + RCT2_CALLPROC_X(0x00699115, _eax, 0, 0, 0, (int)newPeep, 0, _ebp); newPeep->var_C5 = newStaffId; @@ -2930,7 +2944,7 @@ static uint32 game_do_command_table[58] = { 0x006E66A0, 0x006E6878, 0x006C5AE9, - 0, + 0, //0x006BEFA1, // 0, 0x006C09D1, // 30 0x006C0B83, 0x006C0BB5, diff --git a/src/peep.h b/src/peep.h index 99d4aa2b07..fc6406212d 100644 --- a/src/peep.h +++ b/src/peep.h @@ -314,7 +314,7 @@ typedef struct { typedef struct { uint8 sprite_identifier; // 0x00 uint8 pad_01; - uint16 var_02; // 0x02 - it seems that it is used + uint16 var_02; // 0x02 uint16 next; // 0x04 uint16 previous; // 0x06 uint8 var_08; @@ -399,10 +399,12 @@ typedef struct { uint8 var_C6; uint8 photo1_ride_ref; // 0xC7 uint32 flags; // 0xC8 - uint8 var_CC; - uint8 pad_CD[0x13]; + uint32 var_CC; + uint8 pad_D0[0x10]; uint8 var_E0; // 0xE0 - uint8 pad_E1[0x3]; + 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 From c88a7863996a1b6fe8c9c914a2d47d7e1cced8b2 Mon Sep 17 00:00:00 2001 From: qcz Date: Tue, 19 Aug 2014 09:46:04 +0200 Subject: [PATCH 03/13] Fix peep struct member name --- src/game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game.c b/src/game.c index 255362b4e6..09a2b0ba30 100644 --- a/src/game.c +++ b/src/game.c @@ -2474,7 +2474,7 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, newPeep->var_09 = 0x0F; newPeep->var_15 = 5; newPeep->var_14 = 8; - newPeep->var_1E = 0; + newPeep->sprite_direction = 0; _eax = _ax; _edx = _dx; From 0e48e92949145b8b57623af90775ab271fc96515 Mon Sep 17 00:00:00 2001 From: qcz Date: Wed, 20 Aug 2014 07:23:02 +0200 Subject: [PATCH 04/13] Entertainers don't crash the game anymore --- src/game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game.c b/src/game.c index 412089e5dd..18395f1c8e 100644 --- a/src/game.c +++ b/src/game.c @@ -2666,7 +2666,7 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, newPeep->var_AD = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint8); newPeep->var_CC = 0xFFFFFFFF; - uint8 colour = RCT2_ADDRESS(RCT2_ADDRESS_HANDYMAN_COLOUR, uint8)[tabIndex]; + uint8 colour = RCT2_ADDRESS(RCT2_ADDRESS_HANDYMAN_COLOUR, uint8)[tabIndex > 2 ? 2 : tabIndex]; newPeep->tshirt_colour = colour; newPeep->trousers_colour = colour; From 1b3f98362f5550fdc9ec5e69e35cdbbaa8071c3b Mon Sep 17 00:00:00 2001 From: qcz Date: Wed, 20 Aug 2014 15:32:39 +0200 Subject: [PATCH 05/13] Finalize hire-staff-command --- src/game.c | 167 +++-------------------------------------------------- 1 file changed, 8 insertions(+), 159 deletions(-) diff --git a/src/game.c b/src/game.c index 18395f1c8e..ff3af3dc75 100644 --- a/src/game.c +++ b/src/game.c @@ -2386,136 +2386,6 @@ static void game_load_or_quit() } -/** -* -* rct2: 0x0069ED0B -*/ -static void sub_69ED0B(rct_peep* sprite, int cl) -{ - if (sprite->var_08 == 0) - return; - - int ebx = sprite->var_08; - int ax = sprite->next; - - if (sprite->previous != 0xFFFF) { - g_sprite_list[sprite->previous].peep.next = ax; - } - else { - RCT2_ADDRESS(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)[ebx] = ax; - } - - sprite->previous = 0xFFFF; - sprite->var_08 = cl; - - // set next sprite to the delimiter - int tmp_ax = RCT2_ADDRESS(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)[cl]; - RCT2_ADDRESS(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)[cl] = sprite->sprite_index; - sprite->next = tmp_ax; - - if (tmp_ax != 0xFFFF) { - g_sprite_list[tmp_ax].peep.previous = ax; - } - - RCT2_ADDRESS(0x013573C8, uint16)[ebx]--; - RCT2_ADDRESS(0x013573C8, uint16)[cl]++; -} - -/** -* -* rct2: 0x0069EC6B -* bl -* return: new peep sprite (esi) -*/ -static rct_peep* create_peep_sprite(short bl) -{ - int ecx = 0; - rct_peep* newSprite; - - if (!(bl & 2)) { - if (RCT2_GLOBAL(0x013573C8, short) < 0) - return NULL; - - *newSprite = g_sprite_list[RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)].peep; - ecx = 10; - } - else { - if (0x12C - RCT2_GLOBAL(0x0013573CE, short) >= RCT2_GLOBAL(0x013573C8, short)) - return NULL; - - *newSprite = g_sprite_list[RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)].peep; - ecx = 6; - } - - sub_69ED0B(newSprite, ecx); - - newSprite->x = 0x8000; - newSprite->y = 0x8000; - newSprite->z = 0; - newSprite->var_02 = previousPeepSpriteIndex; - previousPeepSpriteIndex = newSprite->sprite_index; - newSprite->name_string_idx = 0; - newSprite->var_14 = 10; - newSprite->var_09 = 0x14; - newSprite->var_15 = 10; - newSprite->var_0C = 10; - newSprite->var_16 = 0x8000; - - return newSprite; -} - -static void sub_6C42AC(uint16 name_string_idx) -{ - if (name_string_idx < 0x8000 || name_string_idx >= 0x9000) - return; - - RCT2_ADDRESS(0x0095AFB8, uint32)[(name_string_idx + 0x3FF) * 20] = 0; -} - -static void sub_69EDB6(rct_peep* peep) { - sub_69ED0B(peep, 0); - sub_6C42AC(peep->name_string_idx); - peep->sprite_identifier = 0; - - int x = peep->x; - if (x == 0x8000) - x = 0x10000; - x &= 0x1FE0; - - uint32* edi = RCT2_ADDRESS(0xF1EF60, uint32)[(x << 3) | (peep->y >> 5)]; - - rct_peep* peepSprite = NULL; - while (peepSprite != peep) { - peepSprite = g_sprite_list + (*edi << 8); - *edi = peepSprite->var_02; - } - peepSprite->sprite_identifier = peep->var_02; -} - -/** -* -* rct2: 0x0069E9D3 -*/ -static void sub_69E9D3(rct_peep* peep, int ax) { - -} - -/** -* -* rct2: 0x006EC473 -*/ -static void sub_6EC473(rct_peep* peep) { - -} - -/** -* -* rct2: 0x00699115 -*/ -static void sub_699115(rct_peep* peep) { - -} - /** * * rct2: 0x006BEFA1 @@ -2523,10 +2393,6 @@ static void sub_699115(rct_peep* peep) { static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp) { - //RCT2_CALLFUNC_X(0x006BEFA1, eax, ebx, ecx, edx, esi, edi, ebp); - //return; - - uint8 _bl = *ebx & 0xFF, tabIndex = (*ebx & 0xFF00) >> 8; uint16 _ax = *eax & 0xFFFF, _cx = *ecx & 0xFFFF, _dx = *edx & 0xFFFF; @@ -2558,18 +2424,13 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, int _eax, _ebx, _ecx = _cx, _edx, _esi, _edi, _ebp; _esi = 0; _ebx = _bl; - RCT2_CALLFUNC_X(0x0069EC6B, &_eax, &_bl, &_ecx, &_edx, &_esi, &_edi, &_ebp); + RCT2_CALLFUNC_X(0x0069EC6B, &_eax, &_ebx, &_ecx, &_edx, &_esi, &_edi, &_ebp); rct_peep* newPeep = (rct_peep*)_esi; //if ((newPeep = create_peep_sprite(_bl)) == NULL) if (_esi == 0) { - #ifdef _MSC_VER - __asm mov ebx, 0x80000000 - #else - __asm__("mov ebx, 0x80000000 "); - #endif - + *ebx = 0x80000000; RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_PEOPLE_IN_GAME; return; } @@ -2585,13 +2446,7 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, newPeep->var_14 = 8; newPeep->sprite_direction = 0; - _eax = _ax; - _edx = _dx; - _ecx = *ecx; - // ax (cmp ax, 8000h) - // esi (peep) - // cx (shr cx, 5) - RCT2_CALLPROC_X(0x0069E9D3, _eax, 0, _ecx, *edx, (int)newPeep, 0, 0); + RCT2_CALLPROC_X(0x0069E9D3, _ax, 0, *ecx, _dx, (int)newPeep, 0, 0); newPeep->state = PEEP_STATE_PICKED; if (newPeep->x != -32768) { @@ -2614,11 +2469,11 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, newPeep->paid_on_souvenirs = 0; newPeep->var_C6 = 0; - /*if (tabIndex == 0) { + if (tabIndex == 0) { newPeep->var_C6 = 7; } else if (tabIndex == 1) { newPeep->var_C6 = 3; - }*/ + } newPeep->staff_type = 0xFF; @@ -2658,9 +2513,7 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, newPeep->var_09 = *((int*)(_edx + 1)); newPeep->var_15 = *((int*)(_edx + 2)); - //sub_69E9D3(newPeep); RCT2_CALLPROC_X(0x0069E9D3, newPeep->x, 0, newPeep->y, newPeep->z, (int)newPeep, 0, 0); - //sub_6EC473(newPeep); RCT2_CALLPROC_X(0x006EC473, *eax, 0, 0, 0, (int)newPeep, 0, 0); newPeep->var_AD = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint8); @@ -2670,15 +2523,12 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, newPeep->tshirt_colour = colour; newPeep->trousers_colour = colour; - _eax = (uint32)ebp & 0xFFFFFF3F; - _ebp = (*ebp << 25) | (*ebp >> 6); - newPeep->energy = 0x60; newPeep->energy_growth_rate = 0x60; newPeep->var_E2 = 0; - //sub_699115(newPeep); - RCT2_CALLPROC_X(0x00699115, _eax, 0, 0, 0, (int)newPeep, 0, _ebp); + RCT2_CALLPROC_X(0x00699115, (uint32)ebp & 0xFFFFFF3F, 0, 0, 0, (int)newPeep, 0, + (*ebp << 25) | (*ebp >> 6)); newPeep->var_C5 = newStaffId; @@ -2694,7 +2544,6 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, *edi = newPeep->sprite_index; } - /** * * rct2: 0x00669E55 @@ -3053,7 +2902,7 @@ static uint32 game_do_command_table[58] = { 0x006E66A0, 0x006E6878, 0x006C5AE9, - 0, //0x006BEFA1, // 0, + 0, // use new_game_command_table, original: 0x006BEFA1, 29 0x006C09D1, // 30 0x006C0B83, 0x006C0BB5, From cb169952aceaa75b7aaa54a324330aab86854a21 Mon Sep 17 00:00:00 2001 From: qcz Date: Wed, 20 Aug 2014 15:38:21 +0200 Subject: [PATCH 06/13] Remove unused variable, add indices to new_game_command_table --- src/game.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/game.c b/src/game.c index ff3af3dc75..cb06621971 100644 --- a/src/game.c +++ b/src/game.c @@ -45,7 +45,6 @@ int _gameSpeed = 1; -int previousPeepSpriteIndex = 0; void game_handle_input(); void game_handle_keyboard_input(); @@ -2946,6 +2945,7 @@ static GAME_COMMAND_POINTER* new_game_command_table[58] = { game_command_emptysub, game_command_emptysub, game_command_emptysub, + game_command_emptysub, // 10 game_command_emptysub, game_command_emptysub, game_command_emptysub, @@ -2955,8 +2955,7 @@ static GAME_COMMAND_POINTER* new_game_command_table[58] = { game_command_emptysub, game_command_emptysub, game_command_emptysub, - game_command_emptysub, - game_command_emptysub, + game_command_emptysub, // 20 game_command_emptysub, game_command_emptysub, game_command_emptysub, @@ -2966,6 +2965,7 @@ static GAME_COMMAND_POINTER* new_game_command_table[58] = { game_command_emptysub, game_command_emptysub, game_hire_new_staff_member, //game_command_emptysub, + game_command_emptysub, // 30 game_command_emptysub, game_command_emptysub, game_command_emptysub, @@ -2975,9 +2975,7 @@ static GAME_COMMAND_POINTER* new_game_command_table[58] = { game_command_emptysub, game_command_emptysub, game_command_emptysub, - game_command_emptysub, - game_command_emptysub, //(uint32)game_update_staff_colour, // 40 - game_command_emptysub, + game_command_emptysub, // 40 game_command_emptysub, game_command_emptysub, game_command_emptysub, @@ -2987,6 +2985,7 @@ static GAME_COMMAND_POINTER* new_game_command_table[58] = { game_command_emptysub, game_command_emptysub, game_command_emptysub, + game_command_emptysub, // 50 game_command_emptysub, game_command_emptysub, game_command_emptysub, From 92f0139b5a98a30ac0924fc43900747d606f55e9 Mon Sep 17 00:00:00 2001 From: qcz Date: Wed, 20 Aug 2014 15:48:53 +0200 Subject: [PATCH 07/13] Move typedef to header file --- src/game.c | 1 - src/game.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/game.c b/src/game.c index cb06621971..126f83b4c5 100644 --- a/src/game.c +++ b/src/game.c @@ -2188,7 +2188,6 @@ static int game_check_affordability(int cost) } static uint32 game_do_command_table[58]; -typedef void (GAME_COMMAND_POINTER)(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp); static GAME_COMMAND_POINTER* new_game_command_table[58]; /** diff --git a/src/game.h b/src/game.h index 92f11036ad..5c0771ca58 100644 --- a/src/game.h +++ b/src/game.h @@ -82,6 +82,8 @@ enum GAME_COMMAND { GAME_COMMAND_57 }; +typedef void (GAME_COMMAND_POINTER)(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp); + void game_create_windows(); void game_update(); void game_logic_update(); From 1007e79baa69ba39032e2cf74a962b738ed3fe81 Mon Sep 17 00:00:00 2001 From: qcz Date: Wed, 20 Aug 2014 16:00:47 +0200 Subject: [PATCH 08/13] Fix Travis error --- src/game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game.c b/src/game.c index 126f83b4c5..4c202af1d3 100644 --- a/src/game.c +++ b/src/game.c @@ -2534,7 +2534,7 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, for (int edi = 0; edi < 0x80; edi++) { int addr = 0x013B0E72 + (newStaffId << 9) + edi * 4; - RCT2_ADDRESS(addr, uint32) = 0; + RCT2_GLOBAL(addr, uint32) = 0; } } From f142cddbd6d22a5e9f55227f6f63508e5a9f567a Mon Sep 17 00:00:00 2001 From: qcz Date: Wed, 20 Aug 2014 16:04:10 +0200 Subject: [PATCH 09/13] Add return type to remove Travis warnings --- src/game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game.c b/src/game.c index 4c202af1d3..fc1c9a1ad6 100644 --- a/src/game.c +++ b/src/game.c @@ -2931,7 +2931,7 @@ static uint32 game_do_command_table[58] = { 0x0068DF91 }; -game_command_emptysub(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp) {} +void game_command_emptysub(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp) {} static GAME_COMMAND_POINTER* new_game_command_table[58] = { game_command_emptysub, From 12f6d578764cb58dbaaadfbeb926515e82c42e67 Mon Sep 17 00:00:00 2001 From: qcz Date: Wed, 20 Aug 2014 17:39:41 +0200 Subject: [PATCH 10/13] Fix pointer type --- src/game.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game.c b/src/game.c index fc1c9a1ad6..ceae782edc 100644 --- a/src/game.c +++ b/src/game.c @@ -2507,9 +2507,9 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, newPeep->sprite_type = _eax; _edx = RCT2_ADDRESS(0x0098270C, uint32)[_eax * 2]; - newPeep->var_14 = *((int*)_edx); - newPeep->var_09 = *((int*)(_edx + 1)); - newPeep->var_15 = *((int*)(_edx + 2)); + newPeep->var_14 = *((uint8*)_edx); + newPeep->var_09 = *((uint8*)(_edx + 1)); + newPeep->var_15 = *((uint8*)(_edx + 2)); RCT2_CALLPROC_X(0x0069E9D3, newPeep->x, 0, newPeep->y, newPeep->z, (int)newPeep, 0, 0); RCT2_CALLPROC_X(0x006EC473, *eax, 0, 0, 0, (int)newPeep, 0, 0); From 250acea957d8f17f7c61b3faa3b61d2d45249e0d Mon Sep 17 00:00:00 2001 From: qcz Date: Wed, 20 Aug 2014 17:48:47 +0200 Subject: [PATCH 11/13] Rename tabIndex to staff_type, move staff max count constant to #define --- src/game.c | 31 ++++++++++++++++--------------- src/peep.h | 2 +- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/game.c b/src/game.c index ceae782edc..f070f910e9 100644 --- a/src/game.c +++ b/src/game.c @@ -2391,7 +2391,7 @@ static void game_load_or_quit() static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp) { - uint8 _bl = *ebx & 0xFF, tabIndex = (*ebx & 0xFF00) >> 8; + uint8 _bl = *ebx & 0xFF, staff_type = (*ebx & 0xFF00) >> 8; uint16 _ax = *eax & 0xFFFF, _cx = *ecx & 0xFFFF, _dx = *edx & 0xFFFF; RCT2_GLOBAL(0x0141F56C, uint8) = 0x28; @@ -2406,12 +2406,12 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, } int i; - for (i = 0; i < 0xC8; i++) { + for (i = 0; i < STAFF_MAX_COUNT; i++) { if (!(RCT2_ADDRESS(0x013CA672, uint8)[i] & 1)) break; } - if (i == 0xC8) { + if (i == STAFF_MAX_COUNT) { *ebx = 0x80000000; RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_STAFF_IN_GAME; return; @@ -2467,9 +2467,10 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, newPeep->paid_on_souvenirs = 0; newPeep->var_C6 = 0; - if (tabIndex == 0) { + if (staff_type == 0) { newPeep->var_C6 = 7; - } else if (tabIndex == 1) { + } + else if (staff_type == 1) { newPeep->var_C6 = 3; } @@ -2485,7 +2486,7 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, newStaffIndex++; FOR_ALL_STAFF(idSearchSpriteIndex, idSearchPeep) { - if (idSearchPeep->staff_type != tabIndex) { + if (idSearchPeep->staff_type != staff_type) { continue; } @@ -2500,10 +2501,10 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, } newPeep->id = newStaffIndex; - newPeep->staff_type = tabIndex; + newPeep->staff_type = staff_type; - _eax = RCT2_ADDRESS(0x009929FC, uint8)[tabIndex]; - newPeep->name_string_idx = tabIndex + 0x300; + _eax = RCT2_ADDRESS(0x009929FC, uint8)[staff_type]; + newPeep->name_string_idx = staff_type + 0x300; newPeep->sprite_type = _eax; _edx = RCT2_ADDRESS(0x0098270C, uint32)[_eax * 2]; @@ -2517,7 +2518,7 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, newPeep->var_AD = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint8); newPeep->var_CC = 0xFFFFFFFF; - uint8 colour = RCT2_ADDRESS(RCT2_ADDRESS_HANDYMAN_COLOUR, uint8)[tabIndex > 2 ? 2 : tabIndex]; + uint8 colour = RCT2_ADDRESS(RCT2_ADDRESS_HANDYMAN_COLOUR, uint8)[staff_type > 2 ? 2 : staff_type]; newPeep->tshirt_colour = colour; newPeep->trousers_colour = colour; @@ -2548,7 +2549,7 @@ static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, */ static void game_update_staff_colour() { - byte tabIndex, colour, _bl; + byte staff_type, colour, _bl; int spriteIndex; rct_peep *peep; @@ -2559,9 +2560,9 @@ static void game_update_staff_colour() #endif #ifdef _MSC_VER - __asm mov tabIndex, bh + __asm mov staff_type, bh #else - __asm__("mov %[tabIndex], bh " : [tabIndex] "+m" (tabIndex)); + __asm__("mov %[staff_type], bh " : [staff_type] "+m" (staff_type)); #endif #ifdef _MSC_VER @@ -2571,10 +2572,10 @@ static void game_update_staff_colour() #endif if (_bl & 1) { - RCT2_ADDRESS(RCT2_ADDRESS_HANDYMAN_COLOUR, uint8)[tabIndex] = colour; + RCT2_ADDRESS(RCT2_ADDRESS_HANDYMAN_COLOUR, uint8)[staff_type] = colour; FOR_ALL_PEEPS(spriteIndex, peep) { - if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == tabIndex) { + if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == staff_type) { peep->tshirt_colour = colour; peep->trousers_colour = colour; } diff --git a/src/peep.h b/src/peep.h index 838564136c..1003852edc 100644 --- a/src/peep.h +++ b/src/peep.h @@ -34,7 +34,7 @@ #define PEEP_NOEXIT_WARNING_THRESHOLD 8 #define PEEP_LOST_WARNING_THRESHOLD 8 - +#define STAFF_MAX_COUNT 0xC8 enum PEEP_TYPE { PEEP_TYPE_GUEST, From fa6caa856a56e4ba9f5e1a2ac2fd2b1385be24ff Mon Sep 17 00:00:00 2001 From: qcz Date: Wed, 20 Aug 2014 23:48:36 +0200 Subject: [PATCH 12/13] Move staff related stuff to its own file --- projects/openrct2.vcxproj | 2 + projects/openrct2.vcxproj.filters | 6 + src/game.c | 212 +---------------------- src/peep.h | 9 - src/staff.c | 272 ++++++++++++++++++++++++++++++ src/staff.h | 41 +++++ src/window_staff.c | 39 ++--- 7 files changed, 336 insertions(+), 245 deletions(-) create mode 100644 src/staff.c create mode 100644 src/staff.h diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 4f016e510c..a70bb48f6e 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -59,6 +59,7 @@ + @@ -132,6 +133,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 936fee5e17..e01f32a9ac 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -156,6 +156,9 @@ Header Files + + Header Files + @@ -371,6 +374,9 @@ Windows + + Source Files + diff --git a/src/game.c b/src/game.c index f070f910e9..5176330499 100644 --- a/src/game.c +++ b/src/game.c @@ -40,6 +40,7 @@ #include "viewport.h" #include "widget.h" #include "window.h" +#include "staff.h" #include "window_error.h" #include "window_tooltip.h" @@ -2384,213 +2385,6 @@ static void game_load_or_quit() } -/** -* -* rct2: 0x006BEFA1 -*/ -static void game_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, - int* esi, int* edi, int* ebp) -{ - uint8 _bl = *ebx & 0xFF, staff_type = (*ebx & 0xFF00) >> 8; - uint16 _ax = *eax & 0xFFFF, _cx = *ecx & 0xFFFF, _dx = *edx & 0xFFFF; - - RCT2_GLOBAL(0x0141F56C, uint8) = 0x28; - RCT2_GLOBAL(0x009DEA5E, uint16) = _ax; - RCT2_GLOBAL(0x009DEA60, uint16) = _cx; - RCT2_GLOBAL(0x009DEA62, uint16) = _dx; - - if (RCT2_GLOBAL(0x13573C8, uint16) < 0x190) { - *ebx = 0x80000000; - RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_PEOPLE_IN_GAME; - return; - } - - int i; - for (i = 0; i < STAFF_MAX_COUNT; i++) { - if (!(RCT2_ADDRESS(0x013CA672, uint8)[i] & 1)) - break; - } - - if (i == STAFF_MAX_COUNT) { - *ebx = 0x80000000; - RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_STAFF_IN_GAME; - return; - } - - int newStaffId = i; - - int _eax, _ebx, _ecx = _cx, _edx, _esi, _edi, _ebp; - _esi = 0; - _ebx = _bl; - RCT2_CALLFUNC_X(0x0069EC6B, &_eax, &_ebx, &_ecx, &_edx, &_esi, &_edi, &_ebp); - rct_peep* newPeep = (rct_peep*)_esi; - - //if ((newPeep = create_peep_sprite(_bl)) == NULL) - if (_esi == 0) - { - *ebx = 0x80000000; - RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_PEOPLE_IN_GAME; - return; - } - - if (_bl == 0) { - RCT2_CALLPROC_X(0x0069EDB6, 0, 0, _ecx, 0, (int)newPeep, 0, 0); - } else { - RCT2_CALLPROC_X(0x0069ED0B, 0, 0, 4, 0, (int)newPeep, 0, 0); - - newPeep->sprite_identifier = 1; - newPeep->var_09 = 0x0F; - newPeep->var_15 = 5; - newPeep->var_14 = 8; - newPeep->sprite_direction = 0; - - RCT2_CALLPROC_X(0x0069E9D3, _ax, 0, *ecx, _dx, (int)newPeep, 0, 0); - - newPeep->state = PEEP_STATE_PICKED; - if (newPeep->x != -32768) { - newPeep->state = 0; - } - - newPeep->var_45 = 0; - newPeep->var_71 = 0xFF; - newPeep->var_6D = 0; - newPeep->var_70 = 0; - newPeep->var_E0 = 0; - newPeep->var_6E = 0; - newPeep->var_C4 = 0; - newPeep->type = PEEP_TYPE_STAFF; - newPeep->var_2A = 0; - newPeep->flags = 0; - newPeep->paid_to_enter = 0; - newPeep->paid_on_rides = 0; - newPeep->paid_on_food = 0; - newPeep->paid_on_souvenirs = 0; - - newPeep->var_C6 = 0; - if (staff_type == 0) { - newPeep->var_C6 = 7; - } - else if (staff_type == 1) { - newPeep->var_C6 = 3; - } - - newPeep->staff_type = 0xFF; - - uint16 idSearchSpriteIndex; - rct_peep* idSearchPeep; - - // We search for the first available id for a given staff type - int newStaffIndex = 0; - for (;;) { - int found = 0; - newStaffIndex++; - - FOR_ALL_STAFF(idSearchSpriteIndex, idSearchPeep) { - if (idSearchPeep->staff_type != staff_type) { - continue; - } - - if (idSearchPeep->id == newStaffIndex) { - found = 1; - break; - } - } - - if (found == 0) - break; - } - - newPeep->id = newStaffIndex; - newPeep->staff_type = staff_type; - - _eax = RCT2_ADDRESS(0x009929FC, uint8)[staff_type]; - newPeep->name_string_idx = staff_type + 0x300; - newPeep->sprite_type = _eax; - - _edx = RCT2_ADDRESS(0x0098270C, uint32)[_eax * 2]; - newPeep->var_14 = *((uint8*)_edx); - newPeep->var_09 = *((uint8*)(_edx + 1)); - newPeep->var_15 = *((uint8*)(_edx + 2)); - - RCT2_CALLPROC_X(0x0069E9D3, newPeep->x, 0, newPeep->y, newPeep->z, (int)newPeep, 0, 0); - RCT2_CALLPROC_X(0x006EC473, *eax, 0, 0, 0, (int)newPeep, 0, 0); - - newPeep->var_AD = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint8); - newPeep->var_CC = 0xFFFFFFFF; - - uint8 colour = RCT2_ADDRESS(RCT2_ADDRESS_HANDYMAN_COLOUR, uint8)[staff_type > 2 ? 2 : staff_type]; - newPeep->tshirt_colour = colour; - newPeep->trousers_colour = colour; - - newPeep->energy = 0x60; - newPeep->energy_growth_rate = 0x60; - newPeep->var_E2 = 0; - - RCT2_CALLPROC_X(0x00699115, (uint32)ebp & 0xFFFFFF3F, 0, 0, 0, (int)newPeep, 0, - (*ebp << 25) | (*ebp >> 6)); - - newPeep->var_C5 = newStaffId; - - RCT2_ADDRESS(0x013CA672, uint8)[newStaffId] = 1; - - for (int edi = 0; edi < 0x80; edi++) { - int addr = 0x013B0E72 + (newStaffId << 9) + edi * 4; - RCT2_GLOBAL(addr, uint32) = 0; - } - } - - *ebx = 0; - *edi = newPeep->sprite_index; -} - -/** -* -* rct2: 0x00669E55 -*/ -static void game_update_staff_colour() -{ - byte staff_type, colour, _bl; - int spriteIndex; - rct_peep *peep; - - #ifdef _MSC_VER - __asm mov _bl, bl - #else - __asm__("mov %[_bl], bl " : [_bl] "+m" (_bl)); - #endif - - #ifdef _MSC_VER - __asm mov staff_type, bh - #else - __asm__("mov %[staff_type], bh " : [staff_type] "+m" (staff_type)); - #endif - - #ifdef _MSC_VER - __asm mov colour, dh - #else - __asm__("mov %[colour], bh " : [colour] "+m" (colour)); - #endif - - if (_bl & 1) { - RCT2_ADDRESS(RCT2_ADDRESS_HANDYMAN_COLOUR, uint8)[staff_type] = colour; - - FOR_ALL_PEEPS(spriteIndex, peep) { - if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == staff_type) { - peep->tshirt_colour = colour; - peep->trousers_colour = colour; - } - } - } - - gfx_invalidate_screen(); - - #ifdef _MSC_VER - __asm mov ebx, 0 - #else - __asm__("mov ebx, 0 "); - #endif -} - /** * * rct2: 0x00674F40 @@ -2912,7 +2706,7 @@ static uint32 game_do_command_table[58] = { 0x00666A63, 0x006CD8CE, 0x00669E30, - (uint32)game_update_staff_colour, // 40 + (uint32)game_command_update_staff_colour, // 40 0x006E519A, 0x006E5597, 0x006B893C, @@ -2964,7 +2758,7 @@ static GAME_COMMAND_POINTER* new_game_command_table[58] = { game_command_emptysub, game_command_emptysub, game_command_emptysub, - game_hire_new_staff_member, //game_command_emptysub, + game_command_hire_new_staff_member, //game_command_emptysub, game_command_emptysub, // 30 game_command_emptysub, game_command_emptysub, diff --git a/src/peep.h b/src/peep.h index 1003852edc..18e5cd17f6 100644 --- a/src/peep.h +++ b/src/peep.h @@ -34,20 +34,11 @@ #define PEEP_NOEXIT_WARNING_THRESHOLD 8 #define PEEP_LOST_WARNING_THRESHOLD 8 -#define STAFF_MAX_COUNT 0xC8 - enum PEEP_TYPE { PEEP_TYPE_GUEST, PEEP_TYPE_STAFF }; -enum STAFF_TYPE { - STAFF_TYPE_HANDYMAN, - STAFF_TYPE_MECHANIC, - STAFF_TYPE_SECURITY, - STAFF_TYPE_ENTERTAINER -}; - enum PEEP_THOUGHT_TYPE { PEEP_THOUGHT_TYPE_SPENT_MONEY = 1, // "I've spent all my money" PEEP_THOUGHT_TYPE_SICK = 2, // "I feel sick" diff --git a/src/staff.c b/src/staff.c new file mode 100644 index 0000000000..b03cd6f90c --- /dev/null +++ b/src/staff.c @@ -0,0 +1,272 @@ +/***************************************************************************** +* Copyright (c) 2014 Dániel Tar +* OpenRCT2, an open source clone of Roller Coaster Tycoon 2. +* +* This file is part of OpenRCT2. +* +* OpenRCT2 is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. + +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. + +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include "staff.h" +#include "addresses.h" +#include "rct2.h" +#include "game.h" +#include "finance.h" +#include "peep.h" +#include "sprite.h" +#include "string_ids.h" +#include "viewport.h" + +/** +* +* rct2: 0x00669E55 +*/ +void game_command_update_staff_colour() +{ + uint8 staff_type, colour, _bl; + int spriteIndex; + rct_peep *peep; + + #ifdef _MSC_VER + __asm mov _bl, bl + #else + __asm__("mov %[_bl], bl " : [_bl] "+m" (_bl)); + #endif + + #ifdef _MSC_VER + __asm mov staff_type, bh + #else + __asm__("mov %[staff_type], bh " : [staff_type] "+m" (staff_type)); + #endif + + #ifdef _MSC_VER + __asm mov colour, dh + #else + __asm__("mov %[colour], bh " : [colour] "+m" (colour)); + #endif + + if (_bl & 1) { + RCT2_ADDRESS(RCT2_ADDRESS_HANDYMAN_COLOUR, uint8)[staff_type] = colour; + + FOR_ALL_PEEPS(spriteIndex, peep) { + if (peep->type == PEEP_TYPE_STAFF && peep->staff_type == staff_type) { + peep->tshirt_colour = colour; + peep->trousers_colour = colour; + } + } + } + + gfx_invalidate_screen(); + + #ifdef _MSC_VER + __asm mov ebx, 0 + #else + __asm__("mov ebx, 0 "); + #endif +} + +/** +* +* rct2: 0x006BEFA1 +*/ +void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, + int* esi, int* edi, int* ebp) +{ + uint8 _bl = *ebx & 0xFF, staff_type = (*ebx & 0xFF00) >> 8; + uint16 _ax = *eax & 0xFFFF, _cx = *ecx & 0xFFFF, _dx = *edx & 0xFFFF; + + RCT2_GLOBAL(0x0141F56C, uint8) = 0x28; + RCT2_GLOBAL(0x009DEA5E, uint16) = _ax; + RCT2_GLOBAL(0x009DEA60, uint16) = _cx; + RCT2_GLOBAL(0x009DEA62, uint16) = _dx; + + if (RCT2_GLOBAL(0x13573C8, uint16) < 0x190) { + *ebx = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_PEOPLE_IN_GAME; + return; + } + + int i; + for (i = 0; i < STAFF_MAX_COUNT; i++) { + if (!(RCT2_ADDRESS(0x013CA672, uint8)[i] & 1)) + break; + } + + if (i == STAFF_MAX_COUNT) { + *ebx = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_STAFF_IN_GAME; + return; + } + + int newStaffId = i; + + int _eax, _ebx, _ecx = _cx, _edx, _esi, _edi, _ebp; + _esi = 0; + _ebx = _bl; + RCT2_CALLFUNC_X(0x0069EC6B, &_eax, &_ebx, &_ecx, &_edx, &_esi, &_edi, &_ebp); + rct_peep* newPeep = (rct_peep*)_esi; + + //if ((newPeep = create_peep_sprite(_bl)) == NULL) + if (_esi == 0) + { + *ebx = 0x80000000; + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_PEOPLE_IN_GAME; + return; + } + + if (_bl == 0) { + RCT2_CALLPROC_X(0x0069EDB6, 0, 0, _ecx, 0, (int)newPeep, 0, 0); + } + else { + RCT2_CALLPROC_X(0x0069ED0B, 0, 0, 4, 0, (int)newPeep, 0, 0); + + newPeep->sprite_identifier = 1; + newPeep->var_09 = 0x0F; + newPeep->var_15 = 5; + newPeep->var_14 = 8; + newPeep->sprite_direction = 0; + + RCT2_CALLPROC_X(0x0069E9D3, _ax, 0, *ecx, _dx, (int)newPeep, 0, 0); + + newPeep->state = PEEP_STATE_PICKED; + if (newPeep->x != -32768) { + newPeep->state = 0; + } + + newPeep->var_45 = 0; + newPeep->var_71 = 0xFF; + newPeep->var_6D = 0; + newPeep->var_70 = 0; + newPeep->var_E0 = 0; + newPeep->var_6E = 0; + newPeep->var_C4 = 0; + newPeep->type = PEEP_TYPE_STAFF; + newPeep->var_2A = 0; + newPeep->flags = 0; + newPeep->paid_to_enter = 0; + newPeep->paid_on_rides = 0; + newPeep->paid_on_food = 0; + newPeep->paid_on_souvenirs = 0; + + newPeep->var_C6 = 0; + if (staff_type == 0) { + newPeep->var_C6 = 7; + } + else if (staff_type == 1) { + newPeep->var_C6 = 3; + } + + newPeep->staff_type = 0xFF; + + uint16 idSearchSpriteIndex; + rct_peep* idSearchPeep; + + // We search for the first available id for a given staff type + int newStaffIndex = 0; + for (;;) { + int found = 0; + newStaffIndex++; + + FOR_ALL_STAFF(idSearchSpriteIndex, idSearchPeep) { + if (idSearchPeep->staff_type != staff_type) { + continue; + } + + if (idSearchPeep->id == newStaffIndex) { + found = 1; + break; + } + } + + if (found == 0) + break; + } + + newPeep->id = newStaffIndex; + newPeep->staff_type = staff_type; + + _eax = RCT2_ADDRESS(0x009929FC, uint8)[staff_type]; + newPeep->name_string_idx = staff_type + 0x300; + newPeep->sprite_type = _eax; + + _edx = RCT2_ADDRESS(0x0098270C, uint32)[_eax * 2]; + newPeep->var_14 = *((uint8*)_edx); + newPeep->var_09 = *((uint8*)(_edx + 1)); + newPeep->var_15 = *((uint8*)(_edx + 2)); + + RCT2_CALLPROC_X(0x0069E9D3, newPeep->x, 0, newPeep->y, newPeep->z, (int)newPeep, 0, 0); + RCT2_CALLPROC_X(0x006EC473, *eax, 0, 0, 0, (int)newPeep, 0, 0); + + newPeep->var_AD = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint8); + newPeep->var_CC = 0xFFFFFFFF; + + uint8 colour = RCT2_ADDRESS(RCT2_ADDRESS_HANDYMAN_COLOUR, uint8)[staff_type > 2 ? 2 : staff_type]; + newPeep->tshirt_colour = colour; + newPeep->trousers_colour = colour; + + newPeep->energy = 0x60; + newPeep->energy_growth_rate = 0x60; + newPeep->var_E2 = 0; + + RCT2_CALLPROC_X(0x00699115, (uint32)ebp & 0xFFFFFF3F, 0, 0, 0, (int)newPeep, 0, + (*ebp << 25) | (*ebp >> 6)); + + newPeep->var_C5 = newStaffId; + + RCT2_ADDRESS(0x013CA672, uint8)[newStaffId] = 1; + + for (int edi = 0; edi < 0x80; edi++) { + int addr = 0x013B0E72 + (newStaffId << 9) + edi * 4; + RCT2_GLOBAL(addr, uint32) = 0; + } + } + + *ebx = 0; + *edi = newPeep->sprite_index; +} + +/* + * Updates the colour of the given staff type. +*/ +void update_staff_colour(uint8 staff_type, uint16 colour) +{ + game_do_command( + 0, + (staff_type << 8) + 1, + 0, + (colour << 8) + 4, + GAME_COMMAND_SET_STAFF_COLOUR, + 0, + 0); +} + +/* + * Hires a new staff member of the given type. If the hire cannot be completed (eg. the maximum + * number of staff is reached or there are too many people in the game) it returns 0xFFFF. +*/ +uint16 hire_new_staff_member(uint8 staff_type) +{ + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, uint16) = STR_CANT_HIRE_NEW_STAFF; + + int eax, ebx, ecx, edx, esi, edi, ebp; + eax = 0x8000; + ebx = staff_type << 8 | 1; + + int result = game_do_command_p(GAME_COMMAND_HIRE_NEW_STAFF_MEMBER, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + + if (result == 0x80000000) + return 0xFFFF; + + return edi; +} \ No newline at end of file diff --git a/src/staff.h b/src/staff.h new file mode 100644 index 0000000000..d531371ad6 --- /dev/null +++ b/src/staff.h @@ -0,0 +1,41 @@ +/***************************************************************************** + * Copyright (c) 2014 Dániel Tar + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * This file is part of OpenRCT2. + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*****************************************************************************/ + +#ifndef _STAFF_H_ +#define _STAFF_H_ + +#include "rct2.h" + +#define STAFF_MAX_COUNT 0xC8 + +enum STAFF_TYPE { + STAFF_TYPE_HANDYMAN, + STAFF_TYPE_MECHANIC, + STAFF_TYPE_SECURITY, + STAFF_TYPE_ENTERTAINER +}; + +void game_command_update_staff_colour(); +void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, int* esi, int* edi, int* ebp); + +void update_staff_colour(uint8 staff_type, uint16 color); +uint16 hire_new_staff_member(uint8 staff_type); + +#endif \ No newline at end of file diff --git a/src/window_staff.c b/src/window_staff.c index d4db8262b9..650dd10dc7 100644 --- a/src/window_staff.c +++ b/src/window_staff.c @@ -23,6 +23,7 @@ #include "game.h" #include "gfx.h" #include "peep.h" +#include "staff.h" #include "sprite.h" #include "string_ids.h" #include "viewport.h" @@ -193,24 +194,6 @@ void window_staff_close() { window_staff_cancel_tools(w); } -void window_staff_hire_new() { - uint8 bl = 1; - RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, uint16) = STR_CANT_HIRE_NEW_STAFF; - int eax, ebx, ecx, edx, esi, edi, ebp; - - eax = 0x8000; - ebx = RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) << 8 | bl; - - int result = game_do_command_p(GAME_COMMAND_HIRE_NEW_STAFF_MEMBER, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); - - if (result == 0x80000000) { - rct_window* window = window_find_by_id(WC_STAFF_LIST, 0); - window_invalidate(window); - } else { - window_staff_peep_open(&g_sprite_list[edi].peep); - } -} - /** * * rct2: 0x006BD94C @@ -219,6 +202,7 @@ static void window_staff_mouseup() { short widgetIndex; rct_window *w; + uint16 newStaffId; window_widget_get_registers(w, widgetIndex); @@ -227,7 +211,15 @@ static void window_staff_mouseup() window_close(w); break; case WIDX_STAFF_HIRE_BUTTON: - window_staff_hire_new(); + newStaffId = hire_new_staff_member(RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8)); + + if (newStaffId == 0xFFFF) { + rct_window* window = window_find_by_id(WC_STAFF_LIST, 0); + window_invalidate(window); + } else { + window_staff_peep_open(&g_sprite_list[newStaffId].peep); + } + break; case WIDX_STAFF_SHOW_PATROL_AREA_BUTTON: RCT2_CALLPROC_X(0x006BD9FF, 0, 0, 0, widgetIndex, (int)w, 0, 0); @@ -310,14 +302,7 @@ static void window_staff_dropdown() window_dropdown_get_registers(w, widgetIndex, dropdownIndex); if (widgetIndex == WIDX_STAFF_UNIFORM_COLOR_PICKER && dropdownIndex != -1) { - game_do_command( - 0, - (RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8) << 8) + 1, - 0, - (dropdownIndex << 8) + 4, - GAME_COMMAND_SET_STAFF_COLOUR, - 0, - 0); + update_staff_colour(RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_STAFF_LIST_SELECTED_TAB, uint8), dropdownIndex); } } From 3a55af7403bfcb4bede29225680983d9aa805019 Mon Sep 17 00:00:00 2001 From: qcz Date: Wed, 20 Aug 2014 23:53:51 +0200 Subject: [PATCH 13/13] Fix new file encodings --- src/staff.c | 2 +- src/staff.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/staff.c b/src/staff.c index b03cd6f90c..1e0bc041cb 100644 --- a/src/staff.c +++ b/src/staff.c @@ -1,5 +1,5 @@ /***************************************************************************** -* Copyright (c) 2014 Dániel Tar +* Copyright (c) 2014 Dániel Tar * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. * * This file is part of OpenRCT2. diff --git a/src/staff.h b/src/staff.h index d531371ad6..533c0b4a8f 100644 --- a/src/staff.h +++ b/src/staff.h @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014 Dániel Tar + * Copyright (c) 2014 Dániel Tar * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. * * This file is part of OpenRCT2.