Replace master-server (UDP-based) with Game Coordinator (TCP-based) #9411
Motivation / Problem
This is a part of #9017.
Currently OpenTTD communicates over UDP with the master-server to register itself, and the master-server uses UDP to polls the server for game-state. This has several disadvantages, as we noticed over the years:
In total, it became pretty clear we should just stop using UDP, and switch completely to TCP. Well, I say completely .. local LAN discovery is and always will be UDP based. That is just how multicasts work ;)
To be clear, this doesn't mean OpenTTD will always be using TCP. It is surely an option to use some library like https://github.com/ValveSoftware/GameNetworkingSockets that does resilient connections over UDP. Either way, we first have to change to a single way of doing stuff, before we can think about changing it all to something else. And this is far out of scope of this PR.
This removes all master-server communication and all UDP-related code from OpenTTD, and replaces it with a TCP-based Game Coordinator code.
Why the change of name? To keep it clear that this is a completely different component. And in the future the Game Coordinator will be tasked with many other tasks, like join-keys, STUN, TURN, etc. It much more takes on the role of a coordinator, and no longer "just" lists the servers.
The way it works is like this (and yes, this is documented in
/** * Game Coordinator communication. * * For servers: * - Server sends CLIENT_REGISTER. * - GC probes server to check if it can directly connect. * - GC sends SERVER_REGISTER_ACK with type of connection. * - Server sends every 30 seconds CLIENT_UPDATE. * * For clients (listing): * - Client sends CLIENT_LISTING. * - GC returns the full list of public servers via SERVER_LISTING (multiple packets). */
Basically this means as soon as the client clicks "Search Internet", it gets the full list of servers, including their details. It no longer has to send a flood of UDP packets to all servers.
Future PRs will extend this functionality with invite-codes, STUN, TURN, ... But, baby-steps.
Currently there are a few rough edged, but further PRs will address those. For example:
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.
The text was updated successfully, but these errors were encountered:
I think this is ready. Game Coordinator is deployed, and talks (two-way) with the Master Server. So anything listed in the Master Server shows up via the Game Coordinator, and the other way around.
Of course you cannot join those servers that are exchanged, as they for sure are of a different revision, but that is not really the point here ;)
It could use some testing of some people, just registering their server, see if they can find it, etc etc. But .. I think this is ready :)