From b7a4b00a0724ab49ed9372218542fbeeb36d8f4f Mon Sep 17 00:00:00 2001 From: ZehMatt Date: Tue, 17 Aug 2021 00:42:39 +0300 Subject: [PATCH 1/3] Remove capture of window pointer in Player.cpp --- src/openrct2-ui/windows/Player.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/openrct2-ui/windows/Player.cpp b/src/openrct2-ui/windows/Player.cpp index 640d1a73f4..10c70f0c85 100644 --- a/src/openrct2-ui/windows/Player.cpp +++ b/src/openrct2-ui/windows/Player.cpp @@ -23,6 +23,7 @@ #include #include #include +#include // clang-format off enum WINDOW_PLAYER_PAGE { @@ -265,8 +266,9 @@ void window_player_overview_mouse_down(rct_window* w, rct_widgetindex widgetInde void window_player_overview_dropdown(rct_window* w, rct_widgetindex widgetIndex, int32_t dropdownIndex) { - int32_t player = network_get_player_index(static_cast(w->number)); - if (player == -1) + const auto playerId = static_cast(w->number); + const auto playerIdx = network_get_player_index(playerId); + if (playerIdx == -1) { return; } @@ -274,12 +276,13 @@ void window_player_overview_dropdown(rct_window* w, rct_widgetindex widgetIndex, { return; } - int32_t group = network_get_group_id(dropdownIndex); - auto playerSetGroupAction = PlayerSetGroupAction(w->number, group); + const auto groupId = network_get_group_id(dropdownIndex); + const auto windowHandle = std::make_pair(w->classification, w->number); + auto playerSetGroupAction = PlayerSetGroupAction(playerId, groupId); playerSetGroupAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { if (result->Error == GameActions::Status::Ok) { - w->Invalidate(); + window_invalidate_by_number(windowHandle.first, windowHandle.second); } }); GameActions::Execute(&playerSetGroupAction); From f4602f49c72caf33f079ad034f62e180b401de35 Mon Sep 17 00:00:00 2001 From: ZehMatt Date: Tue, 17 Aug 2021 00:43:03 +0300 Subject: [PATCH 2/3] Remove capture of window pointer in RideConstruction.cpp --- src/openrct2-ui/windows/RideConstruction.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index b5e470b26a..52aef8142c 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -1933,6 +1933,7 @@ static void window_ride_construction_mouseup_demolish(rct_window* w) _currentTrackPieceType, 0, { _currentTrackBegin.x, _currentTrackBegin.y, _currentTrackBegin.z, _currentTrackPieceDirection }); + const auto rideId = w->number; trackRemoveAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { if (result->Error != GameActions::Status::Ok) { @@ -1940,7 +1941,7 @@ static void window_ride_construction_mouseup_demolish(rct_window* w) } else { - auto ride = get_ride(w->number); + auto ride = get_ride(rideId); if (ride != nullptr) { _stationConstructed = ride->num_stations != 0; From 8d801d9126ba5625794e578eca76cb940cd4147b Mon Sep 17 00:00:00 2001 From: ZehMatt Date: Sat, 21 Aug 2021 01:10:36 +0300 Subject: [PATCH 3/3] Apply review suggestion --- src/openrct2-ui/windows/Player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2-ui/windows/Player.cpp b/src/openrct2-ui/windows/Player.cpp index 10c70f0c85..4e10af0025 100644 --- a/src/openrct2-ui/windows/Player.cpp +++ b/src/openrct2-ui/windows/Player.cpp @@ -279,7 +279,7 @@ void window_player_overview_dropdown(rct_window* w, rct_widgetindex widgetIndex, const auto groupId = network_get_group_id(dropdownIndex); const auto windowHandle = std::make_pair(w->classification, w->number); auto playerSetGroupAction = PlayerSetGroupAction(playerId, groupId); - playerSetGroupAction.SetCallback([=](const GameAction* ga, const GameActions::Result* result) { + playerSetGroupAction.SetCallback([windowHandle](const GameAction* ga, const GameActions::Result* result) { if (result->Error == GameActions::Status::Ok) { window_invalidate_by_number(windowHandle.first, windowHandle.second);