Rework the matchmaker lobby (autolobby)
Description of the proposed changes
Reworks the matchmaker lobby from the bottom up with a focus on documentation and a better maintainable code structure. Introduces a similar setup to the MVC pattern. The pattern is simplified. This is an automated lobby and therefore the view never has to communicate back to the controller.
Controller/Model
See also:
lua\ui\lobby\autolobby\AutolobbyController.lualua\ui\lobby\autolobby\AutolobbyMessageHandlers.lua
Is responsible for the functionality of the matchmaker lobby. This involves creating the initial state and syncing this state between players.
View (interface)
See also:
lua\ui\lobby\autolobby\AutolobbyMapPreview.lualua\ui\lobby\autolobby\AutolobbyInterface.lua
Responsible for the interface of the user. Note that the interface has support for a basic version of hot reload. You can make changes to the interface and it will try to re-initialize in real time. There is no need to restart the application.
The map preview is created from the ground up too with performance (allocations) in mind.
Testing done on the proposed changes
With thanks to the script made by @lL1l1 in #6474 you can run the changes locally and inspect the result. The game launches. The host shares the settings. And once everyone is connected we launch the game.
Rejoin functionality at https://github.com/FAForever/fa/pull/6479/commits/14821634039dbc333fe0c1b0ac170352e8623ef7
https://github.com/user-attachments/assets/46da79e3-d45e-4cd6-828c-c5a529ae7562
https://github.com/FAForever/fa/pull/6479/commits/d41177b22d82b49fe2a3f1931f2816e2ec18e382
https://github.com/user-attachments/assets/58c739a6-79cf-4bd8-95eb-bed50526b2f0
https://github.com/FAForever/fa/pull/6479/commits/320f9f419c66cfffbee235777317d351d9736534
https://github.com/user-attachments/assets/3193071c-54ed-412b-81fe-12aebce2d7b0
Additional context
The interface of the matchmaker lobby has support for a basic 'hot reload' functionality. Assuming that you programmatically blocked the launch you can make changes to the interface, save the file, and the game will automatically try to re-initialize the interface. There's a snippet of comments for at the top of lua\ui\lobby\autolobby\AutolobbyInterface.lua that explains in more detail about how it works.
Checklist
- [ ] Changes are annotated, including comments where useful
- [ ] Changes are documented in the changelog for the next game version
Issues
- [x] (1) When there are 8 players it frequently happens that not everyone is connected to everyone before the game launches.
Resolved with: https://github.com/FAForever/fa/pull/6479/commits/e9670d3bc0f5938a71912b512da4fb675516bfae
- [x] (2) The more players the more frequently it happens that two players never connect. Perhaps we need a way to automatically for a reconnect from the host.
Resolved with: https://github.com/FAForever/fa/pull/6479/commits/5823e21134fb41c2d86101545593927f1f1eebae
Existing features
- [x] (1) Populate initial local player options and share that with the host.
- [x] (2) Populate initial game options.
- [x] (3) Correct nickname of peers that are connected (via
MakeValidPlayerName) - [x] (4) Sync game options from the host to the other peers.
- [x] (5) Launch the game once the host considers the lobby to be ready.
- [x] (6) Support for army colors.
- [ ] (7) Support for an initial loading dialog to show before we've received enough information from the host.
- [x] (8) Show fatal error messages in a dialog (rejected launch, connection failed, etc).
- [ ] (9) Add support for when a player does not send its start information.
- [x] (10) Mimic the behavior of
GpgNetSendin the old autolobby. In paritcular theLaunchStatus,GameState,DisconnectedandPlayerOptionkeys that are sent.
New features
- [x] (1) Improve the connection window to represent it as a matrix.
- [x] (2) Add prefetching of a session to reduce loading times.
New features to be discussed
- [x] (1) Add a basic preview of the map.
- [ ] (2) Add team configuration and player names to the left/right side of the map preview.
- [ ] (3) (Experimental) add support to hide the ratings and names of players for a local client (hinthunter- attempt nr. 3).
Cancelled features
- Add support for the
PreGamedataas defined in the regular lobby.
We either have this feature, or prefetching. We can't have both. Since you can not choose your UI mods regardless, it is probably best to just use whatever is in the prefs file at that moment and use prefetching instead.
Are there any mods that might affect lobby in a way that needs special considerations / testing?
A UI mod does not work/apply during the lobby. The only thing that can adjust the lobby are featured mods. That would be co-op and Nomads. But neither of them touch the autolobby file 😄 !
Some text I wrote on Discord about this pull request:
It is a connection matrix. Supreme Commander is peer-to-peer. Given that Supreme Commander is peer-to-peer it means every player needs a connection to every other player. The matrix represents that. The matrix is asynchronous - which is a difficult topic - but at its core the matrix can be different for all players.
Diagonal of the matrix
The diagonal represents the status of each player (anomynous). The status is local to that player and it is made visual via a color:
- orange: client is waiting for peers.
- green: client is ready to launch.
- purple: client is leaving the lobby to rejoin.
I decided not to ship with the purple status because it was too experimental. Hopefully in the near future though the rejoin functionality can fix lobbies being 'stuck' and not launching at all. The issue is very similar to people rejoining in a custom lobby - sometimes two players just don't connect and by rejoining it is fixed. The purple status would be the same, but then programmatically.
The diagonal also blinks occasionally. That means the local client received a message from that particular client. Usually this is the launch status being broadcasted to all clients. Note that one entry on the diagonal never blinks: that's the local client (you!)
Everything but the diagonal
Everything but the diagonal indicates whether the local client is aware of the player on the X axis to have a connection to the player on the Y axis. In its core its shows you who is connected to who. If it's dark grey, two players are not yet connected. If it brightens up then they are connected. If an entire row/column suddenly turns grey again it means a player likely left, especially if the status is not 'purple'.
What is its purpose?
For the average user it is just something that blinks. You can decipher whether the game may or may not connect. It is to be expanded on. It wasn't supposed to be the only thing visible, in the proof of concept there was also a preview of the map. See also #6479 for more details.
However, for the developer it is very useful. It shows the internal status of the lobby. And because of that it helps a great deal with understanding what is going on while testing. The new data can also be used to better decipher who's being a bad actor when the game does not start. For that, see also #1028. That way we have a better metric to punish (time out) a player that is constantly failing to join the lobby.
In general the matchmaker lobby has been worked up from the ground up to make it more maintainable. We can now actually add and extend features. It's flexible setup even allows us to support new type of queues in the future, such as an AI vs Human queue. There's much more work involved to that then just the in-game lobby, but it at least won't be a deal breaker either :slight_smile: .