From 2ac5e070c13a1a2206e38fbd70b6e503423cffe8 Mon Sep 17 00:00:00 2001 From: Matthias Moninger <5415177+ZehMatt@users.noreply.github.com> Date: Thu, 9 Mar 2023 14:04:19 +0200 Subject: [PATCH] Fix #19601: Crash hiring staff with auto placement turned off (#19602) --- src/openrct2-ui/windows/StaffList.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index d18fc00ef9..cb842d195b 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -552,12 +552,13 @@ private: nullLoc.SetNull(); PeepPickupAction pickupAction{ PeepPickupType::Pickup, staff->Id, nullLoc, NetworkGetCurrentPlayerId() }; - pickupAction.SetCallback([&staff](const GameAction* ga, const GameActions::Result* result) { + pickupAction.SetCallback([staffId = staff->Id](const GameAction* ga, const GameActions::Result* result) { if (result->Error != GameActions::Status::Ok) return; + auto* staff2 = GetEntity(staffId); auto intent = Intent(WindowClass::Peep); - intent.PutExtra(INTENT_EXTRA_PEEP, staff); + intent.PutExtra(INTENT_EXTRA_PEEP, staff2); auto* wind = ContextOpenIntent(&intent); if (wind != nullptr) {