Commit Graph

145 Commits (199e41c762c52c3fff85e52853ef78b7332c7645)

Author SHA1 Message Date
Patric Stout 199e41c762
Codechange: use default dtor instead of empty (#10826) 1 year ago
Tyler Trahan 6501f84b4a
Codechange: Move calendar date functions inside TimerGameCalendar (#10753) 1 year ago
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!
3 years ago
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.
3 years ago
Patric Stout e1e2212e0e Codechange: track version of network servers to prune once out-of-date 3 years ago
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 3 years ago
rubidium42 ab9b937ab7 Codechange: [Network] Use std::string to get a NewGRF's name 3 years ago
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.
3 years ago
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
3 years ago
rubidium42 f1dfa661a1 Codechange: [Network] Use std::string for NetworkGameInfo 3 years ago
rubidium42 dcef3209a6 Codechange: [Network] Use new/delete instead of calloc/free for NetworkGameList 3 years ago
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.
3 years ago
rubidium42 72bd62fd70 Codechange: [Network] Use a single NetworkServerGameInfo object at server side and serialize that for the clients 3 years ago
Patric Stout a8afbe74bf Cleanup: remove write-only variable "hostname" in NetworkGameList 3 years ago
Patric Stout b57d845e55 Codechange: refactor CheckGameCompatibility() from existing function
Later commits use this function in other places too.
3 years ago
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.
3 years ago
Rubidium d6000c2ec5 Codechange: differentiate between UDP, TCP and compatibility MTU values 3 years ago
Rubidium a2051bad50 Codechange: move logic whether there is enough space in a packet to write data into the Packet 3 years ago
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.
3 years ago
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.
3 years ago
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 3 years ago
Rubidium ca6b9ad8b0 Change: move some things only relevant to UDP from network.cpp to network_udp.cpp 3 years ago
Patric Stout 53c28a8ec9 Codechange: [Network] replace _realtime_tick with std::chrono 3 years ago
Charles Pigott 9b800a96ed
Codechange: Remove min/max functions in favour of STL variants (#8502) 3 years ago
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.
4 years ago
Michael Lutz 43cd892e0c Codechange: Replace custom linked list for GRF texts with STL vectors and strings. 4 years ago
glx 3a14cea068 Codechange: Replace FOR_ALL_COMPANIES with range-based for loops 5 years ago
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 5 years ago
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 5 years ago
Michael Lutz 05bc2ed7cb Codechange: Replace custom thread code with C++11 thread objects.
We assume a conforming C++11 compiler environment that has a valid <thread>-header.
Failure to run a real thread is handled gracefully.
5 years ago
Michael Lutz 05f4e73608 Codechange: Replace custom mutex code with C++11 mutex'es.
A conforming compiler with a valid <mutex>-header is expected.
Most parts of the code assume that locking a mutex will never fail unexpectedly,
which is generally true on all common platforms that don't just pretend to
be C++11. The use of condition variables in driver code is checked.
5 years ago
Henry Wilson ab711e6942 Codechange: Replaced SmallVector::[Begin|End]() with std alternatives 5 years ago
Henry Wilson bfd79e59dc Codechange: Replace SmallVector::Clear() with std::vector::clear() 5 years ago
peter1138 07de9d6c3f Codechange: Use override keyword in networking classes. 5 years ago
Patric Stout e3c639a09f Remove: ENABLE_NETWORK switch
This switch has been a pain for years. Often disabling broke
compilation, as no developer compiles OpenTTD without, neither do
any of our official binaries.

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

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

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

All in all, it is time to remove the ENABLE_NETWORK switch. No
replacement is planned, but if you feel we really need this option,
we welcome any Pull Request which implements this in a way that
doesn't crawl through the code like this diff shows we used to.
5 years ago
Niels Martin Hansen 5f8354f358 Change: Make a shortened network revision string for use in server queries 5 years ago
frosch 31f046bd9b (svn r27670) -Add: [FS#6471] Assign descriptive names to (GNU pthread) threads. (JGR) 8 years ago
rubidium ff5c05c1b4 (svn r27400) -Fix [FS#6368] (r26449): when a dedicated server was paused with no clients the tick length was increased significantly, making any assumptions about the tick length used further down in the code are not true anymore. One of such assumptions was that one should readvertise every 15 minutes worth of original ticks, but due to the lengthening this timeframe would be more like 45-60 minutes. Now we'll take the operating system's millisecond counter instead 9 years ago
rubidium 5b82822c12 (svn r26486) -Codechange: replace a number of snprintfs with seprintf 10 years ago
rubidium 0463dbdc9e (svn r26482) -Codechange: add an include that allows us to undefine/redefine "unsafe" functions to prevent them from being used, and thus having to care about certain aspects of their return values 10 years ago
planetmaker c24374f99c (svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow) 12 years ago
rubidium 1adb9a5c85 (svn r24070) -Fix [FS#5098]: the 'last joined' server was not properly selected anymore (adf88) 12 years ago
rubidium d2c643df63 (svn r23754) -Fix (r23752): the locks aren't reentrant 13 years ago
rubidium c530450193 (svn r23752) -Fix [FS#4938]: missing locking causing crash is extreme case when being in the MP lobby 13 years ago
rubidium 531e501b5a (svn r23751) -Codechange: rename NetworkUDPGameLoop to a more descriptive name, and move the UDP specific bits to network_udp 13 years ago
yexo 7a7d9a7b6b (svn r23494) -Feature: [NewGRF] action14 node INFO->URL_ to add an url 13 years ago
rubidium 289133be14 (svn r22695) -Fix [FS#4697]: mark addresses that could not be resolved as 'do not resolve anymore' as well, instead of trying to resolve them each and every time the address is accessed 13 years ago
rubidium 944a5cb7aa (svn r22423) -Document: some network stuff 13 years ago
rubidium 536c581923 (svn r22401) -Codechange: replace some defines in the udp code so doxygen can create better documentation 13 years ago
yexo 93533b603a (svn r22162) -Fix [FS#4533]: No update of NewGRF window when unknown GRF name becomes available 13 years ago