mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 15:41:15 +00:00
(svn r14724) -Codechange: move some NetworkClientSocket related function/definitions closer together.
This commit is contained in:
parent
9476a49763
commit
52fb6b7d7c
@ -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 */
|
||||
|
@ -122,10 +122,6 @@ extern uint8 _network_advertise_retries;
|
||||
// following externs are instantiated at network.cpp
|
||||
extern CommandPacket *_local_command_queue;
|
||||
|
||||
// Here we keep track of the clients
|
||||
// (and the client uses [0] for his own communication)
|
||||
extern NetworkClientSocket _clients[MAX_CLIENTS];
|
||||
|
||||
void NetworkTCPQueryServer(const char* host, unsigned short port);
|
||||
|
||||
void NetworkAddServer(const char *b);
|
||||
@ -147,8 +143,6 @@ NetworkClientSocket *NetworkFindClientStateFromClientID(ClientID client_id);
|
||||
char* GetNetworkErrorMsg(char* buf, NetworkErrorCode err, const char* last);
|
||||
bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH]);
|
||||
|
||||
#define GetNetworkClientSocket(i) (&_clients[i])
|
||||
|
||||
// Macros to make life a bit more easier
|
||||
#define DEF_CLIENT_RECEIVE_COMMAND(type) NetworkRecvStatus NetworkPacketReceive_ ## type ## _command(Packet *p)
|
||||
#define DEF_CLIENT_SEND_COMMAND(type) void NetworkPacketSend_ ## type ## _command()
|
||||
@ -160,7 +154,5 @@ bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH]);
|
||||
#define SEND_COMMAND(type) NetworkPacketSend_ ## type ## _command
|
||||
#define RECEIVE_COMMAND(type) NetworkPacketReceive_ ## type ## _command
|
||||
|
||||
#define FOR_ALL_CLIENT_SOCKETS(cs) for (cs = _clients; cs != endof(_clients) && cs->IsConnected(); cs++)
|
||||
|
||||
#endif /* ENABLE_NETWORK */
|
||||
#endif /* NETWORK_INTERNAL_H */
|
||||
|
Loading…
Reference in New Issue
Block a user