mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-01 00:53:29 +00:00
fe8c0f961a
Resolves #698 ## Description: This PR fixes clients being able to join games which are already full. This caused several bugs and glitches, like incorrect team sizes in team games, and being stuck in spectator mode. This fix checks for number of active clients in GameServer, and if it sees that the lobby is full, it does not put the client in the game, and sends an error with error key being "full-lobby" ClientGameRunner then checks to see this error, and overrides the default implementation of showing a popup. Instead it will leave the lobby for the user by dispatching a leave-lobby event into the document, and the user can then reqeue into a new game. Here is a video showcasing how full games are handled. https://github.com/user-attachments/assets/dc6220ea-590f-4bd1-8ca5-38c0d24ae792 ## Note on testing I wasn't able to figure out how to properly overwrite lobbyMaxPlayers from the default config using the devconfig, so the video shows just a hardcoded version of defaultconfig, therefore testing solo is probably not really possible. I just changed the function in defaultconfig for my testing to this: ```ts lobbyMaxPlayers( map: GameMapType, mode: GameMode, numPlayerTeams: TeamCountConfig | undefined, ): number { return 1; } ``` ## Notes This PR does not necessarily resolve all cases which cause 698, as for example joining too late while there is still space is not changed at all. For most public games, this shouldn't be an issue as the timer is long enough for a majority to be filled up before the timer hits 0. Additionally, spectating ongoing games should work fine, but as local server spectating is buggy in general, I was not able to test and confirm this 100%. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: Lavodan