From 6edcd6d7a06203dcb293f95f1857b31b6b53fb11 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 27 Feb 2024 22:16:06 +0100 Subject: [PATCH] Avoid implicit capture of `this` in Footpath window --- src/openrct2-ui/windows/Footpath.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index e23000c078..d7d1f412eb 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -1034,18 +1034,25 @@ private: auto footpathPlaceAction = FootpathPlaceAction( footpathLoc, slope, type, gFootpathSelection.Railings, _footpathConstructDirection, constructFlags); - footpathPlaceAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + + footpathPlaceAction.SetCallback([footpathLoc](const GameAction* ga, const GameActions::Result* result) { + auto* self = static_cast(WindowFindByClass(WindowClass::Footpath)); + if (self == nullptr) + { + return; + } + if (result->Error == GameActions::Status::Ok) { OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::PlaceItem, result->Position); if (gFootpathConstructSlope == 0) { - _footpathConstructValidDirections = INVALID_DIRECTION; + self->_footpathConstructValidDirections = INVALID_DIRECTION; } else { - _footpathConstructValidDirections = _footpathConstructDirection; + self->_footpathConstructValidDirections = self->_footpathConstructDirection; } if (gFootpathGroundFlags & ELEMENT_IS_UNDERGROUND) @@ -1062,7 +1069,7 @@ private: gFootpathConstructFromPosition.z += PATH_HEIGHT_STEP; } } - WindowFootpathSetEnabledAndPressedWidgets(); + self->WindowFootpathSetEnabledAndPressedWidgets(); }); GameActions::Execute(&footpathPlaceAction); }