Commit Graph

1480 Commits

Author SHA1 Message Date
Patric Stout dd7f69be6e
Fix: "Search LAN games" used the socket after it was closed (#9437)
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-11 22:37:14 +02:00
Rubidium 178ea3196b Remove: includes to network/core/config.h from headers when only three cpp files need it 2021-07-11 22:13:59 +02:00
Patric Stout b6a116a247
Add: allow setting your server visibility to "invite-only" (#9434)
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-11 21:57:05 +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 cee8174d02 Codechange: track servers with a ServerAddress instead of a NetworkAddress
This allows future extensions to have different ways of referencing
a server, instead of forcing to use IP:port.
2021-07-11 20:38:42 +02:00
Patric Stout f4dd2d88c7 Feature: raise the maximum NewGRF limit to 255 2021-07-11 12:16:07 +02:00
Rubidium e99134654b Feature: allow setting (game) coordinator and content server connection strings using environment variables
OTTD_COORDINATOR_CS for the game coordinator defaults to coordinator.openttd.org:3976
OTTD_CONTENT_SERVER_CS for the content server defaults to content.openttd.org:3978
OTTD_CONTENT_MIRROR_CS for the content mirror server defaults to binaries.openttd.org:80
2021-07-10 23:09:45 +02:00
Patric Stout de7ab2eb1c Cleanup: remove unused optional ctor parameter for NetworkGameList 2021-07-10 20:17:07 +02:00
Patric Stout 6212d0a8da Remove: unused UDP protocol parts 2021-07-10 20:17:07 +02:00
Patric Stout 8a2da49413 Remove: old server listing via Master Server
This removes all UDP from the game except for a local broadcast
to find LAN games.

So long Master Server, and tnx for all the fish!
2021-07-10 20:17:07 +02:00
Patric Stout 61fdef8457 Remove: old server announcement to Master Server
As we now use the Game Coordinator for announcements, there is no
longer a need to use the Master Server for this.
2021-07-10 20:17:07 +02:00
Patric Stout aa93d76223 Add: use Game Coordinator to get latest public server listing 2021-07-10 20:17:07 +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
Patric Stout cbaac5609f Codechange: use UpdateNetworkGameWindow() over manually marking window dirty 2021-07-10 20:17:07 +02:00
Stephan a70aa5df49
Add #9188: netsave now keeps multiple version around, similar to autosave (#9395) 2021-07-09 21:44:02 +02:00
Patric Stout 852e056d6f
Fix 9e32c618: network revision was always empty (#9419)
Shadowing the variable you intend to write in tends to do that ;)
2021-07-08 12:29:16 +02:00
Patric Stout d38079d053
Fix f7e390bd: freeaddrinfo() is not guaranteed to handle a nullptr graceful (#9404) 2021-06-29 23:02:25 +02:00
TELK f9b4a3a5e6
Add: Show the number of clients and companies in the online players window (#9376) 2021-06-28 18:42:23 +02:00
rubidium42 cdf9caf8ea Codechange: [Network] Remove overload on NetworkValidateClientName
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-26 20:28:34 +02:00
Rubidium f904aef176 Cleanup: use nullptr instead of 0 or NULL 2021-06-17 16:18:30 +02:00
SamuXarick d0bcb9839a
Fix: you could join an AI company in multiplayer via the GUI (#9369) 2021-06-15 14:00:50 +02:00
rubidium42 05005dcdfa Codechange: [Network] Use std::string instead of char[] for the name of the file that is downloading 2021-06-15 06:13:00 +02:00
rubidium42 981cd0197a Codechange: [Network] Use std::string for the client name in the network server 2021-06-15 06:13:00 +02:00
rubidium42 a8b3afb236 Codechange: [Network] Use string_view for network compatability check 2021-06-15 06:13:00 +02:00
rubidium42 49dcf0c772 Codechange: [Network] Simplify constructing the HTTP request with fmt 2021-06-15 06:13:00 +02:00
rubidium42 53b4786037 Codechange: [Network] Let NetworkError return its std::string instead of a C-string 2021-06-15 06:13:00 +02:00
rubidium42 667301e3ec Codechange: [Network] Make hostname/client IP return strings instead of a C-string 2021-06-15 06:13:00 +02:00
rubidium42 a91e29b656 Codechange: [Network] Let IsInNetmask use std::string 2021-06-15 06:13:00 +02:00
rubidium42 36705f1dc0 Codechange: [Network] Simplify formatting of network addresses to string 2021-06-15 06:13:00 +02:00
rubidium42 9e32c618f9 Fix: [Network] Determining GetNetworkRevisionString could overflow and underflow its buffer
Tagged releases are not affected
2021-06-14 23:05:18 +02:00
rubidium42 eb6cdadc4d Codechange: replace IConsolePrintF with IConsolePrint and fmt formatting
Also make some strings more consistent with the rest of the console strings.
2021-06-13 15:25:31 +02:00
rubidium42 d9c1d18f2b Change: improve some of the console messages related to networking (make them more uniform) and convert to fmt 2021-06-13 15:25:31 +02:00
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 2021-06-13 12:45:45 +02:00
rubidium42 845fded2a0 Fix #9361, a2051ba: [Network] Off by one in CanWriteToPacket
Previously it did not allow writing a byte to a packet that was of size limit - 1 anymore.
2021-06-13 10:31:02 +02:00
TELK 2d0abf5a76
Fix #9362: Hover in online players window was slightly too big (#9364)
This causes graphical glitches at the bottom of the window.
2021-06-13 10:06:50 +02:00
rubidium42 bb8fd00760 Cleanup: [Network] Remove C-string Recv_string and its last use 2021-06-10 21:53:19 +02:00
rubidium42 ab9b937ab7 Codechange: [Network] Use std::string to get a NewGRF's name 2021-06-10 21:53:19 +02:00
rubidium42 e2417193c9 Cleanup: [ContentInfo] Remove some functions that are not needed anymore 2021-06-10 20:09:44 +02:00
rubidium42 e3717ae903 Codechange: [ContentInfo] Use std::string instead of string buffers 2021-06-10 20:09:44 +02:00
rubidium42 df181bb641 Codechange: [ContentInfo] Use a vector for dependencies instead of custom allocation 2021-06-10 20:09:44 +02:00
rubidium42 9c424ab741 Codechange: [ContentInfo] Use StringList for tags instead of custom allocations 2021-06-10 20:09:44 +02:00
rubidium42 dfb89f3891 Codechange: [ContentInfo] Do not use memset/memcpy to make it possible to use vector/string 2021-06-10 20:09:44 +02:00
rubidium42 6bb3f034e4 Cleanup: [ContentInfo] Remove unused function 2021-06-10 20:09:44 +02:00
Patric Stout 5e44da3010
Fix ef991b17: server was trying to free() a packet created with "new CommandPacket()" (#9334) 2021-06-03 22:07:44 +02:00
rubidium42 8c273ed598 Codechange: [Network] Let admin-console use std::string(_view) 2021-05-30 10:15:22 +02:00
rubidium42 e58581f1f8 Codechange: [Network] Let admin-game script use std::string 2021-05-30 10:15:22 +02:00
rubidium42 8a918ce170 Codechange: [Network] Make admin name and version std::string 2021-05-30 10:15:22 +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 806f78aa04 Codechange: [Network] Use std::string to send the client name and rcon commands 2021-05-30 00:01:49 +02:00
rubidium42 fd95736bac Codechange: [Network] Use std::string for server side logic of kicking and banning clients 2021-05-30 00:01:49 +02:00
rubidium42 f0e1cd0129 Codechange: [Network] Let server rcon result use std::string 2021-05-30 00:01:49 +02:00
rubidium42 8b9f1147df Codechange: [Network] Let server changing a client name use std::string 2021-05-30 00:01:49 +02:00
glx22 5799402f7a Codechange: Rename window related DeleteXXX to match new behaviour 2021-05-29 21:08:25 +02:00
glx22 994bf19aef Fix f6d5c01: Delay deletion when closing windows 2021-05-29 21:08:25 +02:00
rubidium42 ef991b1772 Codechange: [Network] Use std::string in CommandPacket 2021-05-29 19:02:18 +02:00
rubidium42 2e136285e1 Codechange: move from C-string to std::string for DoCommand 2021-05-29 19:02:18 +02:00
Patric Stout ca9a7df752
Codechange: rename str_validate to StrMakeValid(InPlace) (#9304)
This to be more explicit the function changes the value, and not
returns yes/no.
2021-05-29 11:21:38 +02:00
rubidium42 4144e949ed Fix: [Network] Prevent an empty server name to be set anywhere 2021-05-29 10:07:30 +02:00
rubidium42 e2f5d9e561 Codechange: use separate pre and post callbacks for string settings 2021-05-29 10:07:30 +02:00
rubidium42 208952f2ba Codechange: split Write_ValidateSetting to get separate functions for making strings valid and writing strings 2021-05-29 10:07:30 +02:00
rubidium42 72ec81325b Cleanup: remove unneeded temporary variables and casts 2021-05-27 18:49:43 +02:00
rubidium42 8ffb4122df Codechange: just pass the SettingDesc to SetSettingValue and remove distinction between (non)company 2021-05-27 18:49:43 +02:00
rubidium42 b791ffc6de Fix: do not hide parameter by local variable with the same name 2021-05-27 18:30:56 +02:00
milek7 7607277380 Fix: Network on Haiku, remove old code for BeOS 2021-05-24 08:56:18 +02:00
rubidium42 e2dc5aa83e Codechange: [Network] Use C++ string functions to generate company password hash 2021-05-17 16:09:10 +02:00
rubidium42 4d246cda73 Codechange: [Network] Let NetworkClientInfo use std::string 2021-05-16 10:07:51 +02:00
rubidium42 83679c0e57 Codechange: [Network] Use std::string to populate the client list for company stats 2021-05-16 10:07:51 +02:00
rubidium42 e90b2649b6 Codechange: [Network] Let NetworkCompanyInfo use std::string 2021-05-16 10:07:51 +02:00
rubidium42 fab120ee83 Codechange: [Network] Let chat communication use std::string 2021-05-15 10:20:50 +02:00
rubidium42 ae85af98eb Codechange: Use std::string GetString where convenient 2021-05-15 10:20:50 +02:00
rubidium42 e6703eac68 Codechange: [Network] Let NetworkTextMessage use std::string 2021-05-15 10:20:50 +02:00
rubidium42 44ca7d9377 Change: Use gender-neutral pronouns 2021-05-15 10:16:48 +02:00
Rubidium bb9121dbd4 Fix: comparison of narrow type to wide type in loop (potential for infinite loops) 2021-05-15 10:16:10 +02:00
Rubidium 031e91de6e Fix: [Network] Check on CIDR for netmask check considered everything valid 2021-05-15 10:16:10 +02:00
rubidium42 297d6e20bf Codechange: [Network] Pass passwords as std::string to the network code 2021-05-14 23:22:04 +02:00
rubidium42 ebe32ad912 Codechange: [Network] Use std::string for the internal handling of admin/rcon passwords 2021-05-14 23:22:04 +02:00
rubidium42 6db52d52d0 Codechange: [Network] Use std::string for the internal handling of server passwords 2021-05-14 23:22:04 +02:00
rubidium42 1de5cdeab8 Codechange: [Network] Use std::string for the internal handling of company passwords 2021-05-14 23:22:04 +02:00
rubidium42 98283116fa Codechange: [Network] Make company state password std::string 2021-05-14 23:22:04 +02:00
rubidium42 16437b7c0d Codechange: move client name in settings to std::string 2021-05-13 23:13:17 +02:00
rubidium42 02fdb5b210 Codechange: move server name/id in settings to std::string 2021-05-13 23:13:17 +02:00
rubidium42 cc6c078dec Codechange: move hostnames in settings to std::string 2021-05-13 23:13:17 +02:00
rubidium42 c73d64adf9 Codechange: move passwords in settings to std::string 2021-05-13 23:13:17 +02:00
rubidium42 f219354f89 Change: further support for std::string in settings 2021-05-13 23:13:17 +02:00
Patric Stout a403653805
Codechange: [Network] split CloseSocket and CloseConnection more clearly (#9261)
* Codechange: [Network] split CloseSocket and CloseConnection more clearly

- CloseSocket now closes the actual OS socket.
- CloseConnection frees up the resources to just before CloseSocket.
- dtors call CloseSocket / CloseConnection where needed.
2021-05-13 11:46:51 +02:00
Rubidium 187a3f20bf Codechange: remove pointless close call due to resolving virtual functions statically in destructors
In the destructors of many of the network related classes Close() is called, just like the
top class in that hierarchy. However, due to virtual functions getting resolved statically
in the destructor it would always call the empty Close() of the top class.
Document the other cases where a virtual call is resolved statically.
2021-05-13 10:03:26 +02:00
Patric Stout d7ce61f106
Fix #9255: [Network] TCPConnecter crashes when hostname not found (#9259) 2021-05-13 08:13:48 +02:00
Patric Stout b136e65cf9
Change: reworked the debug levels for network facility (#9251)
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-12 16:34:02 +02:00
Patric Stout d0eb3e4bc4
Fix: [Network] mark server as offline when no longer reachable (#9244) 2021-05-11 19:19:37 +02:00
rubidium42 0968d009c8 Fix #9243: [Network] For a dedicated server use a fallback client and server name
Also warn when the client or server name has not been set and provide pointers on how to set them
2021-05-11 19:09:04 +02:00
Patric Stout 9e7e87ce3e
Fix: [Network] don't rebuild the host-list during iterating the list (#9240)
Additionally, only rebuild it when we added a new manual server,
as otherwise it is a noop anyway.
2021-05-11 12:32:27 +02:00
Patric Stout 9841ebb0bd
Fix: [Network] don't mark the last-joined server as manual (#9239) 2021-05-11 12:26:30 +02:00
Patric Stout 36e22f3a7b
Fix: [Network] clients leaving because of broken connections was not 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-11 12:26:16 +02:00
Rubidium 495d73a67f Fix: leaking file descriptors 2021-05-10 16:03:31 +02:00
Patric Stout 8f4a612a7c
Change: reworded many of the network errors during connect/listen (#9230)
Also changed some levels to 0, as a failing listen() is something
we should tell the user about. Hiding this information is a bit
evil.
2021-05-10 13:40:28 +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 fc91f1d1b2 Fix: don't do a network disconnect between two queries
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-08 17:26:10 +02:00