From 97bd30ece77e8959c8a8f0285bb8b3286168f001 Mon Sep 17 00:00:00 2001 From: zsilencer Date: Sun, 12 Apr 2015 14:12:06 -0600 Subject: [PATCH] game_command_set_staff_patrol --- src/game.c | 4 ++-- src/peep/staff.c | 41 +++++++++++++++++++++++++++++++++++++++-- src/peep/staff.h | 1 + src/ride/ride.c | 7 +++---- 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/game.c b/src/game.c index 5d67d5e56f..bb366f4c7a 100644 --- a/src/game.c +++ b/src/game.c @@ -904,7 +904,7 @@ static uint32 game_do_command_table[58] = { 0x006E6878, 0x006C5AE9, 0, // use new_game_command_table, original: 0x006BEFA1, 29 - 0x006C09D1, // 30 + 0, // 30 0x006C0B83, 0, 0, @@ -967,7 +967,7 @@ static GAME_COMMAND_POINTER* new_game_command_table[58] = { game_command_emptysub, game_command_emptysub, game_command_hire_new_staff_member, //game_command_emptysub, - game_command_emptysub, // 30 + game_command_set_staff_patrol, // 30 game_command_emptysub, game_command_set_staff_order, game_command_set_park_name, diff --git a/src/peep/staff.c b/src/peep/staff.c index 378672c353..789bbfa8b9 100644 --- a/src/peep/staff.c +++ b/src/peep/staff.c @@ -218,10 +218,9 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, void game_command_set_staff_order(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp) { RCT2_GLOBAL(RCT2_ADDRESS_NEXT_EXPENDITURE_TYPE, uint8) = 40; - uint8 bl = *ebx; uint8 order_id = *ebx >> 8; uint16 sprite_id = *edx; - if(bl & 1){ + if(*ebx & GAME_COMMAND_FLAG_APPLY){ rct_peep *peep = &g_sprite_list[sprite_id].peep; if(order_id & 0x80){ // change costume uint8 sprite_type = order_id & ~0x80; @@ -245,6 +244,44 @@ void game_command_set_staff_order(int *eax, int *ebx, int *ecx, int *edx, int *e *ebx = 0; } +/** + * + * rct2: 0x006C09D1 + */ +void game_command_set_staff_patrol(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp) +{ + if(*ebx & GAME_COMMAND_FLAG_APPLY){ + int x = *eax; + int y = *ecx; + uint16 sprite_id = *edx; + rct_peep *peep = &g_sprite_list[sprite_id].peep; + int patrolOffset = peep->staff_id * (64 * 64 / 8); + int patrolIndex = ((x & 0x1F80) >> 7) | ((y & 0x1F80) >> 1); + int mask = 1 << (patrolIndex & 0x1F); + int base = patrolIndex >> 5; + + uint32 *patrolBits = (uint32*)(0x013B0E72 + patrolOffset + (base * 4)); + *patrolBits ^= mask; + + int eax2 = 0; + for(int i = 0; i < 128; i++){ + eax2 |= *(uint32*)(0x013B0E72 + patrolOffset + (i * 4)); + } + + RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[peep->staff_id] &= ~2; + if(eax2){ + RCT2_ADDRESS(RCT2_ADDRESS_STAFF_MODE_ARRAY, uint8)[peep->staff_id] |= 2; + } + + for(int y2 = 0; y2 < 4; y2++){ + for(int x2 = 0; x2 < 4; x2++){ + map_invalidate_tile_full((x & 0x1F80) + (x2 * 32), (y & 0x1F80) + (y2 * 32)); + } + } + } + *ebx = 0; +} + /* * Updates the colour of the given staff type. */ diff --git a/src/peep/staff.h b/src/peep/staff.h index 9eca6d33d9..87be022900 100644 --- a/src/peep/staff.h +++ b/src/peep/staff.h @@ -52,6 +52,7 @@ enum STAFF_ORDERS{ void game_command_update_staff_colour(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp); void game_command_hire_new_staff_member(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp); void game_command_set_staff_order(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp); +void game_command_set_staff_patrol(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp); void update_staff_colour(uint8 staffType, uint16 color); uint16 hire_new_staff_member(uint8 staffType); diff --git a/src/ride/ride.c b/src/ride/ride.c index 661e15b792..21059f071b 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -3669,7 +3669,6 @@ int ride_get_refund_price(int ride_id) */ void game_command_demolish_ride(int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp) { - uint8 *bl = (uint8*)ebx; uint8 ride_id = *(uint8*)edx; RCT2_GLOBAL(0x009DEA5E, uint16) = 0; @@ -3685,13 +3684,13 @@ void game_command_demolish_ride(int *eax, int *ebx, int *ecx, int *edx, int *esi RCT2_GLOBAL(0x009DEA60, uint16) = y; RCT2_GLOBAL(0x009DEA62, uint16) = z; } - if(!(*bl & 0x40) && RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8)){ + if(!(*ebx & 0x40) && RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8)){ RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; *ebx = MONEY32_UNDEFINED; return; }else{ - if(*bl & 1){ - if(!(*bl & 8)){ + if(*ebx & GAME_COMMAND_FLAG_APPLY){ + if(!(*ebx & 8)){ window_close_by_number(WC_RIDE_CONSTRUCTION, ride_id); } window_close_by_number(WC_RIDE, ride_id);