summaryrefslogtreecommitdiff
path: root/src/network/core
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2019-03-20 17:01:13 +0100
committerPatric Stout <truebrain@openttd.org>2019-03-20 19:24:55 +0100
commite3c639a09f1d2251477f69496120d057dd8320a9 (patch)
tree7d66891ae41db811e1edd13647b05092dca54b5a /src/network/core
parent72c5f2b3eed77120d86ecf636e07c71eb23b4bd5 (diff)
downloadopenttd-e3c639a09f1d2251477f69496120d057dd8320a9.tar.xz
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.
Diffstat (limited to 'src/network/core')
-rw-r--r--src/network/core/address.cpp4
-rw-r--r--src/network/core/address.h3
-rw-r--r--src/network/core/core.cpp4
-rw-r--r--src/network/core/core.h4
-rw-r--r--src/network/core/game.h4
-rw-r--r--src/network/core/host.cpp4
-rw-r--r--src/network/core/os_abstraction.h4
-rw-r--r--src/network/core/packet.cpp4
-rw-r--r--src/network/core/packet.h4
-rw-r--r--src/network/core/tcp.cpp4
-rw-r--r--src/network/core/tcp.h4
-rw-r--r--src/network/core/tcp_admin.cpp4
-rw-r--r--src/network/core/tcp_admin.h4
-rw-r--r--src/network/core/tcp_connect.cpp4
-rw-r--r--src/network/core/tcp_content.cpp4
-rw-r--r--src/network/core/tcp_content.h4
-rw-r--r--src/network/core/tcp_game.cpp4
-rw-r--r--src/network/core/tcp_game.h4
-rw-r--r--src/network/core/tcp_http.cpp4
-rw-r--r--src/network/core/tcp_http.h4
-rw-r--r--src/network/core/tcp_listen.h4
-rw-r--r--src/network/core/udp.cpp4
-rw-r--r--src/network/core/udp.h4
23 files changed, 0 insertions, 91 deletions
diff --git a/src/network/core/address.cpp b/src/network/core/address.cpp
index 62af3a40b..952229776 100644
--- a/src/network/core/address.cpp
+++ b/src/network/core/address.cpp
@@ -11,8 +11,6 @@
#include "../../stdafx.h"
-#ifdef ENABLE_NETWORK
-
#include "address.h"
#include "../../debug.h"
@@ -433,5 +431,3 @@ void NetworkAddress::Listen(int socktype, SocketList *sockets)
default: return "unsupported";
}
}
-
-#endif /* ENABLE_NETWORK */
diff --git a/src/network/core/address.h b/src/network/core/address.h
index 9fd40eaee..b5c78c79b 100644
--- a/src/network/core/address.h
+++ b/src/network/core/address.h
@@ -17,8 +17,6 @@
#include "../../string_func.h"
#include "../../core/smallmap_type.hpp"
-#ifdef ENABLE_NETWORK
-
class NetworkAddress;
typedef SmallVector<NetworkAddress, 4> NetworkAddressList; ///< Type for a list of addresses.
typedef SmallMap<NetworkAddress, SOCKET, 4> SocketList; ///< Type for a mapping between address and socket.
@@ -192,5 +190,4 @@ public:
static const char *AddressFamilyAsString(int family);
};
-#endif /* ENABLE_NETWORK */
#endif /* NETWORK_CORE_ADDRESS_H */
diff --git a/src/network/core/core.cpp b/src/network/core/core.cpp
index e5f1df721..1726e4176 100644
--- a/src/network/core/core.cpp
+++ b/src/network/core/core.cpp
@@ -11,8 +11,6 @@
* @file core.cpp Functions used to initialize/shut down the core network
*/
-#ifdef ENABLE_NETWORK
-
#include "../../stdafx.h"
#include "../../debug.h"
#include "os_abstraction.h"
@@ -80,5 +78,3 @@ void NetworkSocketHandler::ReceiveGRFIdentifier(Packet *p, GRFIdentifier *grf)
grf->md5sum[j] = p->Recv_uint8();
}
}
-
-#endif /* ENABLE_NETWORK */
diff --git a/src/network/core/core.h b/src/network/core/core.h
index a250dbb08..1536c08a7 100644
--- a/src/network/core/core.h
+++ b/src/network/core/core.h
@@ -17,8 +17,6 @@
#include "../../newgrf_config.h"
#include "config.h"
-#ifdef ENABLE_NETWORK
-
bool NetworkCoreInitialize();
void NetworkCoreShutdown();
@@ -80,6 +78,4 @@ public:
void SendCompanyInformation(Packet *p, const struct Company *c, const struct NetworkCompanyStats *stats, uint max_len = NETWORK_COMPANY_NAME_LENGTH);
};
-#endif /* ENABLE_NETWORK */
-
#endif /* NETWORK_CORE_CORE_H */
diff --git a/src/network/core/game.h b/src/network/core/game.h
index a9da29118..57eba5812 100644
--- a/src/network/core/game.h
+++ b/src/network/core/game.h
@@ -19,8 +19,6 @@
#include "../../newgrf_config.h"
#include "../../date_type.h"
-#ifdef ENABLE_NETWORK
-
/**
* The game information that is not generated on-the-fly and has to
* be sent to the clients.
@@ -58,6 +56,4 @@ struct NetworkGameInfo : NetworkServerGameInfo {
const char * GetNetworkRevisionString();
-#endif /* ENABLE_NETWORK */
-
#endif /* NETWORK_CORE_GAME_H */
diff --git a/src/network/core/host.cpp b/src/network/core/host.cpp
index c2faf4c8b..05ad84153 100644
--- a/src/network/core/host.cpp
+++ b/src/network/core/host.cpp
@@ -9,8 +9,6 @@
/** @file host.cpp Functions related to getting host specific data (IPs). */
-#ifdef ENABLE_NETWORK
-
#include "../../stdafx.h"
#include "../../debug.h"
#include "address.h"
@@ -207,5 +205,3 @@ void NetworkFindBroadcastIPs(NetworkAddressList *broadcast)
DEBUG(net, 3, "%d) %s", i++, addr->GetHostname());
}
}
-
-#endif /* ENABLE_NETWORK */
diff --git a/src/network/core/os_abstraction.h b/src/network/core/os_abstraction.h
index 16c85d566..ef5c0f2ab 100644
--- a/src/network/core/os_abstraction.h
+++ b/src/network/core/os_abstraction.h
@@ -18,8 +18,6 @@
/* Include standard stuff per OS */
-#ifdef ENABLE_NETWORK
-
/* Windows stuff */
#if defined(_WIN32)
#include <errno.h>
@@ -172,6 +170,4 @@ static inline bool SetNoDelay(SOCKET d)
assert_compile(sizeof(in_addr) == 4); ///< IPv4 addresses should be 4 bytes.
assert_compile(sizeof(in6_addr) == 16); ///< IPv6 addresses should be 16 bytes.
-#endif /* ENABLE_NETWORK */
-
#endif /* NETWORK_CORE_OS_ABSTRACTION_H */
diff --git a/src/network/core/packet.cpp b/src/network/core/packet.cpp
index 7548132e0..8cecd9bd2 100644
--- a/src/network/core/packet.cpp
+++ b/src/network/core/packet.cpp
@@ -11,8 +11,6 @@
* @file packet.cpp Basic functions to create, fill and read packets.
*/
-#ifdef ENABLE_NETWORK
-
#include "../../stdafx.h"
#include "../../string_func.h"
@@ -310,5 +308,3 @@ void Packet::Recv_string(char *buffer, size_t size, StringValidationSettings set
str_validate(bufp, last, settings);
}
-
-#endif /* ENABLE_NETWORK */
diff --git a/src/network/core/packet.h b/src/network/core/packet.h
index 7f344d017..7b4bf26f3 100644
--- a/src/network/core/packet.h
+++ b/src/network/core/packet.h
@@ -18,8 +18,6 @@
#include "core.h"
#include "../../string_type.h"
-#ifdef ENABLE_NETWORK
-
typedef uint16 PacketSize; ///< Size of the whole packet.
typedef uint8 PacketType; ///< Identifier for the packet
@@ -87,6 +85,4 @@ public:
void Recv_string(char *buffer, size_t size, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK);
};
-#endif /* ENABLE_NETWORK */
-
#endif /* NETWORK_CORE_PACKET_H */
diff --git a/src/network/core/tcp.cpp b/src/network/core/tcp.cpp
index a2f789c09..33b61688d 100644
--- a/src/network/core/tcp.cpp
+++ b/src/network/core/tcp.cpp
@@ -11,8 +11,6 @@
* @file tcp.cpp Basic functions to receive and send TCP packets.
*/
-#ifdef ENABLE_NETWORK
-
#include "../../stdafx.h"
#include "../../debug.h"
@@ -243,5 +241,3 @@ bool NetworkTCPSocketHandler::CanSendReceive()
this->writable = !!FD_ISSET(this->sock, &write_fd);
return FD_ISSET(this->sock, &read_fd) != 0;
}
-
-#endif /* ENABLE_NETWORK */
diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h
index b736189b4..00642c2dd 100644
--- a/src/network/core/tcp.h
+++ b/src/network/core/tcp.h
@@ -17,8 +17,6 @@
#include "address.h"
#include "packet.h"
-#ifdef ENABLE_NETWORK
-
/** The states of sending the packets. */
enum SendPacketsState {
SPS_CLOSED, ///< The connection got closed.
@@ -99,6 +97,4 @@ public:
static void KillAll();
};
-#endif /* ENABLE_NETWORK */
-
#endif /* NETWORK_CORE_TCP_H */
diff --git a/src/network/core/tcp_admin.cpp b/src/network/core/tcp_admin.cpp
index 284ceda9b..226bae024 100644
--- a/src/network/core/tcp_admin.cpp
+++ b/src/network/core/tcp_admin.cpp
@@ -11,8 +11,6 @@
* @file tcp_admin.cpp Basic functions to receive and send TCP packets to and from the admin network.
*/
-#ifdef ENABLE_NETWORK
-
#include "../../stdafx.h"
#include "../network_internal.h"
@@ -172,5 +170,3 @@ NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_NAMES(Packet *p)
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_CMD_LOGGING(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_CMD_LOGGING); }
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_RCON_END(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_RCON_END); }
NetworkRecvStatus NetworkAdminSocketHandler::Receive_SERVER_PONG(Packet *p) { return this->ReceiveInvalidPacket(ADMIN_PACKET_SERVER_PONG); }
-
-#endif /* ENABLE_NETWORK */
diff --git a/src/network/core/tcp_admin.h b/src/network/core/tcp_admin.h
index e141a191a..497c24b48 100644
--- a/src/network/core/tcp_admin.h
+++ b/src/network/core/tcp_admin.h
@@ -19,8 +19,6 @@
#include "../network_type.h"
#include "../../core/pool_type.hpp"
-#ifdef ENABLE_NETWORK
-
/**
* Enum with types of TCP packets specific to the admin network.
* This protocol may only be extended to ensure stability.
@@ -500,6 +498,4 @@ public:
}
};
-#endif /* ENABLE_NETWORK */
-
#endif /* NETWORK_CORE_TCP_ADMIN_H */
diff --git a/src/network/core/tcp_connect.cpp b/src/network/core/tcp_connect.cpp
index 2dc789882..95f9662cd 100644
--- a/src/network/core/tcp_connect.cpp
+++ b/src/network/core/tcp_connect.cpp
@@ -11,8 +11,6 @@
* @file tcp_connect.cpp Basic functions to create connections without blocking.
*/
-#ifdef ENABLE_NETWORK
-
#include "../../stdafx.h"
#include "../../thread/thread.h"
@@ -97,5 +95,3 @@ void TCPConnecter::Connect()
{
for (TCPConnecter **iter = _tcp_connecters.Begin(); iter != _tcp_connecters.End(); iter++) (*iter)->killed = true;
}
-
-#endif /* ENABLE_NETWORK */
diff --git a/src/network/core/tcp_content.cpp b/src/network/core/tcp_content.cpp
index fc22c4491..8257a7252 100644
--- a/src/network/core/tcp_content.cpp
+++ b/src/network/core/tcp_content.cpp
@@ -11,8 +11,6 @@
* @file tcp_content.cpp Basic functions to receive and send Content packets.
*/
-#ifdef ENABLE_NETWORK
-
#include "../../stdafx.h"
#ifndef OPENTTD_MSU
#include "../../textfile_gui.h"
@@ -266,5 +264,3 @@ Subdirectory GetContentInfoSubDir(ContentType type)
}
}
#endif /* OPENTTD_MSU */
-
-#endif /* ENABLE_NETWORK */
diff --git a/src/network/core/tcp_content.h b/src/network/core/tcp_content.h
index a506439da..c359fb667 100644
--- a/src/network/core/tcp_content.h
+++ b/src/network/core/tcp_content.h
@@ -19,8 +19,6 @@
#include "packet.h"
#include "../../debug.h"
-#ifdef ENABLE_NETWORK
-
/** The values in the enum are important; they are used as database 'keys' */
enum ContentType {
CONTENT_TYPE_BEGIN = 1, ///< Helper to mark the begin of the types
@@ -213,6 +211,4 @@ public:
Subdirectory GetContentInfoSubDir(ContentType type);
#endif /* OPENTTD_MSU */
-#endif /* ENABLE_NETWORK */
-
#endif /* NETWORK_CORE_TCP_CONTENT_H */
diff --git a/src/network/core/tcp_game.cpp b/src/network/core/tcp_game.cpp
index caa378fc4..2d8a74a11 100644
--- a/src/network/core/tcp_game.cpp
+++ b/src/network/core/tcp_game.cpp
@@ -11,8 +11,6 @@
* @file tcp_game.cpp Basic functions to receive and send TCP packets for game purposes.
*/
-#ifdef ENABLE_NETWORK
-
#include "../../stdafx.h"
#include "../network.h"
@@ -199,5 +197,3 @@ NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_MOVE(Packet *p) { ret
NetworkRecvStatus NetworkGameSocketHandler::Receive_CLIENT_MOVE(Packet *p) { return this->ReceiveInvalidPacket(PACKET_CLIENT_MOVE); }
NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_COMPANY_UPDATE(Packet *p) { return this->ReceiveInvalidPacket(PACKET_SERVER_COMPANY_UPDATE); }
NetworkRecvStatus NetworkGameSocketHandler::Receive_SERVER_CONFIG_UPDATE(Packet *p) { return this->ReceiveInvalidPacket(PACKET_SERVER_CONFIG_UPDATE); }
-
-#endif /* ENABLE_NETWORK */
diff --git a/src/network/core/tcp_game.h b/src/network/core/tcp_game.h
index 5c6cb5c34..c41ad4dc1 100644
--- a/src/network/core/tcp_game.h
+++ b/src/network/core/tcp_game.h
@@ -19,8 +19,6 @@
#include "../network_type.h"
#include "../../core/pool_type.hpp"
-#ifdef ENABLE_NETWORK
-
/**
* Enum with all types of TCP packets.
* For the exact meaning, look at #NetworkGameSocketHandler.
@@ -558,6 +556,4 @@ public:
void SendCommand(Packet *p, const CommandPacket *cp);
};
-#endif /* ENABLE_NETWORK */
-
#endif /* NETWORK_CORE_TCP_GAME_H */
diff --git a/src/network/core/tcp_http.cpp b/src/network/core/tcp_http.cpp
index 4cd92e5fe..3a40e3eec 100644
--- a/src/network/core/tcp_http.cpp
+++ b/src/network/core/tcp_http.cpp
@@ -11,8 +11,6 @@
* @file tcp_http.cpp Basic functions to receive and send HTTP TCP packets.
*/
-#ifdef ENABLE_NETWORK
-
#include "../../stdafx.h"
#include "../../debug.h"
#include "../../rev.h"
@@ -331,5 +329,3 @@ int NetworkHTTPSocketHandler::Receive()
iter++;
}
}
-
-#endif /* ENABLE_NETWORK */
diff --git a/src/network/core/tcp_http.h b/src/network/core/tcp_http.h
index 36520f136..ec969264b 100644
--- a/src/network/core/tcp_http.h
+++ b/src/network/core/tcp_http.h
@@ -16,8 +16,6 @@
#include "tcp.h"
-#ifdef ENABLE_NETWORK
-
/** Callback for when the HTTP handler has something to tell us. */
struct HTTPCallback {
/**
@@ -122,6 +120,4 @@ public:
}
};
-#endif /* ENABLE_NETWORK */
-
#endif /* NETWORK_CORE_TCP_HTTP_H */
diff --git a/src/network/core/tcp_listen.h b/src/network/core/tcp_listen.h
index 8cd8257b2..21bcaea3c 100644
--- a/src/network/core/tcp_listen.h
+++ b/src/network/core/tcp_listen.h
@@ -20,8 +20,6 @@
#include "../../debug.h"
#include "table/strings.h"
-#ifdef ENABLE_NETWORK
-
/**
* Template for TCP listeners.
* @param Tsocket The class we create sockets for.
@@ -173,6 +171,4 @@ public:
template <class Tsocket, PacketType Tfull_packet, PacketType Tban_packet> SocketList TCPListenHandler<Tsocket, Tfull_packet, Tban_packet>::sockets;
-#endif /* ENABLE_NETWORK */
-
#endif /* NETWORK_CORE_TCP_LISTEN_H */
diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp
index 1f34d15b0..4a2f77368 100644
--- a/src/network/core/udp.cpp
+++ b/src/network/core/udp.cpp
@@ -11,8 +11,6 @@
* @file core/udp.cpp Basic functions to receive and send UDP packets.
*/
-#ifdef ENABLE_NETWORK
-
#include "../../stdafx.h"
#include "../../date_func.h"
#include "../../debug.h"
@@ -347,5 +345,3 @@ void NetworkUDPSocketHandler::Receive_SERVER_UNREGISTER(Packet *p, NetworkAddres
void NetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS(Packet *p, NetworkAddress *client_addr) { this->ReceiveInvalidPacket(PACKET_UDP_CLIENT_GET_NEWGRFS, client_addr); }
void NetworkUDPSocketHandler::Receive_SERVER_NEWGRFS(Packet *p, NetworkAddress *client_addr) { this->ReceiveInvalidPacket(PACKET_UDP_SERVER_NEWGRFS, client_addr); }
void NetworkUDPSocketHandler::Receive_MASTER_SESSION_KEY(Packet *p, NetworkAddress *client_addr) { this->ReceiveInvalidPacket(PACKET_UDP_MASTER_SESSION_KEY, client_addr); }
-
-#endif /* ENABLE_NETWORK */
diff --git a/src/network/core/udp.h b/src/network/core/udp.h
index 9aa0c9dc4..2f77a94df 100644
--- a/src/network/core/udp.h
+++ b/src/network/core/udp.h
@@ -18,8 +18,6 @@
#include "game.h"
#include "packet.h"
-#ifdef ENABLE_NETWORK
-
/** Enum with all types of UDP packets. The order MUST not be changed **/
enum PacketUDPType {
PACKET_UDP_CLIENT_FIND_SERVER, ///< Queries a game server for game information
@@ -246,6 +244,4 @@ public:
void ReceiveNetworkGameInfo(Packet *p, NetworkGameInfo *info);
};
-#endif /* ENABLE_NETWORK */
-
#endif /* NETWORK_CORE_UDP_H */