Commit Graph

1697 Commits

Author SHA1 Message Date
Tyler Trahan ba3de0383a
Codechange: Pass more std::string to StringFilter::AddLine() (#10743) 2023-04-30 10:23:05 +02:00
Rubidium c829930440 Codechange: replace strnatcmp with C++ string capable version 2023-04-29 12:07:45 +02:00
Rubidium 4dd5f994be Codechange: replace strncasecmp with case ignoring variant of StrStarts/EndsWith 2023-04-29 10:25:25 +02:00
Patric Stout 36a0818bc5
Remove: buying/selling/owning company shares (#10709) 2023-04-29 10:16:49 +02:00
Rubidium b221fa3c5a Codechange: use fmt::format_to instead of seprintf to create the search URL 2023-04-28 19:53:03 +02:00
Rubidium 3105d0b09e Codechange: replace text-buf printf with fmt::format 2023-04-26 18:46:17 +02:00
Tyler Trahan 930f0a16d8 Codechange: Define Date/Year/Month/Day within TimerGameCalendar class 2023-04-26 07:14:03 -04:00
Rubidium f74e26ca7e Codechange: replace error/usererror printf variant with fmt variant and rename 2023-04-25 17:55:09 +02:00
Patric Stout 7aa2b9ab0a
Codechange: move all date-related variables inside the timer (#10706) 2023-04-24 15:56:01 +00:00
Charles Pigott b282664242 Codechange: Replace all usages of alloca/AllocaM with more modern/less discouraged alternatives 2023-04-15 16:57:00 +01:00
Patric Stout 3ebc7ad16e Codechange: migrate all game-time-related timers to the new framework 2023-04-15 13:58:55 +02:00
Patric Stout 1ba4dcc924 Codechange: migrate all Window-related timers to the new framework
This means we also say goodbye to GUITimers.
2023-04-15 13:58:55 +02:00
rubidium42 730687080a
Fix: Update some network documentation to match the new command system (#10657) 2023-04-15 09:10:09 +00:00
Peter Nelson e5af5907ec Change: Make all dropdown lists extend width if necessary.
This removes the auto_width parameter from ShowDropDown(At).
2023-04-13 20:57:47 +01:00
Peter Nelson 47e12a8790 Codechange: Check that CompanyMask fits into 16 bits during compilation. 2023-04-07 22:09:55 +01:00
Peter Nelson b6609d1833 Fix: Network server highlight invisible with RTL layout. 2023-03-07 22:05:22 +00:00
Zachary e17c82e32b Add: maximum number of companies allowed to the client list 2023-02-28 20:52:46 +01:00
dP c73b88ddca
Fix: Don't send unused tile field over the network (#10507) 2023-02-24 22:50:11 +01:00
Patric Stout fdfcb09aa3 Fix #10131: actually cancel downloads when pressing cancel 2023-02-15 23:48:06 +01:00
Patric Stout dea2dea881 Fix: reset content download progress to zero if falling back to TCP
Otherwise this chain of events can happen:
- You already have a (partial) file downloaded
- You start the download, and HTTP fails
- This resets the download progress to the current size of the file
- The TCP download starts at a very large value (UINT32_MAX - filesize)

It now resets to 0% done when any negative value is being given.
As added bonus, we no longer have to query how much was already
downloaded.
2023-02-15 23:48:06 +01:00
Patric Stout 1c17556f96 Codechange: replace instance of char * with std::string 2023-02-15 23:48:06 +01:00
Patric Stout 0722bb3bf4
Change: try to detect the CA file/path for CURL (#10481)
The default is given compile-time, not run-time. So libcurl is
of no use to us.

Current list is kindly borrowed from
https://go.dev/src/crypto/x509/root_linux.go
2023-02-15 22:58:43 +01:00
Patric Stout ea90fa24f8
Codechange: move curl into a thread so simplify code (#10480)
With a thread, we can just run curl_easy_perform() and let CURL
and threads handle the blocking part.

With async solution there are too many things to keep track of,
and it makes "when to update the GUI" tricky. By using a thread
that all gets a lot simpler, as the game-thread and download-thread
run side-by-side.

This is similar to how the WinHttp backend already works.
2023-02-15 21:56:19 +01:00
frosch d7fcb420c4 Fix: compilation with libcurl from 2013. 2023-02-13 22:45:07 +01:00
Patric Stout 64523709bf
Add: use https:// for content-service connections (#10448)
This requires the use of WinHTTP (for Windows) or libcurl (for all
others except Emscripten). Emscripten does not support http(s)
calls currently.

On Linux it requires ca-certificates to be installed, so the HTTPS
certificate can be validated. It is really likely this is installed
on any modern machine, as most connections these days are HTTPS.

(On MacOS and Windows the certificate store is filled by default)

Reminder: in case the http(s):// connection cannot be established,
OpenTTD falls back to a custom TCP-based connection to fetch the
content from the content-service. Emscripten will always do this.
2023-02-12 12:07:31 +01:00
Loïc Guilloux a2c8168924
Fix #10465: Delay closing of network join progress window (#10466) 2023-02-11 12:32:45 +01:00
Rubidium 4e65ec1dc4 Codechange: do not declare functions in blocks 2023-01-29 20:28:45 +01:00
rubidium42 6ba55e663e Codechange: do not hide variables with other variables 2023-01-29 07:21:34 +01:00
Rubidium ed7685910d Codechange: pass large objects by reference instead of value
Especially when they get passed on directly to the next function or via a
constructor into an instance variable
2023-01-28 13:43:21 +01:00
Rubidium 7e1d272397 Cleanup: remove unused static variables 2023-01-27 07:05:49 +01:00
Rubidium fe2bcd2a58 Codechange: migrate size related functions to Map structure 2023-01-21 17:11:40 +01:00
Rubidium 8f9a60893d Fix #10177: company list password padlock showed after switching to single player 2023-01-15 11:52:51 +01:00
Rubidium 6dfd2cad69 Fix: comparison result is always the same warnings 2023-01-15 00:24:20 +01:00
Rubidium 90f1768006 Codechange: add non-nullptr asserts in cases where it should never be nullptr
Though where similar calls are checked for nullptr as in those instances of
the use of that function it can actually return nullptr. In other words, write
down the assumption that the function never returns nullptr in an assert.
2023-01-14 21:15:23 +01:00
Rubidium bcfe0fb076 Codechange: introduce GetMainWindow() to properly account for nullptr checks
Some nullptr checks have been removed as they were not triggered with nullptr
with the null video driver and in dedicated server mode.
2023-01-14 21:15:23 +01:00
Patric Stout 1fb101eabb
Codechange: address CodeQL issue "Multiplication result converted to larger type" (#10306)
Most are very unlikely to ever be triggered in our codebase; two
stand out: linkgraph and money cheat. Those, potentially, could
wrap earlier than expected.
2023-01-02 20:30:02 +00:00
PeterN 131b7f5127
Fix: Vertically centre chat prompt. (#10250) 2022-12-17 12:22:02 +00:00
dP 5e14a20b3b
Feature: [GS] Scriptable league tables (#10001) 2022-11-26 18:03:03 +01:00
Peter Nelson ecb5393c55 Change: Standardize progress bar layout.
Progress bars are drawn differently depending on when it was added, with
different layouts and sizes.

This change adds a standard padding size to use, and makes all progress
bars visually similar, with scaled padding.
2022-11-12 18:28:39 +00:00
Peter Nelson 920e588334 Change: Use standard dimensions instead of custom widths. 2022-11-12 18:28:39 +00:00
Peter Nelson 890b2666d3 Change: Use scaled WidgetDimensions. 2022-11-12 18:28:39 +00:00
Peter Nelson b6ed595176 Codechange: Prefer suggested widget padding. 2022-11-12 18:28:39 +00:00
Peter Nelson dd9f6bc803 Change: Use RectPadding Horizontal()/Vertical() helpers. 2022-11-12 18:28:39 +00:00
Peter Nelson 04cbe57d2a Change: Use RectPadding for widget padding/uz_padding. 2022-11-12 18:28:39 +00:00
Peter Nelson 6f95e04005 Change: Use Rect helpers for widget drawing.
This replaces repetitive and sometimes unwieldy use of constants.
2022-11-12 18:28:39 +00:00
Rubidium d5aafaee15 Codechange: rename and move some strings to make them more consistent with the rest of the strings 2022-11-02 17:58:44 +01:00
Michael Lutz 35d9cea487
Fix: Too many braces make old gcc sad. (#10116) 2022-11-02 00:53:44 +01:00
frosch f4e2a462fe Cleanup: Remove unused flag sprites. 2022-10-16 14:56:52 +02:00
Peter Nelson dc1b84aa1e Cleanup: Text widgets are capable of drawing text without assistance.
Remove custom text drawing of some widgets in favour of standard text
widgets.
2022-10-16 14:24:51 +02:00
Peter Nelson 296af146fb Change: Default widget text colour to black.
TC_FROMSTRING really means blue, and we almost never actually use
blue text.
2022-10-16 14:24:51 +02:00
Peter Nelson fa5e2ca276 Cleanup: Tweak panel layout of Online Players window.
This ensures panel borders not hidden behind other widgets.
2022-09-20 07:51:25 +01:00
Peter Nelson 8e9ca5ebcb Fix: Online Players list mouse hover behaviour.
Hover highlight was visible even if the mouse pointer was in a different
window, and the window refreshed itself every frame if the mouse pointer
was not over its matrix widget.

Resolved by using OnMouseOver() instead of OnMouseLoop(), and only
redrawing if the hover position has changed.
2022-09-20 07:51:25 +01:00
dP 64453cb134
Fix: Incorrect player name in online players window (#10013) 2022-09-12 09:18:41 +01:00
Joel-Milligan 3937953f72
Fix #9363: Rebuild client list on reinit event (#9929) 2022-08-30 14:56:19 +02:00
Aaron Katzin 148695c571
Fix #9736: Duplicate multiplayer window opens upon canceling password entry (#9842) 2022-04-02 10:37:07 +02:00
Rubidium c73f578e8c Codechange: replace magic numbers and C-style arrays with C++-style array for share owners 2022-03-09 18:05:12 +01:00
Michael Lutz b11bd185e3 Fix #9756: Network command unpack proc was not generated in all cases.
The case where the callback proc takes all command results but not any of
the command parameters was not handled properly.
2021-12-20 23:32:23 +01:00
Michael Lutz e67124e174 Change: [Admin] Bump admin port protocol due to command changes.
docs/admin_network.md promised that information in an admin packet
is never removed. It does allow the possibility of using a new packet type
for changed data in combination with a bump of the admin port version.

As the recent command handling changes modified the contents of
ADMIN_PACKET_SERVER_CMD_LOGGING, do exactly that.
2021-12-20 19:30:27 +01:00
Michael Lutz afc3d71fd0 Codechange: Don't generate CommandPacket unpack functions for invalid cmd/callback combinations.
If the arguments of the callback proc don't match with the command parameters,
we can't do the proper command execution anyway. As such, don't even generate
an unpack function in the first place, saving a bit of unnecessary code bloat.

Validate on receive that the cmd/callback combination is supported, rejecting
clients that try to send invalid values.
2021-12-16 22:28:32 +01:00
Michael Lutz 3e85e833a7 Codechange: Add support for additional command result values. 2021-12-16 22:28:32 +01:00
Michael Lutz 8503854655 Codechange: Pass unpacked command arguments to command callbacks (except Script). 2021-12-16 22:28:32 +01:00
Michael Lutz d85348b1d1 Codechange: Template the command callback function type to allow unpacked arguments. 2021-12-16 22:28:32 +01:00
Michael Lutz 13528bfcd0 Codechange: Un-bitstuff all remaining commands. 2021-12-16 22:28:32 +01:00
Michael Lutz 4f3ea3907e Codechange: Un-bitstuff commands taking a ClientID (i.e. CMD_CLIENT_ID). 2021-12-16 22:28:32 +01:00
Michael Lutz ccefa76a46 Codechange: Template DoCommandPInternal. 2021-12-16 22:28:32 +01:00
Michael Lutz 0f64ee5ce1 Codechange: Template DoCommandP to automagically reflect the parameters of the command proc.
When finished, this will allow each command handler to take individually
different parameters, obliviating the need for bit-packing.
2021-12-16 22:28:32 +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
Michael Lutz 123c7f99c3 Codechange: Move command callback declarations to the cmd header files. 2021-12-16 22:28:32 +01:00
Michael Lutz a38bbefe1b Codechange: Untangle command code, flags and error string for DoCommand*. 2021-12-16 22:28:32 +01:00
Michael Lutz 549caca39c Codechange: Move command arguments to the back of the networked command function calls. 2021-12-16 22:28:32 +01:00
Rubidium ad89601c49 Codechange: do not use all upper case enumerators in a scoped enum 2021-12-05 21:41:43 +01:00
Patric Stout ea4f6bb8b2
Fix #9730: [Network] connections can use an invalid socket due to a race condition
A race condition happens when an IPv6 connection takes more than
250ms to report an error, but does return before the IPv4 connection
is established.
In result, an invalid socket might be used for that connection.
2021-12-04 20:56:05 +01:00
Patric Stout 9c36c12c85
Codechange: ensure OnConnect() always gets called with a valid socket (#9729)
This should already be the case, but now assert()s will tell us
if this isn't.
2021-12-04 18:32:06 +01:00
Michael Lutz 8c558d74a5 Fix 55a11710: Curly braces need to be double-escaped for (std::)fmt. 2021-11-06 20:21:07 +01:00
dP 80e3397f85
Fix 3a1a915: Every 16th client never reconnects after server restart 2021-11-03 21:33:38 +01:00
glx22 1c0700e0c0 Fix #9624: compilation with RANDOM_DEBUG 2021-10-19 09:05:00 +01:00
Charles Pigott 3b7daca832
Change: Don't use 'server address' string in server list when displaying an invite code (#9615) 2021-10-17 18:14:25 +01:00
Patric Stout e4ad632989
Add: [Network] Keep the refresh button in lowered state while refreshing (#9600)
This gives user visual feedback that the refresh is still pending, and
prevents people from clicking again and again thinking nothing is
happening. This is especially true for connections that fall back to
TURN, as that takes a few seconds to kick in.

Additionally, prevent clicking on the button again while a refresh
is pending. This is only delaying a successful result.
2021-10-03 11:02:28 +02:00
dP 31cf9e888b
Add: [Network] external chat messages for remote admins (#9563) 2021-09-19 23:09:06 +02:00
Patric Stout d9f8ed7bdf
Add: [Network] On join, log the ClientID + IP + Name clearly (#9558)
Additionally, reword the disconnect to match connect / join messages.

Co-authored-by: Berbe <4251220+Berbe@users.noreply.github.com>
2021-09-19 21:52:46 +01:00
Patric Stout a8641ea44a
Add: support filtering content entries for patchpacks (#9541)
This changes nothing for us, but allows patchpacks to add the
right pieces of code to start filtering content entries on patchpack
only entries.
2021-09-11 15:34:46 +02:00
Jonathan G Rennison 6e3d023e69
Fix #9535: Maintain a reverse dependency map of network content (#9538)
Fixes performance issues with dependency lookup when retrieving
content list from the content server.
2021-09-09 18:06:00 +02:00
Patric Stout f656b0ae96
Fix: use-after-free after ClientNetworkCoordinatorSocketHandler::CloseAllConnections() (#9534)
The function clears all stun-handlers. This causes all of those
objects to be destroyed.
A handler can have a pending connecter, which was only killed in
case CloseConnection() was called. This is never the case when
the object is destroyed. In result, the connecter could finish
and cause a use-after-free by calling into the (now deleted)
handler.
2021-09-05 18:17:39 +02:00
Rubidium 92559e6f3a Fix #9388: thread unsafe use of NetworkAdminConsole/IConsolePrint 2021-09-01 22:40:44 +02:00
Patric Stout 63116bd59f
Fix a2051bad: SendCmdNames only sent one name per packet (#9528) 2021-08-31 21:40:38 +02:00
Patric Stout d8e870c50c
Fix: when DNS didn't resolve any IPs, the debug message was misleading (#9519) 2021-08-28 21:19:53 +02:00
Patric Stout dc5b7b996c
Fix: [Network] show query errors in the server listing instead of error popup (#9506)
When you are query several servers at once, it is rather unclear
for which server you got a popup. Instead, show any errors on the
server itself.

This is only true for the query-part. Joining a server still gives
an error popup to tell you about any issue.
2021-08-23 20:16:22 +02:00
Patric Stout e31b5d3870
Fix #9490: [Network] a full server couldn't be queried either (#9508)
You can now still query a full server, as long as the maximum
amount of allowed connections isn't reached. This means that as
long as there are not 255 clients connected to a server, you can
always connect to query.
2021-08-23 19:38:02 +02:00
Patric Stout b2f0491a90
Fix #9501: [Network] crash when more than one game-info query was pending (#9502) 2021-08-23 19:37:51 +02:00
Patric Stout 47ce306085
Fix c4b700f1: remove left-over debug statement (#9510) 2021-08-23 14:05:37 +02:00
Patric Stout 0d26359b5b
Fix: [Network] don't show GameScript " (v0)" for old servers (#9507)
Old servers don't tell the GameScript they are running, so nothing
should be shown.
All values in NetworkGameInfo initialize as 0/empty, except for GS
version. Someone has to be different from the rest, I guess.
2021-08-23 12:41:20 +02:00
Patric Stout 4066a07d8f
Fix: [Network] crash when last-joined server that is no longer available (#9503)
If you update the server-list while not having last-joined selected
and it is no longer available, the game crashed.
2021-08-21 11:56:29 +02:00
Michael Lutz fff09a4af2 Fix d9c1d18f2: Wrong format string for console disconnect message. 2021-08-19 19:56:00 +02:00
Patric Stout c4b700f1b0
Fix #9492: show for what server a relay session is being created (#9494)
Currently it says "the server" which is a bit ambigious. Be more
specific.
2021-08-18 12:06:14 +02:00
Patric Stout 5da60cef46
Fix: typo in the word "spectator" (tnx Heiki) (#9496) 2021-08-18 12:00:17 +02:00
Patric Stout 5c776f21e7
Fix 6acf204d: crash when showing coordinator-error-messages (#9488) 2021-08-17 19:42:46 +02:00
Patric Stout 6acf204d14
Fix: report reuse of invite-code and switch to local game-type (#9487)
This prevents two servers battling for the same invite-code. Now
the last one wins.
2021-08-17 13:35:29 +02:00
dP 2e6a77a78a
Fix: connecting with the same name thrice hangs the server (#9485) 2021-08-16 11:09:54 +02:00
Patric Stout 579f393374
Add: open Online Players GUI on starting/joining a server (#9479) 2021-08-15 00:17:10 +02:00
Patric Stout 1ef4d3cf19
Remove: COMPANY_INFO packets and related code (#9475) 2021-08-14 23:24:02 +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 db13eebf29
Fix 508e465b: network servers didn't show invite-code / connection-type in Online Players GUI (#9478)
The selector selects the first widget, which by accident was now only
the server visibility.
2021-08-14 21:00:30 +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 4c1ea4020d
Change: remove the ability to control "max spectators" (#9466)
Soon we will make "join game" join the game as spectator first,
so limiting the amount of spectators makes no sense anymore in
that context. Not sure it ever did make sense.
2021-08-10 20:03:13 +02:00
Rubidium ba29edb0b3 Cleanup: remove some references to the old master-server 2021-07-21 22:28:51 +02:00
Patric Stout 9cc706847c
Fix: crash when joining a server again after a TCP disconnect (#9453)
"my_client" wasn't always free'd when a game ended. "my_client"
keeps a reference inside the PT_NCLIENT pool. The rest of the
code assumes that when you are not in a game, it can freely
reset this pool.
In result: several ways to trigger a use-after-free.
2021-07-21 21:55:30 +02:00
Patric Stout fa1e27994d Feature: allow the use of TURN to connect client and server together
TURN is a last resort, used only if all other methods failed.
TURN is a relay approach to connect client and server together, where
openttd.org (by default) is the middleman.

It is very unlikely either the client or server cannot connect to
the STUN server, as they are both already connected to the Game
Coordinator. But in the odd case it does fail, estabilishing the
connection fails without any further possibility to recover.
2021-07-20 19:57:23 +02:00
Patric Stout 8a36134003 Fix: [Network] rework when to close connections and inform Game Coordinator if needed 2021-07-20 19:57:23 +02:00
Rubidium 386ef4dac3 Feature: [Game Coordinator] Send NewGRF names to the client 2021-07-18 19:36:38 +02:00
rubidium42 3eaa470632 Feature: [Network] Optionally send NewGRF names with NewGRFs in GameInfo
Before 8a2da49 the NewGRF names were synchronized using UDP packets, however
those have been removed. With this a new version of the GameInfo packet is
introduced that allows to specify the type of serialisation happens for
NewGRFs. Either only the GRF ID and checksum, or those two plus the name of
the NewGRF.
On this request for local servers will send the NewGRFs names.
The Game Coordinator will get the names on the first registration, and after
that only the GRF ID and checksum.
2021-07-18 19:36:38 +02:00
rubidium42 5dd524139f Fix c921f6d: [Network] Documentation of Game Info packet was not updated 2021-07-18 11:42:25 +02:00
rubidium42 09a7825d1e Remove: the concept of UnknownGRFs
These were filled with "<Unknown>" (before 8a2da49) and later their name would get filled via UDP requests to the server. These UDP packets do not exist anymore, so they will always remain "<Unknown>".
Remove that logic and just use the generic translated error GRF UNKNOWN string instead.
2021-07-18 11:42:25 +02:00
Loïc Guilloux 460991ecf4
Feature: Persistant rotation of numbered auto/netsave after restart (#9397)
It was always starting from 0 on openttd restart.
Now the most recent auto/netsave number will be used as a base to generate the next filename.
2021-07-17 12:48:35 +02:00
Patric Stout 29cceb59a5 Doc: explain in a bit more detail how we implemented STUN 2021-07-16 19:50:29 +02:00
Patric Stout 8adade26ed Feature: allow the use of STUN to connect client and server together
This method doesn't require port-forwarding to be used, and works for
most common NAT routers in home setups. But, for sure it doesn't work
for all setups, and not everyone will be able to use this.
2021-07-16 19:50:29 +02:00
Patric Stout 55eed246b8 Codechange: allow Connect() to bind to a local address 2021-07-16 19:50:29 +02:00
Patric Stout c921f6d817
Add: inform clients what game-script a server is running (#9441)
Co-authored-by: The Dude <thedude@novapolis.net>
2021-07-14 21:23:44 +02:00
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