I am currently developing a multiplayer game with a simple room structure where each room can have up to 4 players. Development is going great and we have server-side extensions attached to the Zone to control various different aspects of the game and manage timing, scores, etc for individual rooms. However, I have hit a really confusing issue that I simply cannot resolve after several hours of debugging.
We have a 'play again' button once our game has ended, which will trigger the client to leave their current room, join the lobby and then search for a suitable room to join again (a process that is specified in our extension). Their previous room has a variable set on it stating it is playing/ended, thus meaning it will not match as a suitable room when re-searching for another game. This process all happens when a user first launches the game, and it works every time they first load the game.
So the bug happens in the following use case: I am have a room of 4 players that have just played the game and everything is working correctly - all 4 players can see each other and see their scores are updating. I click play again to do as stated above and join a new room. Then the next 3 players also click play again in sequence and will also appear on player 1's screen to show they have joined. The game starts. The following happens: -
Player 1 can only updates from himself and player 4
Player 2 can see updates from himself, 1 and 4
Player 3 can see updates from everyone
Player 4 can see updates from everyone
The issue here is that the client-side smartfox API cannot see those players and so will not show the updated scores etc for them, even though it saw them join and made them appear (including their variables and usernames). Here is an warning that the console outputs: -
Code: Select all
[WARN] UserVariablesUpdate event, unknown User id: 175
** UPDATE **
Logging the sfs.userManager.getUserList() everytime a user enters the new room shows something interesting. The creator of the room (and the next player) seem to get a bit confused and return a user list of their old room, rather than the room they have just joined. Note-worthy for the edit - hoping it could lead somewhere.