OpenTTD Source 20260208-master-g43af8e94d0
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
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"
18
22
24struct NetworkClientInfo : NetworkClientInfoPool::PoolItem<&_networkclientinfo_pool> {
26 std::string client_name{};
27 std::string public_key{};
28 CompanyID client_playas = CompanyID::Invalid();
29 TimerGameEconomy::Date join_date{};
30
38
40
41 bool CanJoinCompany(CompanyID company_id) const;
42};
43
44#endif /* NETWORK_BASE_H */
Wrapper for network addresses.
Types related to companies.
NetworkClientInfoPool _networkclientinfo_pool("NetworkClientInfo")
Make sure both pools have the same size.
Pool< NetworkClientInfo, ClientPoolID, 8, PoolType::NetworkClient > NetworkClientInfoPool
Type for the pool with client information.
Types used for networking.
ClientID
'Unique' identifier to be given to clients
@ INVALID_CLIENT_ID
Client is not part of anything.
PoolID< uint16_t, struct ClientPoolIDTag, MAX_CLIENTS+1, 0xFFFF > ClientPoolID
Indices into the client related pools.
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
Container for all information known about a client.
static NetworkClientInfo * GetByClientID(ClientID client_id)
Return the CI given it's client-identifier.
Definition network.cpp:117
TimerGameEconomy::Date join_date
Gamedate the client has joined.
~NetworkClientInfo()
Basically a client is leaving us right now.
Definition network.cpp:106
bool CanJoinCompany(CompanyID company_id) const
Returns whether the given company can be joined by this client.
Definition network.cpp:131
CompanyID client_playas
As which company is this client playing (CompanyID).
ClientID client_id
Client identifier (same as ClientState->client_id).
NetworkClientInfo(ClientPoolID index, ClientID client_id=INVALID_CLIENT_ID)
Create a new client.
std::string client_name
Name of the client.
std::string public_key
The public key of the client.
Base class for all pools.
Definition of the game-economy-timer.