1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 11:33:03 +01:00

Remove capture of window pointer in Player.cpp

This commit is contained in:
ZehMatt
2021-08-17 00:42:39 +03:00
parent a721ce30e8
commit b7a4b00a07

View File

@@ -23,6 +23,7 @@
#include <openrct2/network/network.h>
#include <openrct2/sprites.h>
#include <openrct2/util/Util.h>
#include <utility>
// 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<uint8_t>(w->number));
if (player == -1)
const auto playerId = static_cast<uint8_t>(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);