OpenTTD Source: src/network/network_base.h Source File

OpenTTD Source 12.0-beta1

network_base.h
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
7
10 #ifndef NETWORK_BASE_H
11 #define NETWORK_BASE_H
12
13 #include "network_type.h"
14 #include "core/address.h"
15 #include "../core/pool_type.hpp"
16 #include "../company_type.h"
17 #include "../date_type.h"
18
20 typedef Pool<NetworkClientInfo, ClientIndex, 8, MAX_CLIENT_SLOTS, PT_NCLIENT> NetworkClientInfoPool;
21 extern NetworkClientInfoPool _networkclientinfo_pool;
22
24 struct NetworkClientInfo : NetworkClientInfoPool::PoolItem<&_networkclientinfo_pool> {
25 ClientID client_id;
26 std::string client_name;
27 CompanyID client_playas;
28 Date join_date;
29
34 NetworkClientInfo(ClientID client_id = INVALID_CLIENT_ID) : client_id(client_id) {}
35 ~NetworkClientInfo();
36
37 static NetworkClientInfo *GetByClientID(ClientID client_id);
38 };
39
40 #endif /* NETWORK_BASE_H */
NetworkClientInfoPool
Pool< NetworkClientInfo, ClientIndex, 8, MAX_CLIENT_SLOTS, PT_NCLIENT > NetworkClientInfoPool
Type for the pool with client information.
Definition: network_base.h:20
INVALID_CLIENT_ID
@ INVALID_CLIENT_ID
Client is not part of anything.
Definition: network_type.h:48
NetworkClientInfo::client_name
std::string client_name
Name of the client.
Definition: network_base.h:26
NetworkClientInfo::client_playas
CompanyID client_playas
As which company is this client playing (CompanyID)
Definition: network_base.h:27
_networkclientinfo_pool
NetworkClientInfoPool _networkclientinfo_pool
Make sure both pools have the same size.
NetworkClientInfo::join_date
Date join_date
Gamedate the client has joined.
Definition: network_base.h:28
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
NetworkClientInfo::~NetworkClientInfo
~NetworkClientInfo()
Basically a client is leaving us right now.
Definition: network.cpp:101
NetworkClientInfo::GetByClientID
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
Definition: network.cpp:112
address.h
ClientID
ClientID
'Unique' identifier to be given to clients
Definition: network_type.h:47
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:14
NetworkClientInfo::NetworkClientInfo
NetworkClientInfo(ClientID client_id=INVALID_CLIENT_ID)
Create a new client.
Definition: network_base.h:34
NetworkClientInfo::client_id
ClientID client_id
Client identifier (same as ClientState->client_id)
Definition: network_base.h:25
Pool
Base class for all pools.
Definition: pool_type.hpp:81
Pool::PoolItem
Base class for all PoolItems.
Definition: pool_type.hpp:234
NetworkClientInfo
Container for all information known about a client.
Definition: network_base.h:24
network_type.h