diff options
author | rubidium <rubidium@openttd.org> | 2008-12-23 11:43:32 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-12-23 11:43:32 +0000 |
commit | e267bee098dc96f0c2b17f5794f2f330b0acaf58 (patch) | |
tree | b70aff92d1a653082f0958917d8bc936bf96bc2a /src/network/core | |
parent | 97662a0fff0a8c5099ee48f43d15ab0881493393 (diff) | |
download | openttd-e267bee098dc96f0c2b17f5794f2f330b0acaf58.tar.xz |
(svn r14724) -Codechange: move some NetworkClientSocket related function/definitions closer together.
Diffstat (limited to 'src/network/core')
-rw-r--r-- | src/network/core/tcp.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h index f720e0de0..aa5bb7c4a 100644 --- a/src/network/core/tcp.h +++ b/src/network/core/tcp.h @@ -111,6 +111,7 @@ public: Packet *Recv_Packet(NetworkRecvStatus *status); + inline bool IsValid() const { return this->IsConnected(); } inline NetworkClientInfo *GetInfo() const { extern NetworkClientSocket _clients[MAX_CLIENTS]; @@ -118,6 +119,19 @@ public: } }; +// Here we keep track of the clients +// (and the client uses [0] for his own communication) +extern NetworkClientSocket _clients[MAX_CLIENTS]; +#define GetNetworkClientSocket(i) (&_clients[i]) + +static inline bool IsValidNetworkClientSocketIndex(ClientIndex index) +{ + return (uint)index < MAX_CLIENTS && GetNetworkClientSocket(index)->IsValid(); +} + +#define FOR_ALL_CLIENT_SOCKETS_FROM(d, start) for (d = GetNetworkClientSocket(start); d != GetNetworkClientSocket(MAX_CLIENTS); d++) if (d->IsValid()) +#define FOR_ALL_CLIENT_SOCKETS(d) FOR_ALL_CLIENT_SOCKETS_FROM(d, 0) + #endif /* ENABLE_NETWORK */ #endif /* NETWORK_CORE_TCP_H */ |