summaryrefslogtreecommitdiff
path: root/src/network/network.cpp
AgeCommit message (Collapse)Author
2021-07-20Fix: [Network] rework when to close connections and inform Game Coordinator ↵Patric Stout
if needed
2021-07-11Fix: "Search LAN games" used the socket after it was closed (#9437)Patric Stout
Every outgoing connection, either TCP or UDP, triggered NetworkInitialize(), which triggered NetworkUDPInitialize() which first closes all connections. Now the problem was that "Search LAN games" found a server, added it to the list, after which (over TCP) it queries the server. This closes all UDP sockets (as that makes sense, I guess?), while the UDP was still reading from it. Solve this by simply stop initializing UDP every time we make an outgoing TCP connection; instead only do it on start-up.
2021-07-11Add: allow setting your server visibility to "invite-only" (#9434)Patric Stout
In this mode you do register to the Game Coordinator, but your server will not show up in the public server listing. You can give your friends the invite code of the server with which they can join.
2021-07-11Feature: join servers based on their invite codePatric Stout
This removes the need to know a server IP to join it. Invite codes are small (~7 characters) indentifiers for servers, which can be exchanged with other players to join the servers.
2021-07-11Change: groundwork to allow ServerAddress to use invite codesPatric Stout
Normally TCPConnecter will do a DNS resolving of the connection_string and connect to it. But for SERVER_ADDRESS_INVITE_CODE this is different: the Game Coordinator does the "resolving". This means we need to allow TCPConnecter to not setup a connection and allow it to be told when a connection has been setup by an external (to TCPConnecter) part of the code. We do this by telling the (active) socket for the connection. This means the rest of the code doesn't need to know the TCPConnecter is not doing a simple resolve+connect. The rest of the code only cares the connection is established; not how it was established.
2021-07-11Codechange: track servers with a ServerAddress instead of a NetworkAddressPatric Stout
This allows future extensions to have different ways of referencing a server, instead of forcing to use IP:port.
2021-07-10Remove: old server announcement to Master ServerPatric Stout
As we now use the Game Coordinator for announcements, there is no longer a need to use the Master Server for this.
2021-07-10Add: use Game Coordinator to annouce public serversPatric Stout
2021-07-10Codechange: track version of network servers to prune once out-of-datePatric Stout
2021-06-26Codechange: [Network] Remove overload on NetworkValidateClientNamerubidium42
Rename the zero-parameter NetworkValidateClientName to NetworkValidateOurClientName to make it clearer it is performed on our client name, and to make it a non-overloaded function to aid with the variant being added a few commits later
2021-06-13Change: improve some of the console messages related to networking (make ↵rubidium42
them more uniform) and convert to fmt
2021-06-13Codechange: convert printf DEBUG statements to fmt Debug statementsrubidium42
2021-06-03Fix ef991b17: server was trying to free() a packet created with "new ↵Patric Stout
CommandPacket()" (#9334)
2021-05-29Codechange: Rename window related DeleteXXX to match new behaviourglx22
2021-05-29Codechange: [Network] Use std::string in CommandPacketrubidium42
2021-05-29Fix: [Network] Prevent an empty server name to be set anywhererubidium42
2021-05-17Codechange: [Network] Use C++ string functions to generate company password hashrubidium42
2021-05-16Codechange: [Network] Let NetworkClientInfo use std::stringrubidium42
2021-05-15Codechange: Use std::string GetString where convenientrubidium42
2021-05-15Codechange: [Network] Let NetworkTextMessage use std::stringrubidium42
2021-05-15Change: Use gender-neutral pronounsrubidium42
2021-05-14Codechange: [Network] Pass passwords as std::string to the network coderubidium42
2021-05-14Codechange: [Network] Use std::string for the internal handling of company ↵rubidium42
passwords
2021-05-14Codechange: [Network] Make company state password std::stringrubidium42
2021-05-13Codechange: move client name in settings to std::stringrubidium42
2021-05-13Codechange: move server name/id in settings to std::stringrubidium42
2021-05-13Codechange: move hostnames in settings to std::stringrubidium42
2021-05-13Codechange: move passwords in settings to std::stringrubidium42
2021-05-12Change: reworked the debug levels for network facility (#9251)Patric Stout
It now follows very simple rules: 0 - Fatal, user should know about this 1 - Error, but we are recovering 2 - Warning, wrong but okay if you don't know 3 - Info, information you might care about 4 - 5 - Debug #1 - High level debug messages 6 - Debug #2 - Low level debug messages 7 - Trace information
2021-05-11Fix: [Network] mark server as offline when no longer reachable (#9244)Patric Stout
2021-05-11Fix #9243: [Network] For a dedicated server use a fallback client and server ↵rubidium42
name Also warn when the client or server name has not been set and provide pointers on how to set them
2021-05-11Fix: [Network] don't rebuild the host-list during iterating the list (#9240)Patric Stout
Additionally, only rebuild it when we added a new manual server, as otherwise it is a noop anyway.
2021-05-11Fix: [Network] clients leaving because of broken connections was not ↵Patric Stout
broadcasted (#9238) The code mixed up "client has quit but we already told everyone" with "client lost connection, handle this". Split up those two signals: - CLIENT_QUIT means we told everyone and the connection is now dead - CONNECTION_LIST means we should tell everyone we lost a client
2021-05-09Fix: lobby window doesn't close if no connection could be established (#9223)Patric Stout
2021-05-08Fix: only query a manually added server if it isn't there yetPatric Stout
But always mark it as manually, no matter if it was there or not.
2021-05-08Fix: don't do a network disconnect between two queriesPatric Stout
This meant that on opening the Multiplayer window, if you had more than one server configured, it would one by one cancel all pending queries and send a new. Result: only the last server was updated.
2021-05-08Codechange: move connection_string to private for TCPConnecterPatric Stout
The most common case never needs access to it anymore. Make the one exception to this explicit. This means the fact that we store it is now an implementation detail.
2021-05-08Codechange: [Network] Change ChatMessage's message to std::string and ↵rubidium42
simplify some code
2021-05-06Feature: use Happy Eyeballs to make network connections (TCP-only) (#9199)Patric Stout
Hostnames like "content.openttd.org" resolve into multiple IPv4 and IPv6. It is possible that either of the IPs is not working, either due to a poorly configured OS (having IPv6 but no valid route), broken network paths, or a service that is temporary unavailable. Instead of trying the IPs one by one, waiting for a 3s timeout between each, be a bit more like browsers, and stack attempts on top of each other with slight delays. This is called Happy Eyebells. Initially, try the first IPv6 address. If within 250ms there is no connection yet, try the first IPv4 address. 250ms later, try the second IPv6 address, etc, till all addresses are tried. If any connection is created, abort all the other (pending) connections and use the one that is created. If all fail 3s after the last connect(), trigger a timeout for all.
2021-05-06Codechange: [Network] Use std::string for NetworkGameInforubidium42
2021-05-06Codechange: [Network] Move connection string parsing away from C-stringsrubidium42
2021-05-05Codechange: use connection_string in favour of NetworkAddress (#9197)Patric Stout
We now resolve the connection_string to a NetworkAddress in a much later state. This means there are fewer places constructing a NetworkAddress. The main benefit of this is in later PRs that introduce different types of NetworkAddresses. Storing this in things like NetworkGameList is rather complex, especially as NetworkAddress has to be mutable at all times. Additionally, the NetworkAddress is a complex object to store simple information: how to connect to this server.
2021-05-05Change: [Network] Update server's NetworkServerGameInfo only when neededrubidium42
Split the updating in a "static" version that only needs to be called when a new map is loaded or some settings are changed, and a "dynamic" version that updates everything that changes regularly such as the current game date or the number of spectators.
2021-05-02Fix: [Network] Reading beyond the length of the server's ID when hashing ↵rubidium42
password Under normal circumstances the server's ID is 32 characters excluding '\0', however this can be changed at the server. This ID is sent to the server for company name hashing. The client reads it into a statically allocated buffer of 33 bytes, but fills only the bytes it received from the server. However, the hash assumes all 33 bytes are set, thus potentially reading uninitialized data, or a part of the server ID of a previous game in the hashing routine. It is still reading from memory assigned to the server ID, so nothing bad happens, except that company passwords might not work correctly.
2021-05-01Codechange: rename NetworkError to ShowNetworkErrorrubidium42
2021-05-01Fix #6598: Prevent invalid memory accesses when abandoning a join from ↵rubidium42
within a network game One could join a network game from within an already running network game. This would call a NetworkDisconnect, but keeps the UI alive. If, during that process the join is aborted, e.g. by cancelling on a password dialog, you would still be in your network game but also get shown the server list. Solve all the underlying problems by falling back to the main UI when (re)connecting to a(nother) server.
2021-05-01Codechange: Move join information into a single structurerubidium42
2021-05-01Change: [Console] Show help when passing invalid company numberrubidium42
2021-04-30Change: use TCP for everything except for master-server and initial server ↵Patric Stout
scan (#9130) This means that pressing Refresh button and adding servers manually now uses TCP. The master-server and initial scan are still UDP as they will be replaced by Game Coordinator; no need to change this now. If we query a server that is too old, show a proper warning to the user informing him the server is too old.
2021-04-29Change: [Network] Encapsulate logic about the connection string to the ↵rubidium42
network code (#23)