Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework the matchmaker lobby (autolobby) #6479

Merged
merged 85 commits into from
Nov 19, 2024
Merged

Rework the matchmaker lobby (autolobby) #6479

merged 85 commits into from
Nov 19, 2024

Conversation

Garanas
Copy link
Member

@Garanas Garanas commented Oct 18, 2024

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.lua
  • lua\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.lua
  • lua\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 1482163

autolobby-08.mp4

d41177b

autolobby-06.mp4

320f9f4

autolobby.mp4

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

  • (1) When there are 8 players it frequently happens that not everyone is connected to everyone before the game launches.

Resolved with: e9670d3

  • (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: 5823e21

Existing features

  • (1) Populate initial local player options and share that with the host.
  • (2) Populate initial game options.
  • (3) Correct nickname of peers that are connected (via MakeValidPlayerName)
  • (4) Sync game options from the host to the other peers.
  • (5) Launch the game once the host considers the lobby to be ready.
  • (6) Support for army colors.
  • (7) Support for an initial loading dialog to show before we've received enough information from the host.
  • (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.
  • (10) Mimic the behavior of GpgNetSend in the old autolobby. In paritcular the LaunchStatus, GameState, Disconnected and PlayerOption keys that are sent.

New features

  • (1) Improve the connection window to represent it as a matrix.
  • (2) Add prefetching of a session to reduce loading times.

New features to be discussed

  • (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 PreGamedata as 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.

@Garanas Garanas added the area: matchmaker/autolobby related to the matchmaker lobby label Oct 18, 2024
@Pokute
Copy link
Contributor

Pokute commented Oct 18, 2024

Are there any mods that might affect lobby in a way that needs special considerations / testing?

@Garanas
Copy link
Member Author

Garanas commented Oct 18, 2024

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 😄 !

Copy link
Contributor

@lL1l1 lL1l1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the new design for the autolobby overall. Getting the communication stuff out of the way paves a way for an easier time making improvements like the ones in kyro's lobby that people were a fan of before we unfortunately had to disable it.

By the way remember to use the ReusedLayoutFor.

lua/ui/lobby/autolobby.lua Show resolved Hide resolved
lua/ui/lobby/autolobby/AutolobbyInterface.lua Outdated Show resolved Hide resolved
lua/ui/lobby/autolobby/AutolobbyMessageHandlers.lua Outdated Show resolved Hide resolved
`AutolobbyMessages.lua` now document what messages exist and how/when they are accepted. To prevent too much coupling with the controller we simplified the handler to just be a wrapper to a function inside the lobby.
When running locally the peer Ids line up nicely. However, in practice the peerIds can be all over the place and can not be easily mapped to a number. Therefore we manually keep track of them and map them to a number so that we can visualize it.
This prevents all connections being established at roughly the same time.
@Garanas Garanas marked this pull request as ready for review November 19, 2024 19:36
@Garanas Garanas merged commit b872a71 into develop Nov 19, 2024
5 checks passed
@Garanas Garanas deleted the feature/autolobby branch November 19, 2024 19:47
BlackYps added a commit that referenced this pull request Nov 29, 2024
@Garanas
Copy link
Member Author

Garanas commented Dec 5, 2024

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: .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: matchmaker/autolobby related to the matchmaker lobby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants