diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index 7027cbc8a4..8c343ddc0d 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -526,11 +527,38 @@ private: return; auto actionResult = res->GetData(); - // Open window for new staff. auto* staff = GetEntity(actionResult.StaffEntityId); - auto intent = Intent(WindowClass::Peep); - intent.PutExtra(INTENT_EXTRA_PEEP, staff); - ContextOpenIntent(&intent); + + // If autoposition of staff is disabled, pickup peep and then open the staff window + if (staff->State == PeepState::Picked) + { + picked_peep_old_x = staff->x; + CoordsXYZ nullLoc{}; + nullLoc.SetNull(); + + PeepPickupAction pickupAction{ PeepPickupType::Pickup, staff->sprite_index, nullLoc, + NetworkGetCurrentPlayerId() }; + pickupAction.SetCallback([&staff](const GameAction* ga, const GameActions::Result* result) { + if (result->Error != GameActions::Status::Ok) + return; + + auto intent = Intent(WindowClass::Peep); + intent.PutExtra(INTENT_EXTRA_PEEP, staff); + auto* wind = ContextOpenIntent(&intent); + if (wind != nullptr) + { + ToolSet(*wind, WC_STAFF__WIDX_PICKUP, Tool::Picker); + } + }); + GameActions::Execute(&pickupAction); + } + else + { + // Open window for new staff. + auto intent = Intent(WindowClass::Peep); + intent.PutExtra(INTENT_EXTRA_PEEP, staff); + ContextOpenIntent(&intent); + } }); GameActions::Execute(&hireStaffAction); diff --git a/src/openrct2/actions/PeepPickupAction.cpp b/src/openrct2/actions/PeepPickupAction.cpp index b0f0c630aa..c883734ea2 100644 --- a/src/openrct2/actions/PeepPickupAction.cpp +++ b/src/openrct2/actions/PeepPickupAction.cpp @@ -163,7 +163,6 @@ GameActions::Result PeepPickupAction::Execute() const { pickedUpPeep->PickupAbort(_loc.x); } - NetworkSetPickupPeep(_owner, nullptr); } break;