Commit fe8c0f9
authored
Fix clients able to join above max players (#2547)
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:
Lavodan1 parent 8f3e09c commit fe8c0f9
2 files changed
+37
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
128 | 138 | | |
129 | 139 | | |
130 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| 140 | + | |
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
| |||
207 | 208 | | |
208 | 209 | | |
209 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
210 | 228 | | |
211 | 229 | | |
212 | 230 | | |
| |||
0 commit comments