diff options
author | rubidium <rubidium@openttd.org> | 2010-10-15 19:58:56 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-10-15 19:58:56 +0000 |
commit | 9858d699a3c39be2e3a547d59163178012365598 (patch) | |
tree | b0d10b23b4d41471d8ba846ca1805614acfec187 /src/network/core | |
parent | bda26d03b509c3783596c0b3431ca0c8fd7c9990 (diff) | |
download | openttd-9858d699a3c39be2e3a547d59163178012365598.tar.xz |
(svn r20935) -Codechange: only let the server side use a pool of connected sockets
Diffstat (limited to 'src/network/core')
-rw-r--r-- | src/network/core/tcp_game.cpp | 14 | ||||
-rw-r--r-- | src/network/core/tcp_game.h | 10 |
2 files changed, 4 insertions, 20 deletions
diff --git a/src/network/core/tcp_game.cpp b/src/network/core/tcp_game.cpp index 037cb42fc..0960f4324 100644 --- a/src/network/core/tcp_game.cpp +++ b/src/network/core/tcp_game.cpp @@ -17,18 +17,10 @@ #include "../network.h" #include "../network_internal.h" -#include "../../core/pool_func.hpp" #include "../../debug.h" #include "table/strings.h" -/** Make very sure the preconditions given in network_type.h are actually followed */ -assert_compile(MAX_CLIENT_SLOTS > MAX_CLIENTS); -assert_compile(NetworkClientSocketPool::MAX_SIZE == MAX_CLIENT_SLOTS); - -NetworkClientSocketPool _networkclientsocket_pool("NetworkClientSocket"); -INSTANTIATE_POOL_METHODS(NetworkClientSocket) - /** * Create a new socket for the game connection. * @param s The socket to connect with. @@ -75,7 +67,7 @@ NetworkRecvStatus NetworkGameSocketHandler::CloseConnection(bool error) * @param p the packet to handle * @return #NetworkRecvStatus of handling. */ -NetworkRecvStatus NetworkClientSocket::HandlePacket(Packet *p) +NetworkRecvStatus NetworkGameSocketHandler::HandlePacket(Packet *p) { PacketGameType type = (PacketGameType)p->Recv_uint8(); @@ -140,7 +132,7 @@ NetworkRecvStatus NetworkClientSocket::HandlePacket(Packet *p) * HandlePacket is returned. * @return #NetworkRecvStatus of the last handled packet. */ -NetworkRecvStatus NetworkClientSocket::Recv_Packets() +NetworkRecvStatus NetworkGameSocketHandler::Recv_Packets() { Packet *p; while ((p = this->Recv_Packet()) != NULL) { @@ -158,7 +150,7 @@ NetworkRecvStatus NetworkClientSocket::Recv_Packets() * @param type the packet type to create the stub for */ #define DEFINE_UNAVAILABLE_GAME_RECEIVE_COMMAND(type) \ -NetworkRecvStatus NetworkClientSocket::NetworkPacketReceive_## type ##_command(Packet *p) \ +NetworkRecvStatus NetworkGameSocketHandler::NetworkPacketReceive_## type ##_command(Packet *p) \ { \ DEBUG(net, 0, "[tcp/game] received illegal packet type %d from client %d", \ type, this->client_id); \ diff --git a/src/network/core/tcp_game.h b/src/network/core/tcp_game.h index 5ab814bae..71537179b 100644 --- a/src/network/core/tcp_game.h +++ b/src/network/core/tcp_game.h @@ -108,16 +108,11 @@ enum ClientStatus { STATUS_END ///< Must ALWAYS be on the end of this list!! (period) }; -class NetworkGameSocketHandler; -typedef NetworkGameSocketHandler NetworkClientSocket; -typedef Pool<NetworkClientSocket, ClientIndex, 8, MAX_CLIENT_SLOTS> NetworkClientSocketPool; -extern NetworkClientSocketPool _networkclientsocket_pool; - #define DECLARE_GAME_RECEIVE_COMMAND(type) virtual NetworkRecvStatus NetworkPacketReceive_## type ##_command(Packet *p) #define DEF_GAME_RECEIVE_COMMAND(cls, type) NetworkRecvStatus cls ##NetworkGameSocketHandler::NetworkPacketReceive_ ## type ## _command(Packet *p) /** Base socket handler for all TCP sockets */ -class NetworkGameSocketHandler : public NetworkClientSocketPool::PoolItem<&_networkclientsocket_pool>, public NetworkTCPSocketHandler { +class NetworkGameSocketHandler : public NetworkTCPSocketHandler { /* TODO: rewrite into a proper class */ private: NetworkClientInfo *info; ///< Client info related to this socket @@ -191,9 +186,6 @@ public: void Send_Command(Packet *p, const CommandPacket *cp); }; -#define FOR_ALL_CLIENT_SOCKETS_FROM(var, start) FOR_ALL_ITEMS_FROM(NetworkClientSocket, clientsocket_index, var, start) -#define FOR_ALL_CLIENT_SOCKETS(var) FOR_ALL_CLIENT_SOCKETS_FROM(var, 0) - #endif /* ENABLE_NETWORK */ #endif /* NETWORK_CORE_TCP_GAME_H */ |