From 77238c1e5eed200f38db7cdf3ed6370f815b1e0c Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sat, 16 Mar 2019 20:45:52 +0000 Subject: [PATCH 1/5] Add staff set patrol area and fire actions --- src/openrct2-ui/windows/Staff.cpp | 7 +- src/openrct2-ui/windows/StaffFirePrompt.cpp | 8 +- src/openrct2-ui/windows/StaffList.cpp | 6 +- .../actions/GameActionRegistration.cpp | 4 + src/openrct2/actions/StaffFireAction.hpp | 72 ++++++++++++++ .../actions/StaffSetPatrolAreaAction.hpp | 99 +++++++++++++++++++ 6 files changed, 190 insertions(+), 6 deletions(-) create mode 100644 src/openrct2/actions/StaffFireAction.hpp create mode 100644 src/openrct2/actions/StaffSetPatrolAreaAction.hpp diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index c31fc30c34..b99f068e9b 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1225,7 +1226,8 @@ void window_staff_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex, { _staffPatrolAreaPaintValue = PatrolAreaValue::SET; } - game_do_command(dest_x, 1, dest_y, w->number, GAME_COMMAND_SET_STAFF_PATROL, 0, 0); + auto staffSetPatrolAreaAction = StaffSetPatrolAreaAction(w->number, { dest_x, dest_y }); + GameActions::Execute(&staffSetPatrolAreaAction); } } @@ -1263,7 +1265,8 @@ void window_staff_overview_tool_drag(rct_window* w, rct_widgetindex widgetIndex, if (_staffPatrolAreaPaintValue == PatrolAreaValue::UNSET && patrolAreaValue == false) return; // Since area is already the value we want, skip... - game_do_command(dest_x, 1, dest_y, w->number, GAME_COMMAND_SET_STAFF_PATROL, 0, 0); + auto staffSetPatrolAreaAction = StaffSetPatrolAreaAction(w->number, { dest_x, dest_y }); + GameActions::Execute(&staffSetPatrolAreaAction); } void window_staff_overview_tool_up(rct_window* w, rct_widgetindex widgetIndex, int32_t x, int32_t y) diff --git a/src/openrct2-ui/windows/StaffFirePrompt.cpp b/src/openrct2-ui/windows/StaffFirePrompt.cpp index 31acc4e44d..6937e84312 100644 --- a/src/openrct2-ui/windows/StaffFirePrompt.cpp +++ b/src/openrct2-ui/windows/StaffFirePrompt.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -103,12 +104,13 @@ rct_window* window_staff_fire_prompt_open(Peep* peep) */ static void window_staff_fire_mouseup(rct_window *w, rct_widgetindex widgetIndex) { - Peep* peep = &get_sprite(w->number)->peep; - switch (widgetIndex){ case WIDX_YES: - game_do_command(peep->x, 1, peep->y, w->number, GAME_COMMAND_FIRE_STAFF_MEMBER, 0, 0); + { + auto staffFireAction = StaffFireAction(w->number); + GameActions::Execute(&staffFireAction); break; + } case WIDX_CANCEL: case WIDX_CLOSE: window_close(w); diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index 34379e3f24..a02e4efd50 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -465,7 +466,10 @@ void window_staff_list_scrollmousedown(rct_window* w, int32_t scrollIndex, int32 if (i == 0) { if (_quick_fire_mode) - game_do_command(peep->x, 1, peep->y, spriteIndex, GAME_COMMAND_FIRE_STAFF_MEMBER, 0, 0); + { + auto staffFireAction = StaffFireAction(spriteIndex); + GameActions::Execute(&staffFireAction); + } else { auto intent = Intent(WC_PEEP); diff --git a/src/openrct2/actions/GameActionRegistration.cpp b/src/openrct2/actions/GameActionRegistration.cpp index cf6fd67727..fc31c174f9 100644 --- a/src/openrct2/actions/GameActionRegistration.cpp +++ b/src/openrct2/actions/GameActionRegistration.cpp @@ -46,11 +46,13 @@ #include "SignSetStyleAction.hpp" #include "SmallSceneryPlaceAction.hpp" #include "SmallSceneryRemoveAction.hpp" +#include "StaffFireAction.hpp" #include "StaffHireNewAction.hpp" #include "StaffSetColourAction.hpp" #include "StaffSetCostumeAction.hpp" #include "StaffSetNameAction.hpp" #include "StaffSetOrdersAction.hpp" +#include "StaffSetPatrolAreaAction.hpp" #include "TrackPlaceAction.hpp" #include "TrackRemoveAction.hpp" #include "TrackSetBrakeSpeedAction.hpp" @@ -92,11 +94,13 @@ namespace GameActions Register(); Register(); Register(); + Register(); Register(); Register(); Register(); Register(); Register(); + Register(); Register(); Register(); Register(); diff --git a/src/openrct2/actions/StaffFireAction.hpp b/src/openrct2/actions/StaffFireAction.hpp new file mode 100644 index 0000000000..e209e1be0e --- /dev/null +++ b/src/openrct2/actions/StaffFireAction.hpp @@ -0,0 +1,72 @@ +/***************************************************************************** + * Copyright (c) 2014-2018 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../interface/Window.h" +#include "../peep/Peep.h" +#include "../world/Sprite.h" +#include "GameAction.h" + +DEFINE_GAME_ACTION(StaffFireAction, GAME_COMMAND_FIRE_STAFF_MEMBER, GameActionResult) +{ +private: + uint16_t _spriteId; + +public: + StaffFireAction() + { + } + StaffFireAction(uint16_t spriteId) + : _spriteId(spriteId) + { + } + + uint16_t GetActionFlags() const override + { + return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + } + + void Serialise(DataSerialiser & stream) override + { + GameAction::Serialise(stream); + stream << DS_TAG(_spriteId); + } + + GameActionResult::Ptr Query() const override + { + if (_spriteId >= MAX_SPRITES) + { + log_error("Invalid spriteId."); + return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + } + + auto peep = GET_PEEP(_spriteId); + if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->type != PEEP_TYPE_STAFF) + { + log_error("Invalid spriteId."); + return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + } + + return MakeResult(); + } + + GameActionResult::Ptr Execute() const override + { + auto peep = GET_PEEP(_spriteId); + if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->type != PEEP_TYPE_STAFF) + { + log_error("Invalid spriteId."); + return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + } + window_close_by_class(WC_FIRE_PROMPT); + peep_sprite_remove(peep); + return MakeResult(); + } +}; diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.hpp b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp new file mode 100644 index 0000000000..b287dbeecc --- /dev/null +++ b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp @@ -0,0 +1,99 @@ +/***************************************************************************** + * Copyright (c) 2014-2018 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../interface/Window.h" +#include "../peep/Peep.h" +#include "../peep/Staff.h" +#include "../world/Sprite.h" +#include "GameAction.h" + +DEFINE_GAME_ACTION(StaffSetPatrolAreaAction, GAME_COMMAND_SET_STAFF_PATROL, GameActionResult) +{ +private: + uint16_t _spriteId; + CoordsXY _loc; + +public: + StaffSetPatrolAreaAction() + { + } + StaffSetPatrolAreaAction(uint16_t spriteId, CoordsXY loc) + : _spriteId(spriteId) + , _loc(loc) + { + } + + uint16_t GetActionFlags() const override + { + return GameAction::GetActionFlags() | GA_FLAGS::ALLOW_WHILE_PAUSED; + } + + void Serialise(DataSerialiser & stream) override + { + GameAction::Serialise(stream); + stream << DS_TAG(_spriteId) << DS_TAG(_loc); + } + + GameActionResult::Ptr Query() const override + { + if (_spriteId >= MAX_SPRITES) + { + log_error("Invalid spriteId."); + return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + } + + auto peep = GET_PEEP(_spriteId); + if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->type != PEEP_TYPE_STAFF) + { + log_error("Invalid spriteId."); + return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + } + + return MakeResult(); + } + + GameActionResult::Ptr Execute() const override + { + auto peep = GET_PEEP(_spriteId); + if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->type != PEEP_TYPE_STAFF) + { + log_error("Invalid spriteId."); + return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); + } + + int32_t patrolOffset = peep->staff_id * STAFF_PATROL_AREA_SIZE; + + staff_toggle_patrol_area(peep->staff_id, _loc.x, _loc.y); + + int32_t ispatrolling = 0; + for (int32_t i = 0; i < 128; i++) + { + ispatrolling |= gStaffPatrolAreas[patrolOffset + i]; + } + + gStaffModes[peep->staff_id] &= ~(1 << 1); + if (ispatrolling) + { + gStaffModes[peep->staff_id] |= (1 << 1); + } + + for (int32_t y = 0; y < 4 * 32; y += 32) + { + for (int32_t x = 0; x < 4 * 32; x += 32) + { + map_invalidate_tile_full((_loc.x & 0x1F80) + x, (_loc.y & 0x1F80) + y); + } + } + staff_update_greyed_patrol_areas(); + + return MakeResult(); + } +}; From 0b231c8b380202ab0a307b067f5d85f7fcdceb7d Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sat, 16 Mar 2019 20:47:54 +0000 Subject: [PATCH 2/5] Remove old game commands --- src/openrct2/Game.cpp | 4 +- src/openrct2/Game.h | 8 ++-- src/openrct2/peep/Staff.cpp | 87 ------------------------------------- src/openrct2/peep/Staff.h | 4 -- 4 files changed, 6 insertions(+), 97 deletions(-) diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 791f428806..78018158ce 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -1291,8 +1291,8 @@ GAME_COMMAND_POINTER* new_game_command_table[GAME_COMMAND_COUNT] = { nullptr, nullptr, nullptr, - game_command_set_staff_patrol, - game_command_fire_staff_member, + nullptr, + nullptr, nullptr, nullptr, game_command_set_park_open, diff --git a/src/openrct2/Game.h b/src/openrct2/Game.h index e0b759675a..cd2d18c298 100644 --- a/src/openrct2/Game.h +++ b/src/openrct2/Game.h @@ -49,10 +49,10 @@ enum GAME_COMMAND GAME_COMMAND_LOWER_WATER, // GA GAME_COMMAND_SET_BRAKES_SPEED, // GA GAME_COMMAND_HIRE_NEW_STAFF_MEMBER, // GA - GAME_COMMAND_SET_STAFF_PATROL, - GAME_COMMAND_FIRE_STAFF_MEMBER, - GAME_COMMAND_SET_STAFF_ORDERS, // GA - GAME_COMMAND_SET_PARK_NAME, // GA + GAME_COMMAND_SET_STAFF_PATROL, // GA + GAME_COMMAND_FIRE_STAFF_MEMBER, // GA + GAME_COMMAND_SET_STAFF_ORDERS, // GA + GAME_COMMAND_SET_PARK_NAME, // GA GAME_COMMAND_SET_PARK_OPEN, GAME_COMMAND_BUY_LAND_RIGHTS, GAME_COMMAND_PLACE_PARK_ENTRANCE, // GA diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 80203cf89c..39053bb261 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -82,93 +82,6 @@ void staff_reset_modes() staff_update_greyed_patrol_areas(); } -/** - * - * rct2: 0x006C09D1 - */ -void game_command_set_staff_patrol( - int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, [[maybe_unused]] int32_t* esi, [[maybe_unused]] int32_t* edi, - [[maybe_unused]] int32_t* ebp) -{ - if (*ebx & GAME_COMMAND_FLAG_APPLY) - { - int32_t x = *eax; - int32_t y = *ecx; - uint16_t sprite_id = *edx; - if (sprite_id >= MAX_SPRITES) - { - *ebx = MONEY32_UNDEFINED; - log_warning("Invalid sprite id %u", sprite_id); - return; - } - rct_sprite* sprite = get_sprite(sprite_id); - if (sprite->generic.sprite_identifier != SPRITE_IDENTIFIER_PEEP || sprite->peep.type != PEEP_TYPE_STAFF) - { - *ebx = MONEY32_UNDEFINED; - log_warning("Invalid type of sprite %u for game command", sprite_id); - return; - } - Peep* peep = &sprite->peep; - int32_t patrolOffset = peep->staff_id * STAFF_PATROL_AREA_SIZE; - - staff_toggle_patrol_area(peep->staff_id, x, y); - - int32_t ispatrolling = 0; - for (int32_t i = 0; i < 128; i++) - { - ispatrolling |= gStaffPatrolAreas[patrolOffset + i]; - } - - gStaffModes[peep->staff_id] &= ~2; - if (ispatrolling) - { - gStaffModes[peep->staff_id] |= 2; - } - - for (int32_t y2 = 0; y2 < 4; y2++) - { - for (int32_t x2 = 0; x2 < 4; x2++) - { - map_invalidate_tile_full((x & 0x1F80) + (x2 * 32), (y & 0x1F80) + (y2 * 32)); - } - } - staff_update_greyed_patrol_areas(); - } - *ebx = 0; -} - -/** - * - * rct2: 0x006C0B83 - */ -void game_command_fire_staff_member( - [[maybe_unused]] int32_t* eax, int32_t* ebx, [[maybe_unused]] int32_t* ecx, int32_t* edx, [[maybe_unused]] int32_t* esi, - [[maybe_unused]] int32_t* edi, [[maybe_unused]] int32_t* ebp) -{ - gCommandExpenditureType = RCT_EXPENDITURE_TYPE_WAGES; - if (*ebx & GAME_COMMAND_FLAG_APPLY) - { - window_close_by_class(WC_FIRE_PROMPT); - uint16_t sprite_id = *edx; - if (sprite_id >= MAX_SPRITES) - { - log_warning("Invalid game command, sprite_id = %u", sprite_id); - *ebx = MONEY32_UNDEFINED; - return; - } - Peep* peep = &get_sprite(sprite_id)->peep; - if (peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->type != PEEP_TYPE_STAFF) - { - log_warning( - "Invalid game command, peep->sprite_identifier = %u, peep->type = %u", peep->sprite_identifier, peep->type); - *ebx = MONEY32_UNDEFINED; - return; - } - peep_sprite_remove(peep); - } - *ebx = 0; -} - /** * Hires a new staff member of the given type. */ diff --git a/src/openrct2/peep/Staff.h b/src/openrct2/peep/Staff.h index 30ef68ef5f..1c712f17a6 100644 --- a/src/openrct2/peep/Staff.h +++ b/src/openrct2/peep/Staff.h @@ -75,10 +75,6 @@ void game_command_hire_new_staff_member( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); void game_command_callback_hire_new_staff_member( int32_t eax, int32_t ebx, int32_t ecx, int32_t edx, int32_t esi, int32_t edi, int32_t ebp); -void game_command_set_staff_patrol( - int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); -void game_command_fire_staff_member( - int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); void game_command_set_staff_name( int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp); void game_command_pickup_staff( From ca92d63b2085f0f2809c3eb47478d5964931fc7e Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sat, 16 Mar 2019 20:50:00 +0000 Subject: [PATCH 3/5] Put the correct copyright date on --- src/openrct2/actions/StaffFireAction.hpp | 2 +- src/openrct2/actions/StaffSetPatrolAreaAction.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openrct2/actions/StaffFireAction.hpp b/src/openrct2/actions/StaffFireAction.hpp index e209e1be0e..30369e3c00 100644 --- a/src/openrct2/actions/StaffFireAction.hpp +++ b/src/openrct2/actions/StaffFireAction.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2018 OpenRCT2 developers + * Copyright (c) 2014-2019 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.hpp b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp index b287dbeecc..04339908ff 100644 --- a/src/openrct2/actions/StaffSetPatrolAreaAction.hpp +++ b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2018 OpenRCT2 developers + * Copyright (c) 2014-2019 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 From 9e316f9191bda229e4a2e3d129644d7062462ab7 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sat, 16 Mar 2019 21:07:50 +0000 Subject: [PATCH 4/5] Fix formatting --- src/openrct2-ui/windows/StaffFirePrompt.cpp | 2 +- src/openrct2-ui/windows/StaffList.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openrct2-ui/windows/StaffFirePrompt.cpp b/src/openrct2-ui/windows/StaffFirePrompt.cpp index 6937e84312..d26be2fda0 100644 --- a/src/openrct2-ui/windows/StaffFirePrompt.cpp +++ b/src/openrct2-ui/windows/StaffFirePrompt.cpp @@ -10,9 +10,9 @@ #include #include #include +#include #include #include -#include #include #include diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index a02e4efd50..64e9e8c547 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -15,8 +15,8 @@ #include #include #include -#include #include +#include #include #include #include From e97428acc0c0df7c32ecf07aa5c3f9c4bd296480 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sun, 17 Mar 2019 07:26:39 +0000 Subject: [PATCH 5/5] Make requested changes --- src/openrct2/actions/StaffFireAction.hpp | 8 ++++---- .../actions/StaffSetPatrolAreaAction.hpp | 18 +++++++++++------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/openrct2/actions/StaffFireAction.hpp b/src/openrct2/actions/StaffFireAction.hpp index 30369e3c00..49e1f70f05 100644 --- a/src/openrct2/actions/StaffFireAction.hpp +++ b/src/openrct2/actions/StaffFireAction.hpp @@ -17,7 +17,7 @@ DEFINE_GAME_ACTION(StaffFireAction, GAME_COMMAND_FIRE_STAFF_MEMBER, GameActionResult) { private: - uint16_t _spriteId; + uint16_t _spriteId{ SPRITE_INDEX_NULL }; public: StaffFireAction() @@ -43,14 +43,14 @@ public: { if (_spriteId >= MAX_SPRITES) { - log_error("Invalid spriteId."); + log_error("Invalid spriteId. spriteId = %u", _spriteId); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); } auto peep = GET_PEEP(_spriteId); if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->type != PEEP_TYPE_STAFF) { - log_error("Invalid spriteId."); + log_error("Invalid spriteId. spriteId = %u", _spriteId); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); } @@ -62,7 +62,7 @@ public: auto peep = GET_PEEP(_spriteId); if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->type != PEEP_TYPE_STAFF) { - log_error("Invalid spriteId."); + log_error("Invalid spriteId. spriteId = %u", _spriteId); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); } window_close_by_class(WC_FIRE_PROMPT); diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.hpp b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp index 04339908ff..355494da4f 100644 --- a/src/openrct2/actions/StaffSetPatrolAreaAction.hpp +++ b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp @@ -18,7 +18,7 @@ DEFINE_GAME_ACTION(StaffSetPatrolAreaAction, GAME_COMMAND_SET_STAFF_PATROL, GameActionResult) { private: - uint16_t _spriteId; + uint16_t _spriteId{ SPRITE_INDEX_NULL }; CoordsXY _loc; public: @@ -46,14 +46,14 @@ public: { if (_spriteId >= MAX_SPRITES) { - log_error("Invalid spriteId."); + log_error("Invalid spriteId. spriteId = %u", _spriteId); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); } auto peep = GET_PEEP(_spriteId); if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->type != PEEP_TYPE_STAFF) { - log_error("Invalid spriteId."); + log_error("Invalid spriteId. spriteId = %u", _spriteId); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); } @@ -65,7 +65,7 @@ public: auto peep = GET_PEEP(_spriteId); if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->type != PEEP_TYPE_STAFF) { - log_error("Invalid spriteId."); + log_error("Invalid spriteId. spriteId = %u", _spriteId); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); } @@ -73,14 +73,18 @@ public: staff_toggle_patrol_area(peep->staff_id, _loc.x, _loc.y); - int32_t ispatrolling = 0; + bool isPatrolling = false; for (int32_t i = 0; i < 128; i++) { - ispatrolling |= gStaffPatrolAreas[patrolOffset + i]; + if (gStaffPatrolAreas[patrolOffset + i]) + { + isPatrolling = true; + break; + } } gStaffModes[peep->staff_id] &= ~(1 << 1); - if (ispatrolling) + if (isPatrolling) { gStaffModes[peep->staff_id] |= (1 << 1); }