Skip to content

Steam Multiplayer would endlessly hang waiting for the players because local_ident was never ready #392

Open
MrJCraft wants to merge 1 commit intoaardappel:masterfrom
MrJCraft:patch-1
Open

Steam Multiplayer would endlessly hang waiting for the players because local_ident was never ready #392
MrJCraft wants to merge 1 commit intoaardappel:masterfrom
MrJCraft:patch-1

Conversation

@MrJCraft
Copy link
Contributor

when testing this program multiplayer did not work
after some debugging I found that
local_ident was never initialized with the local identity

I initialize the local_ident at the top of the while loop so it gets initialized upfront
making the assumption that any special case most likely sets it explicitly after that point

I did not check every branch of code to guarantee correctness, it works for the normal friends lobby

the issue is specifically in this case:

                    case GS_HOST_WAITING_FOR_PEERS:
                        im.text("Waiting for peers...")
                        let ready = all(map(players): has_peer(_.ident))
                        guard ready
                        // Let all peers know that the game is starting
                        let peers_copy = copy(peers)
                        peers_copy.push(local_ident)
                        send(m_start_game { peers_copy })
                        game_state = GS_START_GAME

ready would get set to [false, true]
false being local_ident

let ready = all(map(players): has_peer(_.ident))
// local_ident was never set so it was empty always returning false     
def has_peer(id):
       return id == local_ident or (find(peers): _ == id) != -1

@aardappel
Copy link
Owner

Thanks for figuring that out!
@binji does this make sense to you?

@binji
Copy link
Collaborator

binji commented Jan 24, 2026

Hm, I'm not sure. It looks like I changed this when I added support for connecting via IP address; my guess is that I didn't verify that it worked with steam network addresses. It is probably safe to initialize it with the steam identity and override it with the IP address later, but I'd want to confirm first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants