Commit Graph

97 Commits

Author SHA1 Message Date
dP c73b88ddca
Fix: Don't send unused tile field over the network (#10507) 2023-02-24 22:50:11 +01:00
Rubidium 4e65ec1dc4 Codechange: do not declare functions in blocks 2023-01-29 20:28:45 +01:00
Michael Lutz a05fd7aa50 Change: [Network] Transfer command data as serialized byte stream without fixed structure.
The data will be transmitted as the length followed by the serialized data. This allows the command
data to be different for every command type in the future.
2021-12-16 22:28:32 +01:00
dP 31cf9e888b
Add: [Network] external chat messages for remote admins (#9563) 2021-09-19 23:09:06 +02:00
Patric Stout 3d55ea2d4d
Feature: make "join game" button join the game, instead of first showing a lobby window (#9467)
Nobody really paid attention to the lobby window, and it completely
missed its purpose. Most people don't even wait for companies to
show up, but just hit "New Company".
This in turn means people create a lot of unneeded companies, while
they "just want to watch the game" or join another company.

Instead, "Join Game" now just joins the game as spectators.
2021-08-14 23:07:18 +02:00
Patric Stout 508e465b59
Add: synchronize server name to clients and display in Online Players GUI (#9472) 2021-08-14 10:19:40 +02:00
Patric Stout e4d216e44b Feature: join servers based on their invite code
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-11 20:38:42 +02:00
Patric Stout 1baec41542 Change: groundwork to allow ServerAddress to use invite codes
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-11 20:38:42 +02:00
Patric Stout b1280fd17e Add: use Game Coordinator to annouce public servers 2021-07-10 20:17:07 +02:00
Patric Stout e1e2212e0e Codechange: track version of network servers to prune once out-of-date 2021-07-10 20:17:07 +02:00
rubidium42 e3c9ed4d15 Codechange: [Network] Use std::string to determine an unique name for clients 2021-05-30 00:01:49 +02:00
rubidium42 e6703eac68 Codechange: [Network] Let NetworkTextMessage use std::string 2021-05-15 10:20:50 +02:00
rubidium42 1de5cdeab8 Codechange: [Network] Use std::string for the internal handling of company passwords 2021-05-14 23:22:04 +02:00
Patric Stout 583011bca0
Fix: lobby window doesn't close if no connection could be established (#9223) 2021-05-09 18:48:21 +02:00
Patric Stout b9ab3bd6b3 Fix: only query a manually added server if it isn't there yet
But always mark it as manually, no matter if it was there or not.
2021-05-08 17:26:10 +02:00
Patric Stout f7e390bdc0
Feature: use Happy Eyeballs to make network connections (TCP-only) (#9199)
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-06 23:13:35 +02:00
rubidium42 3d91eee919 Codechange: [Network] Move connection string parsing away from C-strings 2021-05-06 20:33:26 +02:00
Patric Stout f94fb93779
Codechange: use connection_string in favour of NetworkAddress (#9197)
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-05 23:21:14 +02:00
rubidium42 0eb17a70af Codechange: rename NetworkError to ShowNetworkError 2021-05-01 19:36:22 +02:00
rubidium42 3bd416bfdb Change: [Console] Show help when passing invalid company number 2021-05-01 18:30:08 +02:00
Patric Stout 69118d063f
Change: use TCP for everything except for master-server and initial server 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-30 11:34:47 +02:00
rubidium42 a61696d6c5 Change: [Network] Encapsulate logic about the connection string to the network code (#23) 2021-04-29 20:12:11 +02:00
Patric Stout cb2ef1ea4b Codechange: move all NetworkGameInfo related functions to a single file
It currently was a bit scattered over the place. Part of
NetworkGameInfo is also the GRF Identifiers that goes with it.
2021-04-27 20:18:53 +02:00
Patric Stout 05612d60ae Remove: "language" field from server/client
The original idea was that people could find a server they could
talk in their native language on. This isn't really used in that
way. There are several reasons for removing this:

- the client also sends his "language" to the server, but nothing
  is doing anything with this.
- flags are a bad way to represent languages, and over the years
  we had several (rightfully) complaints about this.
- most servers have their language set to "All", and prefix the
  servername with the language it is about. This is a much more
  efficient way to do the same.

All in all, this feature should go back to the drawing board.
Maybe it could work in another form, but this form is not it.
2021-04-20 17:24:38 +02:00
Rubidium ca6b9ad8b0 Change: move some things only relevant to UDP from network.cpp to network_udp.cpp 2021-04-12 21:10:21 +02:00
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 2019-04-10 23:22:20 +02:00
Patric Stout e3c639a09f Remove: ENABLE_NETWORK switch
This switch has been a pain for years. Often disabling broke
compilation, as no developer compiles OpenTTD without, neither do
any of our official binaries.

Additionaly, it has grown so hugely in our codebase, that it
clearly shows that the current solution was a poor one. 350+
instances of "#ifdef ENABLE_NETWORK" were in the code, of which
only ~30 in the networking code itself. The rest were all around
the code to do the right thing, from GUI to NewGRF.

A more proper solution would be to stub all the functions, and
make sure the rest of the code can simply assume network is
available. This was also partially done, and most variables were
correct if networking was disabled. Despite that, often the #ifdefs
were still used.

With the recent removal of DOS, there is also no platform anymore
which we support where networking isn't working out-of-the-box.

All in all, it is time to remove the ENABLE_NETWORK switch. No
replacement is planned, but if you feel we really need this option,
we welcome any Pull Request which implements this in a way that
doesn't crawl through the code like this diff shows we used to.
2019-03-20 19:24:55 +01:00
rubidium 160ad31028 (svn r26488) -Codechange: perform the appropriate length checks when getting a client name 2014-04-23 21:19:54 +00:00
frosch c6ce57e8a7 (svn r26370) -Doc: Desync debugging and command replaying. 2014-02-23 19:32:32 +00:00
rubidium b3e93d6520 (svn r26057) -Fix: a number of possibly uninitialised variables 2013-11-23 13:12:19 +00:00
rubidium 2e54c8fdfa (svn r26056) -Fix: a number of possibly uninitialised variables 2013-11-22 21:50:43 +00:00
rubidium 1adb9a5c85 (svn r24070) -Fix [FS#5098]: the 'last joined' server was not properly selected anymore (adf88) 2012-03-25 19:46:59 +00:00
rubidium b888027ddd (svn r23843) -Fix: minor issue with replaying ;) 2012-01-22 21:27:15 +00:00
rubidium a66debfadd (svn r23822) -Fix-ish: when replaying make sure companies get created even if their creating client doesn't exist during the replay 2012-01-17 21:13:02 +00:00
rubidium c4aa943aaa (svn r22424) -Document: some more bits 2011-05-05 16:24:48 +00:00
rubidium f1d0c1a746 (svn r22363) -Codechange: NetworkFindClientStateFromClientID -> NetworkClientSocket::GetByClientID 2011-04-22 15:54:42 +00:00
rubidium eb299736c1 (svn r21886) -Codechange: move documentation towards the code to make it more likely to be updated [n]. 2011-01-22 09:53:15 +00:00
rubidium e54a1f6721 (svn r21853) -Codechange: HashCurrentCompanyPassword is only used by servers, so move it to network_server.* (dihedral) 2011-01-19 16:37:06 +00:00
rubidium b25cf57542 (svn r21701) -Codechange: ConsoleColour = TextColour, so make it that way and remove some unneeded casts 2011-01-03 12:01:41 +00:00
rubidium 2cd67a51ac (svn r21029) -Codechange: split the map downloading packet + 3-state enum into 3 separate packets 2010-10-24 20:03:33 +00:00
rubidium f712055002 (svn r20936) -Codechange: make server side packet sending methods class methods 2010-10-15 20:25:07 +00:00
rubidium 9858d699a3 (svn r20935) -Codechange: only let the server side use a pool of connected sockets 2010-10-15 19:58:56 +00:00
rubidium bda26d03b5 (svn r20934) -Codechange: move NetworkGetClientName to the server's socket 2010-10-15 19:35:08 +00:00
rubidium f555e6d72e (svn r20933) -Codechange: move some more client related methods and such to network_client.cpp 2010-10-15 19:33:08 +00:00
rubidium 7ba07d9573 (svn r20929) -Codechange: make NetworkCloseClient a class method 2010-10-15 18:42:52 +00:00
rubidium 515edee17c (svn r20925) -Codechange: make the client send commands have a slightly more sensible name 2010-10-15 14:29:13 +00:00
alberth be59c90e86 (svn r20674) -Codechange: Remove declared functions that do not exist (anymore) otherwise. 2010-08-28 20:15:45 +00:00
rubidium b594990071 (svn r20549) -Codechange: centralise the handling of the incoming commands (from clients and the server) 2010-08-18 22:40:17 +00:00
rubidium 088282bcf8 (svn r19620) -Fix: desync when a command is received and in the queue while a client starts joining, i.e. save the game state. This can happen in two ways: with frame_freq > 1 a command received in a previous frame might not be executed yet or when a command is received in the same frame as the join but before the savegame is made. In both cases the joining client would not get all commands to get in-sync with the server (and the other clients). 2010-04-13 18:55:31 +00:00