1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Capture track location for callback by value (#25455)

Previously it was getting captured by reference and the action using it
was queued up for execution in next tick, resulting in reference going
out of scope. Capturing it by value fixes this issue as it is POD
struct.
This commit is contained in:
Michał Janiszewski
2025-11-09 01:25:02 +01:00
committed by GitHub
parent ed25fbcb3a
commit c20d9add1c

View File

@@ -299,7 +299,7 @@ namespace OpenRCT2::Ui::Windows
auto tdAction = GameActions::TrackDesignAction(
{ trackLoc, _currentTrackPieceDirection }, *_trackDesign, !gTrackDesignSceneryToggle);
tdAction.SetCallback([&](const GameActions::GameAction*, const GameActions::Result* result) {
tdAction.SetCallback([&, trackLoc](const GameActions::GameAction*, const GameActions::Result* result) {
if (result->Error != GameActions::Status::Ok)
{
Audio::Play3D(Audio::SoundId::error, result->Position);