From b9a950fee799353b21aeea778fe4a047a0cb6bda Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Thu, 9 Feb 2023 00:08:45 -0800 Subject: [PATCH] Qt: Properly cap number of attached players by platform (fixes #2807) --- CHANGES | 1 + src/platform/qt/MultiplayerController.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 75c23d765..a507010c2 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,7 @@ Other fixes: - Core: Allow sending thread requests to a crashed core (fixes mgba.io/i/2784) - Qt: Fix crash when attempting to use OpenGL 2.1 to 3.1 (fixes mgba.io/i/2794) - Qt: Disable sync while running scripts from main thread (fixes mgba.io/i/2738) + - Qt: Properly cap number of attached players by platform (fixes mgba.io/i/2807) Misc: - Qt: Include wayland QPA in AppImage (fixes mgba.io/i/2796) - Qt: Stop eating boolean action key events (fixes mgba.io/i/2636) diff --git a/src/platform/qt/MultiplayerController.cpp b/src/platform/qt/MultiplayerController.cpp index f44323603..a45f287a9 100644 --- a/src/platform/qt/MultiplayerController.cpp +++ b/src/platform/qt/MultiplayerController.cpp @@ -214,10 +214,6 @@ MultiplayerController::~MultiplayerController() { } bool MultiplayerController::attachGame(CoreController* controller) { - if (m_lockstep.attached == MAX_GBAS) { - return false; - } - if (m_lockstep.attached == 0) { switch (controller->platform()) { #ifdef M_CORE_GBA @@ -243,6 +239,10 @@ bool MultiplayerController::attachGame(CoreController* controller) { switch (controller->platform()) { #ifdef M_CORE_GBA case mPLATFORM_GBA: { + if (m_lockstep.attached >= MAX_GBAS) { + return false; + } + GBA* gba = static_cast(thread->core->board); GBASIOLockstepNode* node = new GBASIOLockstepNode; @@ -259,6 +259,10 @@ bool MultiplayerController::attachGame(CoreController* controller) { #endif #ifdef M_CORE_GB case mPLATFORM_GB: { + if (m_lockstep.attached >= 2) { + return false; + } + GB* gb = static_cast(thread->core->board); GBSIOLockstepNode* node = new GBSIOLockstepNode;