foxygit / doom Log in
commit 80318dc0edae0b11ce533391433d4e4d8bd8006b
Author:     jens <jens.se@icloud.com>
AuthorDate: Sat Aug 22 09:32:10 2026 +0200
Commit:     jens <jens.se@icloud.com>
CommitDate: Sat Aug 22 09:32:10 2026 +0200

    Let a phone take slot 0 in the menu-triggered lobby, not just -nolocal

    I_WebInputTic reserved player slots 0/1 for a local host/WASD zone
    unless -nolocal was passed - a leftover from before the lobby existed,
    when slot 0 was always either a guaranteed local player or explicitly
    disclaimed via that flag. The menu-triggered lobby (see lobby_active)
    has the same "nobody local is guaranteed" property but isn't -nolocal,
    so a phone joining there still got pushed to slot 2+ instead of being
    able to become player 1 like a keyboard Space-press could.

    Reserve those slots only when neither -nolocal nor lobby_active apply.
    Verified with a single simulated phone connection through the actual
    menu -> Multiplayer -> lobby flow: it now correctly lands on slot 0
    ("Player 1"), with no duplicate join.

    Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---
 src/doom/i_webinput.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/doom/i_webinput.c b/src/doom/i_webinput.c
index 91cb834a..eea8c60f 100644
--- a/src/doom/i_webinput.c
+++ b/src/doom/i_webinput.c
@@ -1063,10 +1063,14 @@ void I_WebInputTic(void)
             else
             {
                 // Slots 0/1 are normally reserved for a local host/WASD
-                // zone (see MAX_REMOTE_SLOTS); under -nolocal there is
-                // no local player to reserve them for, so the first
-                // phone can take slot 0 itself.
-                int start_slot = nolocal_enabled ? 0 : 2;
+                // zone (see MAX_REMOTE_SLOTS); under -nolocal, or while
+                // still in the menu-triggered multiplayer lobby (see
+                // lobby_active, g_game.c), neither is guaranteed to
+                // exist - the host there is just as optional as any
+                // other player (see G_Responder's key_use handling) -
+                // so there is nothing to reserve them for and the
+                // first phone can take slot 0 itself.
+                int start_slot = (nolocal_enabled || lobby_active) ? 0 : 2;
                 SDL_UnlockMutex(remote_lock);
                 for (slot = start_slot; slot < MAXPLAYERS; slot++)
                 {