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