From 62a7948af0ca9eb3b190a54918201e1075edcbbc Mon Sep 17 00:00:00 2001 From: smatz Date: Fri, 22 May 2009 15:13:50 +0000 Subject: (svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved --- src/network/core/tcp_game.cpp | 8 ++++---- src/network/core/tcp_game.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/network/core') diff --git a/src/network/core/tcp_game.cpp b/src/network/core/tcp_game.cpp index d34ace4bf..b4bb52190 100644 --- a/src/network/core/tcp_game.cpp +++ b/src/network/core/tcp_game.cpp @@ -13,16 +13,16 @@ #include "../network_internal.h" #include "packet.h" #include "tcp_game.h" +#include "../../core/pool_func.hpp" #include "table/strings.h" -#include "../../oldpool_func.h" /** Make very sure the preconditions given in network_type.h are actually followed */ -assert_compile(MAX_CLIENT_SLOTS == (MAX_CLIENT_SLOTS >> NCI_BITS_PER_POOL_BLOCK) << NCI_BITS_PER_POOL_BLOCK); assert_compile(MAX_CLIENT_SLOTS > MAX_CLIENTS); +assert_compile(NetworkClientSocketPool::MAX_SIZE == MAX_CLIENT_SLOTS); -typedef ClientIndex NetworkClientSocketID; -DEFINE_OLD_POOL_GENERIC(NetworkClientSocket, NetworkClientSocket); +NetworkClientSocketPool _networkclientsocket_pool("NetworkClientSocket"); +INSTANTIATE_POOL_METHODS(NetworkClientSocket) NetworkClientSocket::NetworkClientSocket(ClientID client_id) { diff --git a/src/network/core/tcp_game.h b/src/network/core/tcp_game.h index bfc82f17f..d01a3d9a8 100644 --- a/src/network/core/tcp_game.h +++ b/src/network/core/tcp_game.h @@ -12,6 +12,7 @@ #include "os_abstraction.h" #include "tcp.h" #include "packet.h" +#include "../../core/pool.hpp" /** * Enum with all types of UDP packets. @@ -76,12 +77,12 @@ enum ClientStatus { STATUS_ACTIVE, ///< The client is active within in the game }; - class NetworkClientSocket; -DECLARE_OLD_POOL(NetworkClientSocket, NetworkClientSocket, NCI_BITS_PER_POOL_BLOCK, MAX_CLIENT_SLOTS >> NCI_BITS_PER_POOL_BLOCK); +typedef Pool NetworkClientSocketPool; +extern NetworkClientSocketPool _networkclientsocket_pool; /** Base socket handler for all TCP sockets */ -class NetworkClientSocket : public PoolItem, public NetworkTCPSocketHandler { +class NetworkClientSocket : public NetworkClientSocketPool::PoolItem<&_networkclientsocket_pool>, public NetworkTCPSocketHandler { /* TODO: rewrite into a proper class */ private: NetworkClientInfo *info; ///< Client info related to this socket @@ -100,7 +101,6 @@ public: NetworkClientSocket(ClientID client_id = INVALID_CLIENT_ID); ~NetworkClientSocket(); - inline bool IsValid() const { return this->IsConnected(); } inline void SetInfo(NetworkClientInfo *info) { assert(info != NULL && this->info == NULL); this->info = info; } inline NetworkClientInfo *GetInfo() const { return this->info; } -- cgit v1.2.3-54-g00ecf