From 50d33b4dbf404ee81f30d425c37041f6e45df991 Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Fri, 15 May 2026 11:50:28 +0200 Subject: [PATCH] Assert on attempting to login the same user for two different slots (#4421) --- src/core/user_manager.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/core/user_manager.cpp b/src/core/user_manager.cpp index b13593b30..d26ee7c85 100644 --- a/src/core/user_manager.cpp +++ b/src/core/user_manager.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include "emulator_settings.h" #include "libraries/system/userservice.h" @@ -199,10 +200,15 @@ void UserManager::LoginUser(User* u, s32 player_index) { return; } + // if a controller triggers a login event for an already logged in user for the same index (e.g. + // the primary user is logged on at boot, with no controllers being connected at that time, then + // a controller is connected, triggering another login for the first user), do nothing + if (logged_in_users[player_index - 1] == u) { + return; + } + // if the same user is attempted to be registered in two different slots, crash for (auto& logged_in_user : logged_in_users) { - if (logged_in_user == u) { - logged_in_user = nullptr; - } + ASSERT(logged_in_user != u); } u->logged_in = true;