Commit Graph

2943 Commits

Author SHA1 Message Date
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
Jonathan G Rennison
ad0e085ec7 Fix off by one error in Packet::CanWriteToPacket 2021-06-12 22:47:29 +01:00
Jonathan G Rennison
1002c6d9d2 Fix various compiler warnings
See: #267
2021-06-11 22:54:27 +01:00
Jonathan G Rennison
97d5982cb5 Fix various compiler warnings
See: #267
2021-06-11 00:39:24 +01: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
Rubidium
e227bbaff0 Cleanup: remove the old FIO slot functions
(cherry picked from commit fa6abe1646)
2021-05-30 22:02:14 +01: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
Rubidium
2606f5409a Fix: leaking file descriptors
(cherry picked from commit 495d73a67f)
2021-05-30 07:52:55 +01:00
rubidium42
62e3bfd684 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

(cherry picked from commit 0968d009c8)
2021-05-30 06:45:44 +01: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
8ffb4122df Codechange: just pass the SettingDesc to SetSettingValue and remove distinction between (non)company 2021-05-27 18:49:43 +02:00
rubidium42
72ec81325b Cleanup: remove unneeded temporary variables and casts 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
Jonathan G Rennison
66289bbda4 Log packet size parse failures in NetworkTCPSocketHandler 2021-05-21 01:42:31 +01:00
Jonathan G Rennison
6d58115458 Net: Log sent and received game packets with type and status names 2021-05-21 01:40:00 +01:00
Jonathan G Rennison
7677d2d01a Fix mishandling of PACKET_SERVER_MAP_BEGIN queuing at server
This could result in broken packet framing in the TCP stream
2021-05-21 00:58:24 +01:00
Milek7
7ab6ab7400 Fix: missing <limits> include in network/core/packet.h (#9123)
(cherry picked from commit a341852cd5)
2021-05-19 18:19:59 +01: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
Jonathan G Rennison
f3e0507c54 Network: Include extra info in PACKET_CLIENT_ERROR packets
Log more details in server when PACKET_CLIENT_ERROR received
2021-05-14 20:31:31 +01:00
Jonathan G Rennison
e04218b528 Network: Log received packets at log level net=3 2021-05-14 19:34:15 +01:00
William Davis
879de9781b Change: Use gender-neutral pronouns in console command messages (and comments) (#9203)
(cherry picked from commit 881e1da51d)
2021-05-14 18:15:00 +01: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
Patric Stout
1b75a29d12 Fix: destroying a TCPConnecter that was still resolving made illegal writes
Basically, we should join the resolve thread before we destruct
the object.
2021-05-08 17:26:10 +02:00
Patric Stout
664a8c3e85 Codechange: move connection_string to private for TCPConnecter
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-08 17:26:10 +02:00
William Davis
881e1da51d
Change: Use gender-neutral pronouns in console command messages (and comments) (#9203) 2021-05-08 11:02:30 +01:00
Patric Stout
f187708b3b
Fix f7e390bd: getpeername() doesn't work on closed sockets (#9213) 2021-05-08 11:57:41 +02:00
rubidium42
e2774354b4
Codechange: [Network] Change ChatMessage's message to std::string and simplify some code 2021-05-08 10:19:42 +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
59a817f21f Fix: [Network] Reading beyond the length of the server's ID when hashing 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.

(cherry picked from commit 56aa6d0edd)
2021-05-06 20:52:00 +01:00
rubidium42
f1dfa661a1 Codechange: [Network] Use std::string for NetworkGameInfo 2021-05-06 21:45:36 +02:00
Peter Nelson
a469b4f395 Fix: Recalculate padding and minimum sizes when GUI or Font zoom is changed.
(cherry picked from commit 4791ff2862)
2021-05-06 20:11:55 +01:00
rubidium42
3d91eee919 Codechange: [Network] Move connection string parsing away from C-strings 2021-05-06 20:33:26 +02:00
rubidium42
6c4a65eeb8 Codechange: [Network] Use std::string for NetworkAddress' host name 2021-05-06 20:33:26 +02:00
rubidium42
dcef3209a6 Codechange: [Network] Use new/delete instead of calloc/free for NetworkGameList 2021-05-06 20:33:26 +02:00
Loïc Guilloux
88bc7bd235 Fix: [MinGW] Set minimum OS version to Windows XP (#9135)
(cherry picked from commit 356bbbb90a)
2021-05-06 18:25:28 +01: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
Rubidium
ead30dc725 Cleanup: [Network] Remove variable from NetworkGameInfo that is only used during deserialisation 2021-05-05 21:01:23 +02:00
rubidium42
e7581fd42d Change: [Network] Update server's NetworkServerGameInfo only when needed
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-05 21:01:23 +02:00
rubidium42
72bd62fd70 Codechange: [Network] Use a single NetworkServerGameInfo object at server side and serialize that for the clients 2021-05-05 21:01:23 +02:00
Jonathan G Rennison
a9515456cb Merge branch 'master' into jgrpp
# Conflicts:
#	src/network/core/os_abstraction.h
#	src/network/core/tcp_content.h
#	src/network/core/udp.cpp
#	src/table/currency_settings.ini
#	src/table/settings.h.preamble
2021-05-03 21:59:49 +01:00
rubidium42
7bcc472f73 Add: [Network] Reading std::string from a packet 2021-05-03 17:56:05 +02:00
rubidium42
ba409e8c45 Add: [Network] Writing std::string to a packet 2021-05-03 17:56:05 +02:00
rubidium42
56aa6d0edd Fix: [Network] Reading beyond the length of the server's ID when hashing 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-02 11:51:28 +02:00
rubidium42
e097c83c83 Codechange: move some OS abstraction method implementations out of the header 2021-05-01 19:36:22 +02:00
rubidium42
22720332eb Codechange: encapsulate network error handling 2021-05-01 19:36:22 +02:00
rubidium42
0eb17a70af Codechange: rename NetworkError to ShowNetworkError 2021-05-01 19:36:22 +02:00
rubidium42
05394d5216 Fix #6598: Prevent invalid memory accesses when abandoning a join from 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-01 18:30:08 +02:00
rubidium42
83985fe26f Codechange: Move join information into a single structure 2021-05-01 18:30:08 +02:00
rubidium42
3bd416bfdb Change: [Console] Show help when passing invalid company number 2021-05-01 18:30:08 +02:00
Peter Nelson
4791ff2862 Fix: Recalculate padding and minimum sizes when GUI or Font zoom is changed. 2021-04-30 17:08:15 +01: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
be37a2cab8 Codechange: use NetworkAddress instead of two host/port variables where possible
This also means we no longer need last_host/last_port, but can
just use a single last_joined setting.
2021-04-29 20:12:11 +02:00
Patric Stout
99f998805b Codechange: use std::string over stack-based strings if possible 2021-04-29 20:12:11 +02:00
Patric Stout
a8afbe74bf Cleanup: remove write-only variable "hostname" in NetworkGameList 2021-04-29 20:12:11 +02:00
Loïc Guilloux
356bbbb90a
Fix: [MinGW] Set minimum OS version to Windows XP (#9135) 2021-04-29 14:26:08 +02:00
Patric Stout
96dc0d04ec
Fix b3003dd1: swap SERVER_GAME_INFO with CLIENT_GAME_INFO (#9129)
The idea is that if you query an older server that does not support
this packet yet, the client receives an error. The assumption was
that on every "illegal packet" the connection would be closed. This
turns out to be false.

Now CLIENT_GAME_INFO aligns with the old PACKET_CLIENT_NEWGRFS_CHECKED,
which does a pre-check (which fails), and an error is sent back
and the connection is closed.

This is not a nice solution, but it is the best we got.
2021-04-28 23:09:03 +02:00
Milek7
a341852cd5
Fix: missing <limits> include in network/core/packet.h (#9123) 2021-04-27 23:22:03 +01:00
Patric Stout
31f1db2d3a Change: no longer use UDP when entering the lobby of a server
The lobby of a server requested some parts via UDP and some via
TCP. This is strictly seen fine, but for future extensions it
is a lot easier if just one protocol is used.
2021-04-27 20:18:53 +02:00
Patric Stout
b57d845e55 Codechange: refactor CheckGameCompatibility() from existing function
Later commits use this function in other places too.
2021-04-27 20:18:53 +02:00
Patric Stout
b3003dd163 Add: ability to retrieve game info from server over TCP 2021-04-27 20:18:53 +02:00
Patric Stout
84c75a7b9a Codechange: be explicit in pointer comparisons 2021-04-27 20:18:53 +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
8fa53f543a
Change: [Network] lower TCP connect() timeout to 3s (#9112)
Currently we use default OS timeout for TCP connections, which
is around 30s. 99% of the users will never notice this, but there
are a few cases where this is an issue:

- If you have a broken IPv6 connection, using Content Service is
  first tried over IPv6. Only after 30s it times out and tries
  IPv4. Nobody is waiting for that 30s.
- Upcoming STUN support has several methods of establishing a
  connection between client and server. This requires feedback
  from connect() to know if any method worked (they have to be
  tried one by one). With 30s, this would take a very long time.

What is good to mention, is that there is no good value here. Any
value will have edge-cases where the experience is suboptimal. But
with 3s we support most of the stable connections, and if it fails,
the user can just retry. On the other side of the spectrum, with 30s,
it means the user has no possibility to use the service. So worst case
we annoy a few users with them having the retry vs annoying a few
users which have no means of resolving the situation.
2021-04-27 20:18:43 +02:00
rubidium42
015e3b412e Cleanup: remove #ifdefs for compiling the old content server 2021-04-27 19:58:03 +02:00
rubidium42
84985c1223 Codechange: [Network] Do not leak os_abstraction.h via fios.h 2021-04-27 18:17:34 +01:00
rubidium42
cbad518bf3 Codechange: [Network] Do not leak os_abstraction.h via network_func 2021-04-27 18:17:34 +01:00
rubidium42
cf8c1aa860 Change: [Network] Use string error messages instead of numeric error numbers that need to be looked up 2021-04-27 18:17:34 +01:00
rubidium42
65c5a64719 Fix: [Network] errno and strerror do not handle network errors on Windows 2021-04-27 18:17:34 +01:00
Charles Pigott
43b6f6915b Fix 8a95fee4: Missing initialiser in Packet constructor 2021-04-26 06:45:37 +02:00
Jonathan G Rennison
8eb27e1ac7 Merge branch 'master' into jgrpp
# Conflicts:
#	src/company_cmd.cpp
#	src/lang/japanese.txt
#	src/network/core/config.h
#	src/network/core/packet.cpp
#	src/network/core/tcp.cpp
#	src/network/network_content.cpp
#	src/network/network_server.cpp
#	src/network/network_udp.cpp
#	src/toolbar_gui.cpp
#	src/vehicle_gui_base.h
2021-04-25 22:14:59 +01:00
Jonathan G Rennison
66fda55ec4 Merge branch 'master' into jgrpp
# Conflicts:
#	src/company_cmd.cpp
#	src/network/core/packet.cpp
#	src/network/core/packet.h
#	src/network/core/tcp.cpp
#	src/network/core/udp.cpp
#	src/network/network_server.cpp
#	src/network/network_server.h
#	src/toolbar_gui.cpp
#	src/vehicle_gui_base.h
2021-04-25 20:56:16 +01:00
rubidium42
5afb090082 Change: [Network] Remove now defunct savegame transfer packet limiter 2021-04-25 21:29:23 +02:00
Rubidium
a3c9eca722 Change: use 32 KiB packets to send requests to the content server 2021-04-25 21:27:54 +02:00
Rubidium
21f58ab437 Change: use 32 KiB packets to transfer the savegame 2021-04-25 21:27:54 +02:00
Rubidium
d6000c2ec5 Codechange: differentiate between UDP, TCP and compatibility MTU values 2021-04-25 21:27:54 +02:00
Rubidium
8b302761d4 Codechange: allow different limits in packet sizes 2021-04-25 21:27:54 +02:00
rubidium42
65818db1f4 Fix: [Network] Prevent stalling save game transfer when compression is slow 2021-04-25 19:54:21 +02:00
Jonathan G Rennison
253772e9af Merge branch 'master' into jgrpp
# Conflicts:
#	CMakeLists.txt
#	COMPILING.md
#	src/console.cpp
#	src/console_cmds.cpp
#	src/console_internal.h
#	src/rev.cpp.in
2021-04-25 02:14:58 +01:00
Jonathan G Rennison
ba418f9d0d Merge branch 'master' into jgrpp
# Conflicts:
#	src/lang/simplified_chinese.txt
#	src/network/core/tcp_content.cpp
#	src/network/core/udp.cpp
#	src/network/network_server.cpp
#	src/saveload/linkgraph_sl.cpp
#	src/table/gameopt_settings.ini
2021-04-25 01:23:52 +01:00
Jonathan G Rennison
1e4161ff56 Merge branch 'master' into jgrpp
# Conflicts:
#	src/group_gui.cpp
2021-04-25 00:30:03 +01:00
Patric Stout
fda1a590f6 Change: use icons to indicate you/host in Online Players GUI 2021-04-24 21:43:58 +02:00
Patric Stout
a924b2ff81 Add: move "New Company" inside the Online Players GUI 2021-04-24 21:43:58 +02:00
Patric Stout
c2e116a3d3 Change: track hover position on Online Players GUI
Especially if there are many players online, trying to chat with
the right one can be a visual challenge. This can be solved by
highlighting the row you are on. This visual cue is often enough
for humans to find the right row.
2021-04-24 21:43:58 +02:00
Patric Stout
54f69deb0c Add: ask for confirmation on admin actions in network games 2021-04-24 21:43:58 +02:00
Patric Stout
ff708c2c65 Add: admin menu for companies in multiplayer games
You can now easily do:
- a password reset (unlock)
- remove an empty company (reset company)
2021-04-24 21:43:58 +02:00
Patric Stout
5266359424 Feature: rework in-game Online Players GUI
The GUI now more clearly shows some basic information about the
server you joined, your client name (and the ability to change it),
and what players are in which company.

It also contains useful buttons to press to join companies, chat
with other people, and for admins to kick/ban people.

Additionally, renamed "advertised" to "visibility"; this has to
do with future additions, but also because it is more clear in
wording.
2021-04-24 21:43:58 +02:00
Rubidium
75386873b7 Codechange: use std::vector instead of a fixed size array for Packets 2021-04-24 20:42:01 +02:00
Rubidium
450178d780 Codechange: add accessor for the packet type to Packet and make the internal state of Packet private 2021-04-24 20:42:01 +02:00
Rubidium
3abefdf561 Codechange: remove public access to the next pointer in Packet 2021-04-24 20:42:01 +02:00
Rubidium
f71fb0f54a Codechange: encapsulate reading the size of a Packet 2021-04-24 20:42:01 +02:00
Rubidium
6f161f6559 Codechange: encapsulate the logic about how many bytes can be sent from a buffer in to a Packet 2021-04-24 20:42:01 +02:00
Rubidium
38d15fc9b7 Codechange: move the logic shrinking of the packets into the Packet itself 2021-04-24 20:42:01 +02:00
Rubidium
d4f027c03b Codechange: encapsulate writing data from Packets into sockets/files/buffers to prevent packet state modifications outside of the Packet 2021-04-24 20:42:01 +02:00
Rubidium
98aa561cf7 Codechange: encapsulate reading data from sockets into Packets to prevent packet state modifications outside of the Packet 2021-04-24 20:42:01 +02:00
Rubidium
a2051bad50 Codechange: move logic whether there is enough space in a packet to write data into the Packet 2021-04-24 20:42:01 +02:00
Rubidium
c545cc9d70 Codechange: move more logic about packet size validity and reading into Packet 2021-04-24 20:42:01 +02:00
rubidium42
2999d301ad Add: [Network] Validate the client name when receiving one from the server
This so names from other clients are known valid in the client as well, instead allowing some compromised/bad server to potentially crash clients upon certain expectations.
2021-04-24 08:02:54 +02:00
rubidium42
e1cebe0ea0 Add: [Network] Validate the client name server side, so no clients with invalid names can actually join 2021-04-24 08:02:54 +02:00
rubidium42
2e0f3799a8 Change: [Network] Prevent invalid client names being sent to the server when changing it using the console/settings 2021-04-24 08:02:54 +02:00
rubidium42
bfb0ab3e2f Feature: [Network] Ensure players fill in a name instead of defaulting to "Player" 2021-04-24 08:02:54 +02:00
rubidium42
b14f412117 Codechange: [Network] Introduce function to validate the client name 2021-04-24 08:02:54 +02:00
Jonathan G Rennison
0d262e4d9a Send network client desync log messages to server 2021-04-24 01:15:05 +01:00
Peter Nelson
9aa64b7885 Codechange: Use new widget features on chat message box. 2021-04-22 16:42:04 +01:00
Rubidium
bf4fe19a66 Codechange: merge duplicated logic to scroll in lists by key into a single function 2021-04-21 21:12:08 +02:00
Patric Stout
ce6a744278 Doc: server name doesn't need to be advertised to be valid
Strictly seen the comment is true, as it says 'e.g.', but it is
misleading. The server name is just that: the name of the server
as configured. No need to mention advertising.
2021-04-20 17:34:04 +02:00
Patric Stout
cd757d53ca Codechange: remove always-empty "address" from NetworkContentSocketHandler
When ever you saw this debug lines (which you never should), they
showed an empty address. It is also not very useful to have, as it
always points to a known server anyway.
2021-04-20 17:34:04 +02:00
Patric Stout
31897eaa7d Codechange: split ParseConnectionString into two functions
One also looks for a company, the other doesn't. There were more
uses of the latter than the first, leaving very weird code all
over the place.
2021-04-20 17:34:04 +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
Patric Stout
f4bd3fff5e Remove: "map_name" from server announcements / listing
The idea back in the days was nice, but it never resulted in
anything useful. Most servers either read "(loaded game)" or
"Random Map", neither being useful. It was meant for heightmaps,
so you could find a server that was using a specific one .. but
there are many things wrong with that idea. Mostly, servers tend
to save and load savegames from time to time, after which the
original heightmap used was lost.

All in all, removing map_name all together is just better.
2021-04-20 17:24:38 +02:00
Jonathan G Rennison
8d8076040a Avoid std::scoped_lock for MacOS 10.12 compatibility 2021-04-18 20:33:17 +01:00
Peter Nelson
3248a6c12b Fix #9042: Make multiplayer server list height auto-fill window.
#9042 did not fix all combinations of scaling options. This additional
change makes the server list automatically fill available height.
2021-04-17 22:23:43 +02:00
Peter Nelson
cb9f56df0c Feature: Show previous chat history when the chat message box is open 2021-04-16 20:25:46 +02:00
Peter Nelson
fbef63822c Codechange: Use std::deque for chat history instead of fixed array 2021-04-16 20:25:46 +02:00
Peter Nelson
837994034d Fix: Sizing of Multiplayer server list incorrect when GUI zoom doesn't match Font zoom.
The server information panel was scaled by GUI scale, which could result in a panel that is longer than the server list. This height difference is then maintained when the window is resized to fill the screen.
Instead, specify the minimum size by number of text lines and (summed total) padding.
2021-04-16 20:24:08 +02:00
Jonathan G Rennison
253d54ce05 Merge branch 'master' into jgrpp
# Conflicts:
#	src/lang/french.txt
#	src/network/network_udp.cpp
2021-04-12 22:59:30 +01:00
Rubidium
d2fe8c2842 Change: warn the user about the resolving of an address being extra very slow 2021-04-12 21:10:21 +02:00
Rubidium
7597740bff Fix: split the UDP blocking of sockets to only the socket involved, and when another thread is busy do not attempt to process the packets of that socket 2021-04-12 21:10:21 +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
Jonathan G Rennison
227041008f Merge branch 'master' into jgrpp
# Conflicts:
#	src/debug.cpp
#	src/lang/russian.txt
#	src/misc_gui.cpp
#	src/os/windows/crashlog_win.cpp
#	src/os/windows/font_win32.cpp
#	src/os/windows/win32.cpp
#	src/rail_cmd.cpp
#	src/window_gui.h
2021-04-11 03:05:08 +01:00
Niels Martin Hansen
e0561dbded Fix #8713: Change OTTD2FS and FS2OTTD to return string objects instead of static buffers 2021-04-07 09:31:47 +02:00
Jonathan G Rennison
825867f2c5
Fix: [Network] State conditions for sending client info/quit packets (#8959)
Use status >= STATUS_AUTHORIZED as the state criteria for all cases
where updates about other clients are sent.
This avoids the case where a client is informed that another client
has joined but not informed when it later quits, resulting in
stale entries in the client list window.
2021-04-06 19:31:52 +01:00
Jonathan G Rennison
d452517c66 Fix data race warning in NetworkGameListHandleDelayedInsert
Avoid thread-sanitizer warning on ins_item->next
2021-04-06 18:43:50 +01:00
Jonathan G Rennison
76624e6f58 Server: Fix client state conditions for sending client info/quit packets 2021-04-06 02:21:32 +01:00
Jonathan G Rennison
5e14b54a0c Merge branch 'master' into jgrpp 2021-04-05 17:51:45 +01:00
Jonathan G Rennison
425b725eab Include last sync frame in desync crash log 2021-04-01 01:59:48 +01:00
Jonathan G Rennison
4361a6dbf4 Avoid undefined behaviour const_casting std::string c_str()
Use non-const data() instead

See: #224
2021-03-11 01:33:06 +00:00
Patric Stout
970fedd78c Add: make modal windows update more smooth
Basically, modal windows had their own thread-locking for what
drawing was possible. This is a bit nonsense now we have a
game-thread. And it makes much more sense to do things like
NewGRFScan and GenerateWorld in the game-thread, and not in a
thread next to the game-thread.

This commit changes that: it removes the threads for NewGRFScan
and GenerateWorld, and just runs the code in the game-thread.
On regular intervals it allows the draw-thread to do a tick,
which gives a much smoother look and feel.

It does slow down NewGRFScan and GenerateWorld ever so slightly
as it spends more time on drawing. But the slowdown is not
measureable on my machines (with 700+ NewGRFs / 4kx4k map and
a Debug build).

Running without a game-thread means NewGRFScan and GenerateWorld
are now blocking.
2021-03-10 13:41:18 +01:00
Jonathan G Rennison
5a364d3e8c Merge branch 'master' into jgrpp
# Conflicts:
#	src/blitter/32bpp_optimized.cpp
#	src/lang/serbian.txt
2021-03-04 00:17:10 +00:00
Patric Stout
0243ae4654
Fix #8799: NGameAllowedSorter() is not imposing strict weak ordering relation (#8801)
In other words, it should only (!) return true if A comes for B.
This promise was broken for the situation where two values are
identical. It would return true in these cases too. This is of
course not possible: if two values are identical, neither come
before the other. As such, the sorter was not imposing strict
weak ordering relations.

libstdc++ handled this scenario just fine, but libc++ crashes
badly on this, as it allowed comparing of [begin, end] instead
of [begin, end).
libc++ considered this not a bug (and by specs, they are correct;
just this way of crashing is of course a bit harsh):
https://bugs.llvm.org/show_bug.cgi?id=47903
2021-03-03 12:12:29 +00:00
Jonathan G Rennison
f4e29071be Merge tag '1.11.0-beta2' into jgrpp
# Conflicts:
#	.github/workflows/ci-build.yml
#	.github/workflows/release.yml
#	CMakeLists.txt
#	src/blitter/32bpp_optimized.cpp
#	src/debug.cpp
#	src/gfx.cpp
#	src/gfx_func.h
#	src/lang/czech.txt
#	src/lang/english.txt
#	src/lang/italian.txt
#	src/lang/swedish.txt
#	src/lang/ukrainian.txt
#	src/network/network_server.cpp
#	src/os/windows/crashlog_win.cpp
#	src/os/windows/win32.cpp
#	src/pathfinder/follow_track.hpp
#	src/screenshot.cpp
#	src/settings_type.h
#	src/spritecache.cpp
#	src/vehicle_gui.cpp
#	src/video/sdl2_v.cpp
#	src/video/video_driver.cpp
#	src/video/video_driver.hpp
#	src/video/win32_v.cpp
2021-03-02 11:59:03 +00:00
Jonathan G Rennison
edeced8fce Zstd: Enable zstd for autosaves
See also: https://github.com/OpenTTD/OpenTTD/pull/8773
2021-03-01 18:59:03 +00:00
Jonathan G Rennison
c2ae7580e0 Zstd: Use zstd for network joins if supported at both ends
See also: https://github.com/OpenTTD/OpenTTD/pull/8773
2021-03-01 18:59:03 +00:00
Patric Stout
d4f208d9c1 Codechange: [Network] replace _realtime_tick with std::chrono
(cherry picked from commit 53c28a8ec9)
2021-03-01 17:54:15 +00:00
Patric Stout
c13c201f72 Fix: [Network] don't show "server doesn't respond" while in queue
Send all clients in the queue every game-day a packet that they
are still in the queue.

(cherry picked from commit 13889b6554)

# Conflicts:
#	src/network/network_server.cpp
2021-03-01 17:54:15 +00:00
Patric Stout
7da90af2f4 Fix: [Network] send map to next client if current client disconnects
Also terminate creating of the savegame, as the client is gone,
there really is no need for that anymore.

(cherry picked from commit 8d199b1bbc)
2021-03-01 17:49:03 +00:00
Patric Stout
cfa1612766 Fix: [Network] also count the person downloading the map in the queue
Strictly seen, there are "N" people -waiting- in front of you
in the queue, but it is nicer to show "N + 1" for the person that
is currently downloading the map. Avoids it showing:
"0 clients in front of you". That just feels a bit off.

(cherry picked from commit 3677418225)
2021-03-01 17:49:03 +00:00
dP
73fd634209 Fix #6266: Ugly lists in network lobby windows on double/quad interface sizes with custom fonts 2021-02-28 17:43:30 +00:00
Patric Stout
13889b6554 Fix: [Network] don't show "server doesn't respond" while in queue
Send all clients in the queue every game-day a packet that they
are still in the queue.
2021-02-28 12:27:04 +01:00
Patric Stout
8d199b1bbc Fix: [Network] send map to next client if current client disconnects
Also terminate creating of the savegame, as the client is gone,
there really is no need for that anymore.
2021-02-28 12:27:04 +01:00
Patric Stout
3677418225 Fix: [Network] also count the person downloading the map in the queue
Strictly seen, there are "N" people -waiting- in front of you
in the queue, but it is nicer to show "N + 1" for the person that
is currently downloading the map. Avoids it showing:
"0 clients in front of you". That just feels a bit off.
2021-02-28 12:27:04 +01:00
Pavel Stupnikov
4fd2eecb8b
Change: Improve console warnings on invalid network commands (#8753) 2021-02-27 20:26:51 +01:00
Patric Stout
53c28a8ec9 Codechange: [Network] replace _realtime_tick with std::chrono 2021-02-27 00:36:14 +01:00
Patric Stout
d068d61f3c
Fix bddfcaef: don't tell twice that a client left because of a timeout etc (#8746)
SendError() notifies all clients of the disconnect. This calls
CloseConnection() at the end, which also notified the clients
of the disconnect. Really no need to do it twice.

The status NETWORK_RECV_STATUS_SERVER_ERROR is only set by
SendError(), so in case that is the status, don't let
ClientConnection() send another notification.
2021-02-27 00:32:51 +01:00
Jonathan G Rennison
dfecdf3afb Merge branch 'master' into jgrpp
# Conflicts:
#	src/dock_gui.cpp
#	src/rail_gui.cpp
#	src/road_gui.cpp
#	src/terraform_gui.cpp
#	src/vehicle.cpp
#	src/video/allegro_v.cpp
#	src/video/cocoa/cocoa_v.mm
#	src/video/dedicated_v.cpp
#	src/video/sdl2_v.cpp
#	src/video/sdl_v.cpp
#	src/video/win32_v.cpp
2021-02-21 11:54:24 +00:00
frosch
d9b4413bc9
Codechange: rename sound ids to make more sense. (#8701) 2021-02-20 19:01:04 +01:00
Jonathan G Rennison
e95216b59d Merge branch 'master' into jgrpp
# Conflicts:
#	src/company_cmd.cpp
#	src/core/geometry_func.cpp
#	src/date.cpp
#	src/genworld_gui.cpp
#	src/gfx.cpp
#	src/object_gui.cpp
#	src/openttd.cpp
#	src/settings_type.h
#	src/video/allegro_v.cpp
#	src/video/dedicated_v.cpp
#	src/video/null_v.cpp
#	src/video/sdl2_v.cpp
#	src/video/sdl_v.cpp
#	src/video/win32_v.cpp
2021-02-19 15:38:34 +00:00
Patric Stout
ac2b5e57cf
Fix: mention our websites with https:// (instead of http://) (#8657)
It is 2021. Nobody should advertise http anymore. Not even us.
2021-02-08 19:07:34 +01:00
SamuXarick
a4035af337
Codechange: Apply coding style (#8640)
* Fix: Missing or needed spaces

* Codechange: Remove space

* Codechange: Remove space

* Codechange: More missing spaces

* Codechange: Missing spaces

* Codechange: Remove space

* Codechange: Remove space
2021-02-05 11:00:36 +01:00
Jonathan G Rennison
650d5e014e Merge branch 'master' into jgrpp
# Conflicts:
#	src/ai/ai_gui.cpp
#	src/company_cmd.cpp
#	src/lang/estonian.txt
#	src/lang/german.txt
#	src/lang/hungarian.txt
#	src/lang/korean.txt
#	src/lang/slovak.txt
#	src/main_gui.cpp
#	src/video/sdl2_v.cpp
2021-02-01 19:34:30 +00:00
Jonathan G Rennison
b7ddd486cf Merge branch 'master' into jgrpp
# Conflicts:
#	cmake/CompileFlags.cmake
#	src/aircraft_cmd.cpp
#	src/blitter/32bpp_anim.cpp
#	src/cargopacket.cpp
#	src/cheat_gui.cpp
#	src/company_cmd.cpp
#	src/company_gui.cpp
#	src/core/pool_func.hpp
#	src/date.cpp
#	src/economy.cpp
#	src/error_gui.cpp
#	src/ground_vehicle.cpp
#	src/ground_vehicle.hpp
#	src/group_gui.cpp
#	src/industry_cmd.cpp
#	src/lang/dutch.txt
#	src/lang/french.txt
#	src/lang/german.txt
#	src/linkgraph/linkgraph_gui.cpp
#	src/linkgraph/mcf.cpp
#	src/network/network_content.cpp
#	src/network/network_server.cpp
#	src/network/network_udp.cpp
#	src/newgrf_engine.cpp
#	src/newgrf_station.cpp
#	src/order_cmd.cpp
#	src/order_gui.cpp
#	src/pathfinder/follow_track.hpp
#	src/pathfinder/yapf/yapf_common.hpp
#	src/saveload/saveload.cpp
#	src/settings_gui.cpp
#	src/station_cmd.cpp
#	src/station_kdtree.h
#	src/string_func.h
#	src/table/settings.ini
#	src/tgp.cpp
#	src/timetable_cmd.cpp
#	src/timetable_gui.cpp
#	src/toolbar_gui.cpp
#	src/town_cmd.cpp
#	src/train_cmd.cpp
#	src/train_gui.cpp
#	src/tree_gui.cpp
#	src/tunnelbridge_cmd.cpp
#	src/vehicle.cpp
#	src/vehicle_gui.cpp
#	src/video/sdl2_v.cpp
#	src/video/sdl_v.cpp
#	src/video/win32_v.cpp
#	src/viewport.cpp
#	src/viewport_sprite_sorter_sse4.cpp
#	src/window.cpp
2021-02-01 17:07:34 +00:00
Patric Stout
7fbf705c41
Fix 2db88953: default Network Server List sorter put compatible servers in wrong order (#8626)
If a server is compatible, it falls back to sorting by clients.
This used to be in reverse, so full servers are on top. With
the codechange commit, this was removed by accident, and as
such empty servers were on top. This is silly.
2021-01-31 10:36:07 +01:00
Jonathan G Rennison
082d9021d0 Only use more specific texts for money sending where available 2021-01-31 01:46:29 +00:00
Jonathan G Rennison
f9956d88c3 Merge branch 'master' into jgrpp
# Conflicts:
#	src/aircraft_cmd.cpp
#	src/company_gui.cpp
#	src/lang/arabic_egypt.txt
#	src/lang/czech.txt
#	src/lang/esperanto.txt
#	src/lang/faroese.txt
#	src/lang/finnish.txt
#	src/lang/german.txt
#	src/lang/korean.txt
#	src/lang/latvian.txt
#	src/lang/malay.txt
#	src/lang/polish.txt
#	src/lang/spanish.txt
#	src/lang/spanish_MX.txt
#	src/lang/unfinished/urdu.txt
#	src/main_gui.cpp
#	src/rail_cmd.cpp
#	src/rail_gui.cpp
#	src/road_cmd.cpp
#	src/settings_type.h
#	src/station_cmd.cpp
#	src/table/settings.ini
2021-01-31 01:11:12 +00:00
Jonathan G Rennison
6c3e5642f8 Merge branch 'master' into jgrpp
# Conflicts:
#	cmake/CompileFlags.cmake
#	src/crashlog.cpp
#	src/fileio.cpp
#	src/fileio_func.h
#	src/fios_gui.cpp
#	src/ini_load.cpp
#	src/ini_type.h
#	src/lang/english.txt
#	src/lang/german.txt
#	src/lang/korean.txt
#	src/network/network_client.cpp
#	src/order_base.h
#	src/order_cmd.cpp
#	src/os/windows/win32.cpp
#	src/road_cmd.cpp
#	src/saveload/saveload.cpp
#	src/saveload/saveload.h
#	src/settings.cpp
#	src/station_cmd.cpp
#	src/stdafx.h
#	src/table/settings.ini
#	src/tree_cmd.cpp
#	src/tree_gui.cpp
#	src/vehicle_base.h
#	src/video/cocoa/cocoa_v.mm
#	src/video/cocoa/event.mm
#	src/video/cocoa/wnd_quartz.mm
#	src/viewport.cpp
#	src/widgets/tree_widget.h
2021-01-31 01:08:35 +00:00
Jonathan G Rennison
39df1c49a1 Merge branch 'master' into jgrpp
# Conflicts:
#	src/fileio.cpp
#	src/group_gui.cpp
#	src/industry.h
#	src/lang/korean.txt
#	src/linkgraph/linkgraphjob.cpp
#	src/linkgraph/linkgraphjob.h
#	src/linkgraph/linkgraphschedule.cpp
#	src/linkgraph/linkgraphschedule.h
#	src/openttd.cpp
#	src/saveload/saveload.cpp
#	src/saveload/saveload.h
#	src/town_cmd.cpp
#	src/vehicle_gui.cpp
#	src/vehicle_gui_base.h
2021-01-30 18:27:35 +00:00
Jonathan G Rennison
cb69611248 Merge branch 'master' into jgrpp
# Conflicts:
#	.github/changelog.sh
#	cmake/PackageDeb.cmake
#	src/network/network_client.cpp
#	src/settings_gui.cpp
2021-01-29 18:27:36 +00:00
Jonathan G Rennison
43980639de Merge branch 'master' into jgrpp
# Conflicts:
#	.gitignore
#	CMakeLists.txt
#	src/3rdparty/optional/optional.hpp
#	src/group_cmd.cpp
#	src/industry_cmd.cpp
#	src/misc_gui.cpp
#	src/video/sdl2_v.cpp
2021-01-29 17:45:15 +00:00
glx22
6b8ad5a9b1 Change: Apply some consistency to singleplayer related comments 2021-01-22 22:19:55 +01:00
frosch
31d1968004
Fix: Start the inactivity-timeout for the content server only after the connection has been established. (#8530)
When connecting took long due to the first N resolve-addresses timing out, OpenTTD would immediately close the connection, without sending anything.
2021-01-08 20:20:54 +01:00
Charles Pigott
9b800a96ed
Codechange: Remove min/max functions in favour of STL variants (#8502) 2021-01-08 11:16:18 +01:00
Patric Stout
62cdadb582 Change: move "give money" from client-list to company window
This is a much better location for this button, as you send
money from one company to another company, not from player
to player.

This is based on work done by JGRPP in:
f820543391
and surrounding commits, which took the work from estys:
https://www.tt-forums.net/viewtopic.php?p=1183311#p1183311

We did modify it to fix several bugs and clean up the code while
here anyway.

The callback was removed, as it meant a modified client could
prevent anyone from seeing money was transfered. The message
is now generated in the command itself, making that impossible.
2021-01-05 21:56:24 +01:00
Patric Stout
c288eba813
Fix: prevent clients making emergency saves twice if server disconnects (#8477)
This was clearly overlooked during the initial implementation.
2021-01-02 20:34:55 +01:00
Charles Pigott
e0161cf8da Fix b408fe7: Don't try to construct a std::string from nullptr 2020-12-27 18:30:53 +00:00
Michael Lutz
5cbb2da794 Codechange: Even more std::string usage in file IO. 2020-12-27 13:19:25 +01:00
Michael Lutz
65f65ad2ad Codechange: Convert some more FIO functions to take std::string. 2020-12-27 13:19:25 +01:00
Michael Lutz
f3326d34e7 Codechange: Use std::string in FIO search path handling. 2020-12-27 13:19:25 +01:00
Charles Pigott
860c270c73 Codechange: Replace assert_compile macro with static_assert 2020-12-27 10:55:42 +00:00
frosch
ba49fa3b82 Codechange: Rename strings to match their usage. 2020-12-25 00:40:35 +01:00
frosch
2bb691f50e Change: Remove the LAN/Internet combobox from the server list in favour of adding two separate search buttons. 2020-12-25 00:40:35 +01:00
Jonathan G Rennison
0c5dc5d41e Change: [Linkgraph] Pause the game when linkgraph jobs lag (#6470)
Check if the job is still running two date fract ticks before it is due
to join, and if so pause the game until its done.
When loading a game, check if the game would block immediately due to
a job which is scheduled to be joined within two date fract ticks,
and if so pause the game until its done.
This avoids the main thread being blocked on a thread join, which appears
to the user as if the game is unresponsive, as the UI does not repaint
and cannot be interacted with.
Show if pause is due to link graph job in status bar, update network
messages.
This does not apply for network clients.
2020-12-22 15:17:57 +01:00
Pavel Stupnikov
d989fb516b
Change: send network error to the server before making an emergency save (#8387) 2020-12-16 21:23:12 +01:00
Byoungchan Lee
0471de2d92
Fix: Remove unnessary reference to suppress warning (#8337)
Apple Clang version 12 (bundled with Xcode 12) complaints about copying
small objects in range loop (-Wrange-loop-analysis introduced by -Wall).
This warning can be easily avoided by removing the reference from
the const pointer type.
2020-12-15 22:39:51 +01:00
Patric Stout
8fbf5bef60 Fix: workarounds for two emscripten bugs in the network stack 2020-12-15 15:46:39 +01:00
Patric Stout
d15dc9f40f Add: support for emscripten (play-OpenTTD-in-the-browser)
Emscripten compiles to WASM, which can be loaded via
HTML / JavaScript. This allows you to play OpenTTD inside a
browser.

Co-authored-by: milek7 <me@milek7.pl>
2020-12-15 15:46:39 +01:00
Jonathan G Rennison
1f54c8a018 Send vehicle caches to network clients to prevent desyncs due to bad GRFs 2020-11-22 11:41:50 +00:00
Jonathan G Rennison
bbbda0739b Add third DoCommand parameter p3 2020-10-17 17:25:44 +01:00
Jonathan G Rennison
cce6d731a1 TBTR: Delete orphaned virtual trains on client disconnection 2020-10-09 19:26:07 +01:00
Jonathan G Rennison
2cad094725 Allow sending an empty password to drop settings_access 2020-09-29 18:21:06 +01:00
Jonathan G Rennison
4763f441f6 On load, use previous local company or first usable company
Instead of always using the first company slot
2020-09-20 17:36:36 +01:00
Jonathan G Rennison
11a9a4dc0c Fix no error message when attaching new template/virtual vehicle fails
See: #187
2020-09-08 23:56:38 +01:00
Jonathan G Rennison
dea2be5d3f Increase size of ContentInfo::name field 2020-08-31 19:02:33 +01:00
Jonathan G Rennison
7467051331 Merge branch 'master' into jgrpp
# Conflicts:
#	.gitignore
#	src/network/network_server.cpp
#	src/vehicle_gui.cpp
2020-07-12 12:29:28 +01:00
Jonathan G Rennison
053d4f3bff Fix: Thread unsafe use of SendPacket for PACKET_SERVER_MAP_SIZE
NetworkTCPSocketHandler::SendPacket is not thread safe and may not
be used concurrently from multiple threads without suitable locking
2020-07-09 16:08:01 +01:00
Jonathan G Rennison
53f9fa139d Remove redundant year/month date globals 2020-07-07 17:53:54 +01:00
Jonathan G Rennison
3adeff1883 Merge branch 'master' into jgrpp
# Conflicts:
#	CMakeLists.txt
#	cmake/CompileFlags.cmake
#	src/bridge_gui.cpp
#	src/saveload/afterload.cpp
#	src/saveload/saveload.cpp
#	src/saveload/saveload.h
#	src/saveload/town_sl.cpp
#	src/screenshot.cpp
#	src/screenshot.h
#	src/toolbar_gui.cpp
#	src/town.h
#	src/town_cmd.cpp
2020-06-30 21:43:04 +01:00
TechGeekNZ
cf8ea74733 Update: Merge branch 'jgrpp_master_cmake' into jgrpp_cmake 2020-06-28 21:56:43 +01:00
duck
1bc7047af7
Doc: Acknowledge integer type mismatch in certain admin packets using AdminUpdateType (#8238) 2020-06-27 18:21:17 +02:00
Charles Pigott
224acb78b0 Fix: Compiler warnings about memsetting non-trivial classes 2020-06-27 14:51:14 +01:00
Jonathan G Rennison
1ac0d4a5b2 Fix: Thread unsafe use of NetworkAddress::GetAddressAsString
Remove static buffer form of NetworkAddress::GetAddressAsString.
This is used in multiple threads concurrently, and is not thread-safe.

Replace it with a form returning std::string.
2020-06-21 11:47:56 +01:00
Jonathan G Rennison
b0f192abc4 Fix: Racy use of flags in TCPConnecter::CheckCallbacks
conected and aborted flags are used concurrently from multiple threads.
2020-06-18 19:57:34 +02:00
Jonathan G Rennison
d160536315 Fix has_packets in ServerNetworkGameSocketHandler::SendMap 2020-06-18 17:06:07 +01:00
Jonathan G Rennison
663886843c Win32: Wine: Oversize buffer for WSAIoctl/SIO_GET_INTERFACE_LIST
This is a workaround for https://bugs.winehq.org/show_bug.cgi?id=49371

See also: 1e7a73b2
2020-06-12 17:15:03 +01:00
Patric Stout
56d54cf60e Add: introduce CMake for project management
CMake works on all our supported platforms, like MSVC, Mingw, GCC,
Clang, and many more. It allows for a single way of doing things,
so no longer we need shell scripts and vbs scripts to work on all
our supported platforms.

Additionally, CMake allows to generate project files for like MSVC,
KDevelop, etc.

This heavily reduces the lines of code we need to support multiple
platforms from a project perspective.

Addtiionally, this heavily improves our detection of libraries, etc.
2020-06-05 19:36:05 +02:00
Jonathan G Rennison
677940cfc6 Merge branch 'master' into jgrpp 2020-06-01 20:39:46 +01:00
Yexo
a9b3312d1a Fix #8024: make online content gui more responsive while loading
Previously the internal content list was invalidated and sorted for
every new item added. Now the sorting is delayed until the GUI is
drawn, which means we only sort once per GUI tick.

Since the amount of incoming items per GUI tick is not controlled by
the GUI but rather by network speed, we were previously doing a lot
of duplicate work per tick, causing the mouse cursor to lag while
the list was initialized.
2020-06-01 10:59:11 +02:00
Jonathan G Rennison
f8d6e781ba Merge branch 'master' into jgrpp
# Conflicts:
#	projects/openttd_vs140.vcxproj.filters
#	projects/openttd_vs141.vcxproj.filters
#	projects/openttd_vs142.vcxproj.filters
#	src/base_consist.h
#	src/company_base.h
#	src/newgrf_config.cpp
#	src/newgrf_config.h
#	src/openttd.cpp
#	src/saveload/saveload.cpp
#	src/saveload/saveload.h
#	src/saveload/station_sl.cpp
#	src/settings.cpp
#	src/signs_base.h
#	src/string.cpp
#	src/string_func.h
#	src/table/misc_settings.ini
#	src/table/settings.h.preamble
#	src/town_cmd.cpp
#	src/vehicle.cpp
#	src/vehicle_cmd.cpp
#	src/video/cocoa/cocoa_v.mm
#	src/video/null_v.cpp
2020-05-21 22:24:01 +01:00
Michael Lutz
43cd892e0c Codechange: Replace custom linked list for GRF texts with STL vectors and strings. 2020-05-21 20:02:34 +02:00
Jonathan G Rennison
58c02030c2 Network: Avoid racy use of flags in TCPConnecter::CheckCallbacks 2020-05-07 20:53:50 +01:00
Jonathan G Rennison
ef7e658dee Network: Remove static buffer form of NetworkAddress::GetAddressAsString
This is used in multiple threads concurrently
2020-05-07 20:53:50 +01:00
Jonathan G Rennison
a1d85b812b Network: Use unique_ptr for packets, use deque for packet queues 2020-05-07 20:53:50 +01:00
Jonathan G Rennison
caa27cfa39 Network: Fix locking issues around server map PacketWriter 2020-05-07 20:53:50 +01:00
glx22
82573a5e73
Fix #8117: Memory leak in admin port (#8122) 2020-05-07 02:00:53 +02:00
Jonathan G Rennison
b209b37db9 Add new CommandFlags value: CMD_SERVER_NS 2020-04-14 22:03:04 +01:00
Jonathan G Rennison
86b6e9727f Cheats: Enable setting magic bulldozer, tunnels and jet crashes in multiplayer 2020-04-14 20:41:37 +01:00
Jonathan G Rennison
1e7a73b2c7 Win32: Check for buffer overrun when calling WSAIoctl/SIO_GET_INTERFACE_LIST
This has been observed on Wine
2020-04-11 01:18:03 +01:00
Jonathan G Rennison
f077c3bf6e Merge branch 'master' into jgrpp 2020-04-06 20:58:54 +01:00
frosch
7fe291667f Fix #8060, 5880f14: Restore admin network API compatibility. 2020-04-05 18:36:21 +01:00
Jonathan G Rennison
8fb0b638fa Merge branch 'master' into jgrpp
# Conflicts:
#	src/network/network.cpp
2020-03-11 23:16:32 +00:00
Jonathan G Rennison
8f442500ea Change how dirty screen, window and viewport areas are tracked for later redrawing
Track dirty viewport areas seperately form general screen redraws.
Maintain a dirty block grid per viewport, with a smaller block size.
Use even smaller block size in viewport map mode.

Use a rectangle array for general screen redraws instead of a block grid.

Add a dirty bit to windows and widgets, to simplify the common case
of repainting a whole window or widget, without catching
neighbouring windows or viewports.
2020-03-05 00:27:17 +00:00
Quipyowert2
d1b7eb2de1 Codechange: Limit field width to avoid sscanf crash 2020-02-23 19:04:34 +00:00
Jonathan G Rennison
babe98cdb1 Merge branch 'master' into jgrpp
# Conflicts:
#	src/network/network_server.h
#	src/pathfinder/yapf/yapf_road.cpp
#	src/viewport.cpp
2020-02-09 15:43:47 +00:00
glx
2b1a7ceb4e Fix #7976: Don't kick the client doing the rcon 2020-02-08 09:03:14 +01:00
Bjarni Thor
5880f1479f Feature #7756: Allow server to supply a reason to kicked/banned clients
This commit adds the missing feature of allowing the server owner to
    provide a reason for kicking/banning a client, which the client sees in
    a pop-up window after being kicked. The implementation extends the
    network protocol by adding a new network action called
    NETWORK_ACTION_KICKED that is capable of having an error string, unlike
    the other network error packages.  Additionally, the kick function
    broadcasts a message to all clients about the kicked client and the
    reason for the kick.
2020-02-04 22:17:39 +00:00
Jonathan G Rennison
dd99fd646d Merge branch 'master' into jgrpp
# Conflicts:
#	src/base_station_base.h
#	src/industry.h
#	src/industry_cmd.cpp
#	src/industry_gui.cpp
#	src/lang/korean.txt
#	src/os/macosx/crashlog_osx.cpp
#	src/station_cmd.cpp
#	src/town.h
#	src/town_cmd.cpp
#	src/town_gui.cpp
2020-01-20 18:36:55 +00:00
Berbe
2fc2058b3b Feature: Auto-restart loads the original resources again
If the game was started loading a savegame or scenario, auto-restart will load a new random map.
This is inconsistent with the case in which a heightmap was loaded, as in that case the heightmap is kept as a basis for a new game.
This proposal solves this heterogeneity be considering the originally loaded resource shall be kept, hence savegames & scenarios shall be reloaded
2020-01-12 23:47:19 +01:00
Jonathan G Rennison
150dfba95b Codechange: Remove std::function from Pool iteration wrapper
Add a separate template wrapper for filtered iteration
2020-01-07 09:00:45 +00:00
Jonathan G Rennison
61934fdfdc Remove std::function from Pool iteration wrapper
Add a separate template wrapper for filtered iteration
2020-01-06 19:09:24 +00:00
Jonathan G Rennison
7960db35f2 Merge branch 'master' into jgrpp
# Conflicts:
#	config.lib
#	projects/openttd_vs140.vcxproj
#	projects/openttd_vs140.vcxproj.filters
#	projects/openttd_vs141.vcxproj
#	projects/openttd_vs141.vcxproj.filters
#	projects/openttd_vs142.vcxproj
#	projects/openttd_vs142.vcxproj.filters
#	src/aircraft_cmd.cpp
#	src/base_station_base.h
#	src/core/pool_type.hpp
#	src/disaster_vehicle.cpp
#	src/economy.cpp
#	src/engine.cpp
#	src/group.h
#	src/group_cmd.cpp
#	src/group_gui.cpp
#	src/lang/english.txt
#	src/lang/german.txt
#	src/linkgraph/linkgraph_gui.cpp
#	src/network/network_command.cpp
#	src/network/network_server.cpp
#	src/openttd.cpp
#	src/order_cmd.cpp
#	src/road_cmd.cpp
#	src/saveload/afterload.cpp
#	src/saveload/cargopacket_sl.cpp
#	src/saveload/linkgraph_sl.cpp
#	src/saveload/order_sl.cpp
#	src/saveload/station_sl.cpp
#	src/saveload/town_sl.cpp
#	src/saveload/vehicle_sl.cpp
#	src/screenshot.cpp
#	src/screenshot.h
#	src/settings_gui.cpp
#	src/settings_type.h
#	src/smallmap_gui.cpp
#	src/station.cpp
#	src/station_cmd.cpp
#	src/table/settings.ini
#	src/toolbar_gui.cpp
#	src/town_cmd.cpp
#	src/train.h
#	src/train_cmd.cpp
#	src/train_gui.cpp
#	src/vehicle.cpp
#	src/vehicle_base.h
#	src/vehiclelist.cpp
#	src/window_type.h
2020-01-06 18:45:51 +00:00
glx
e3c75a30ba Fix: unused variable warnings 2019-12-21 20:13:03 +01:00
glx
ee7a8eebca Codechange: Replace FOR_ALL_TOWNS with range-based for loops 2019-12-21 20:13:03 +01:00
glx
d8a1be48cd Codechange: Replace vehicle related FOR_ALL with range-based for loops 2019-12-21 20:13:03 +01:00
glx
41232f18c1 Codechange: Replace network related FOR_ALL with range-based for loops 2019-12-21 20:13:03 +01:00
glx
ddabfed1cd Codechange: Replace station related FOR_ALL with range-based for loops 2019-12-21 20:13:03 +01:00
glx
3a14cea068 Codechange: Replace FOR_ALL_COMPANIES with range-based for loops 2019-12-21 20:13:03 +01:00
Jonathan G Rennison
cbdd9f84d8 Merge branch 'master' into jgrpp
# Conflicts:
#	src/console_gui.cpp
#	src/lang/korean.txt
#	src/video/sdl2_v.cpp
#	src/video/sdl2_v.h
#	src/window.cpp
#	src/window_gui.h
2019-11-12 18:43:10 +00:00
S. D. Cloudt
13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
Jonathan G Rennison
c84a454d70 Network: Use shorter UDP MTU where data can be split across multiple packets. 2019-10-31 20:40:07 +00:00
Jonathan G Rennison
03fbe87752 Merge branch 'master' into jgrpp 2019-10-12 00:56:56 +01:00
Joe Stringer
b4f1056097 Fix: [Cygwin] Fix missing AI_ADDRCONFIG declaration
Fixes the following complaints:

src/network/core/address.cpp: In member function 'const sockaddr_storage* NetworkAddress::GetAddress()':
src/network/core/address.cpp:134:55: error: 'AI_ADDRCONFIG' was not declared in this scope
   this->Resolve(this->address.ss_family, SOCK_STREAM, AI_ADDRCONFIG, nullptr, ResolveLoopProc);

Signed-off-by: Joe Stringer <joe@wand.net.nz>
2019-10-07 21:36:00 +02:00
Jonathan G Rennison
edfd378e93 Merge branch 'master' into jgrpp
# Conflicts:
#	source.list
#	src/blitter/32bpp_anim.cpp
#	src/linkgraph/linkgraphjob.cpp
#	src/order_cmd.cpp
#	src/vehicle.cpp
#	src/vehicle_type.h
2019-10-05 21:45:54 +01:00
Charles Pigott
fe9731d32c Fix: clang and MSVC warnings (glx) 2019-09-30 14:00:06 +01:00
Charles Pigott
71a3e83468 Fix: GCC9's warnings about deprecated implicit assignment operators 2019-09-30 14:00:06 +01:00
JMcKiern
04f659e768 Fix: Some typos found using codespell 2019-09-29 21:27:32 +01:00
Jonathan G Rennison
ba9d1a0390 Merge branch 'jgrpp' into jgrpp-nrt
# Conflicts:
#	.ottdrev-vc
#	README.md
#	jgrpp-changelog.md
2019-08-29 01:01:45 +01:00
Jonathan G Rennison
9a05ea67d5 Add chicken bits setting
2 bits so far
2019-08-28 19:10:34 +01:00
Jonathan G Rennison
04ef407ddf Merge branch 'jgrpp' into jgrpp-nrt
# Conflicts:
#	.ottdrev-vc
#	README.md
#	jgrpp-changelog.md
#	src/ship_cmd.cpp
2019-08-24 10:41:08 +01:00
Jonathan G Rennison
2e4b1d73d8 Avoid performing emergency network save more than once 2019-08-22 01:40:28 +01:00
Jonathan G Rennison
6ce7f22fe6 Send server desync log to client 2019-08-22 01:13:07 +01:00
Jonathan G Rennison
459a49cb24 Add flags for mismatch type to client desync log 2019-08-20 22:52:03 +01:00
Jonathan G Rennison
ec892879f4 Add passworded mechanism to change server game settings from client 2019-08-20 20:42:17 +01:00
Jonathan G Rennison
17c054a650 Use password hash for network server and rcon passwords 2019-08-20 20:04:34 +01:00
Jonathan G Rennison
0aa366a24b Desync: Log seed and state checksum on desync 2019-08-06 03:03:40 +01:00
Jonathan G Rennison
a1d36b02f0 Network: Add state checksum which is check in network sync 2019-08-06 03:03:40 +01:00
Jonathan G Rennison
c941d2d2a6 Desync: Change sync event logging to desync debug level 2 2019-08-05 19:14:06 +01:00