OpenTTD

network_base.h
Go to the documentation of this file.
1 /* $Id: network_base.h 22423 2011-05-04 20:24:23Z rubidium $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
9
12 #ifndef NETWORK_BASE_H
13 #define NETWORK_BASE_H
14
15 #ifdef ENABLE_NETWORK
16
17 #include "network_type.h"
18 #include "core/address.h"
19 #include "../core/pool_type.hpp"
20 #include "../company_type.h"
21
23 typedef Pool<NetworkClientInfo, ClientIndex, 8, MAX_CLIENT_SLOTS, PT_NCLIENT> NetworkClientInfoPool;
24 extern NetworkClientInfoPool _networkclientinfo_pool;
25
27 struct NetworkClientInfo : NetworkClientInfoPool::PoolItem<&_networkclientinfo_pool> {
28 ClientID client_id;
29 char client_name[NETWORK_CLIENT_NAME_LENGTH];
30 byte client_lang;
31 CompanyID client_playas;
32 Date join_date;
33
38 NetworkClientInfo(ClientID client_id = INVALID_CLIENT_ID) : client_id(client_id) {}
39 ~NetworkClientInfo();
40
41 static NetworkClientInfo *GetByClientID(ClientID client_id);
42 };
43
49 #define FOR_ALL_CLIENT_INFOS_FROM(var, start) FOR_ALL_ITEMS_FROM(NetworkClientInfo, clientinfo_index, var, start)
50
55 #define FOR_ALL_CLIENT_INFOS(var) FOR_ALL_CLIENT_INFOS_FROM(var, 0)
56
57 #endif /* ENABLE_NETWORK */
58 #endif /* NETWORK_BASE_H */
NETWORK_CLIENT_NAME_LENGTH
static const uint NETWORK_CLIENT_NAME_LENGTH
The maximum length of a client&#39;s name, in bytes including &#39;\0&#39;.
Definition: config.h:49
NetworkClientInfo
Container for all information known about a client.
Definition: network_base.h:27
NetworkClientInfo::~NetworkClientInfo
~NetworkClientInfo()
Basically a client is leaving us right now.
Definition: network.cpp:115
NetworkClientInfo::client_id
ClientID client_id
Client identifier (same as ClientState->client_id)
Definition: network_base.h:28
NetworkClientInfoPool
Pool< NetworkClientInfo, ClientIndex, 8, MAX_CLIENT_SLOTS, PT_NCLIENT > NetworkClientInfoPool
Type for the pool with client information.
Definition: network_base.h:23
NetworkClientInfo::client_playas
CompanyID client_playas
As which company is this client playing (CompanyID)
Definition: network_base.h:31
NetworkClientInfo::client_name
char client_name[NETWORK_CLIENT_NAME_LENGTH]
Name of the client.
Definition: network_base.h:29
address.h
Wrapper for network addresses.
Pool::PoolItem
Base class for all PoolItems.
Definition: pool_type.hpp:146
NetworkClientInfo::join_date
Date join_date
Gamedate the client has joined.
Definition: network_base.h:32
Pool
Base class for all pools.
Definition: pool_type.hpp:83
network_type.h
Types used for networking.
INVALID_CLIENT_ID
Client is not part of anything.
Definition: network_type.h:44
ClientID
ClientID
&#39;Unique&#39; identifier to be given to clients
Definition: network_type.h:43
NetworkClientInfo::NetworkClientInfo
NetworkClientInfo(ClientID client_id=INVALID_CLIENT_ID)
Create a new client.
Definition: network_base.h:38
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:16
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:20
NetworkClientInfo::GetByClientID
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it&#39;s client-identifier.
Definition: network.cpp:126
NetworkClientInfo::client_lang
byte client_lang
The language of the client.
Definition: network_base.h:30
_networkclientinfo_pool
NetworkClientInfoPool _networkclientinfo_pool
The pool with client information.