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) {