Commit Graph

62 Commits

Author SHA1 Message Date
Rubidium 1cf8799810 Feature: encrypt the connection between game server and client 2024-03-17 19:48:34 +01:00
Rubidium 72a44b0df6 Codechange: use references for handling received TCP packets 2024-02-05 16:30:49 +01:00
Rubidium 031a9d4e26 Codechange: use std::unique_ptr for the Packets created to send via TCP 2024-02-05 16:30:49 +01:00
Rubidium 36e1b32ccf Codechange: use std::deque of std::unique_ptr to queue packets 2024-02-05 16:30:49 +01:00
Rubidium c77a45ed86 Codechange: use std::unique_ptr for receiving network packets 2024-02-05 16:30:49 +01:00
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +02: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
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 2021-06-13 12:45:45 +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 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
rubidium42 22720332eb Codechange: encapsulate network error handling 2021-05-01 19:36:22 +02: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
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
Rubidium 3abefdf561 Codechange: remove public access to the next pointer in 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 c545cc9d70 Codechange: move more logic about packet size validity and reading into Packet 2021-04-24 20:42:01 +02:00
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 2019-04-10 23:22:20 +02:00
Patric Stout e3c639a09f Remove: ENABLE_NETWORK switch
This switch has been a pain for years. Often disabling broke
compilation, as no developer compiles OpenTTD without, neither do
any of our official binaries.

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

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

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

All in all, it is time to remove the ENABLE_NETWORK switch. No
replacement is planned, but if you feel we really need this option,
we welcome any Pull Request which implements this in a way that
doesn't crawl through the code like this diff shows we used to.
2019-03-20 19:24:55 +01:00
Patric Stout 7784d77713 Remove: MorphOS / AmigaOS support
In 10 years there is no commit to change how MorphOS works, and we
have no active maintainer for it. It is unlikely it works in its
current state (but not impossible).

With the arrival of SDL2 (and removal of SDL), MorphOS is no longer
support. There is an SDL2 port for MorphOS, but it is not maintained
by upstream SDL2, and nobody can currently test it out.

If anyone wants to re-add MorphOS, please do (revert this patch,
fix the problems, and create a Pull Request). If you need any help
doing so, let us know! It is not that we don't like MorphOS, it is
that we don't have anyone fixing the problems :(
2019-03-05 22:03:00 +01:00
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 2014-04-23 20:13:33 +00:00
rubidium fad4fa09ba (svn r26046) -Fix: handle a number of failure conditions from methods called in the network code 2013-11-22 21:41:19 +00:00
rubidium 99ec3a044a (svn r22403) -Document: some more network/core code 2011-05-01 13:29:40 +00:00
rubidium adfd648031 (svn r22068) -Codechange/Fix: return "connection lost" instead of "okay" when SendPackets closed the connection 2011-02-12 21:09:34 +00:00
rubidium b6c2216749 (svn r21358) -Codechange: make some network function names conform to coding style 2010-11-30 13:38:46 +00:00
rubidium 9c83a8975f (svn r21357) -Codechange: make it possible to resize the packet's buffer 2010-11-30 13:22:29 +00:00
rubidium 673b3711b4 (svn r21182) -Fix: possible just-freed memory reads 2010-11-14 12:05:24 +00:00
rubidium 5ed77b4919 (svn r20939) -Fix: some MSVC warnings 2010-10-15 22:08:57 +00:00
rubidium f555e6d72e (svn r20933) -Codechange: move some more client related methods and such to network_client.cpp 2010-10-15 19:33:08 +00:00
rubidium f89d6bea0e (svn r18801) -Fix: in some cases error messages weren't properly sent to the client before closing the connection. As a result the client would say 'connection lost' when the cause was something completely different. 2010-01-14 21:48:42 +00:00
smatz eb72a0095f (svn r17746) -Codechange: 'operator new' doesn't return NULL, NetworkSend_Init() is useless 2009-10-09 11:03:00 +00:00
rubidium df75db67eb (svn r17742) -Codechange: remove unused variable from Recv_Packet 2009-10-07 20:58:14 +00:00
rubidium d6cded5380 (svn r17693) -Cleanup: remove some unneeded includes 2009-10-04 17:16:41 +00:00
rubidium 7fbc33dae1 (svn r17248) -Fix: add GPL license notice where appropriate 2009-08-21 20:21:05 +00:00
rubidium 9b156c1bd4 (svn r16601) -Fix [FS#2880]: try 2... hopefully better this time 2009-06-19 20:26:18 +00:00
rubidium 2a6e9288fd (svn r15971) -Codechange: make it possible for UDP socket handlers to bind to multiple sockets. 2009-04-07 20:27:13 +00:00
rubidium 22d9306889 (svn r15967) -Codechange: do not access NetworkSocketHandler::has_quit directly 2009-04-07 18:23:14 +00:00
rubidium 4f5a8b15ed (svn r15206) -Fix [FS#2567]: memory corruption due to not properly cleanup up the mess when cancelling a download 2009-01-22 10:09:56 +00:00
rubidium 28a641066e (svn r15163) -Change/Fix: use a non-blocking method to resolve the hostname and connect to game servers. 2009-01-20 11:28:18 +00:00
rubidium e18c24cdb5 (svn r15079) -Codechange: split tcp 'backend' and in-game handling like it is for UDP. 2009-01-14 12:50:13 +00:00
rubidium 105b84e343 (svn r14760) -Fix (rlongago): network connection of clients being closed twice (found due to added assertion in r14730) 2008-12-28 21:45:41 +00:00
rubidium afddfcb2b1 (svn r14730) -Codechange: remove the need for networkclientsockets and networkclientinfo structs to be in a contiguous piece of memory and put them in a pool.
-Note: 255 should really be enough for now... making it any more means network protocol bumps.
2008-12-23 20:52:27 +00:00
rubidium ae96ca635c (svn r14721) -Codechange: s/NetworkTCPSocketHandler/NetworkClientSocket/ as it's (way) more descriptive what it's used for. 2008-12-23 09:47:42 +00:00
rubidium 782b80eff7 (svn r14709) -Codechange: make a clearer distinction between 'unique' client identification ids and the indices into the clients/client info arrays. 2008-12-22 12:59:31 +00:00
rubidium 2f3b88ef9a (svn r13343) -Codechange: reorder/move variable/functions in the network headers so that nothing from the network directory needs to include basically all network headers. 2008-05-30 18:20:26 +00:00