2009-08-21 22:21:05 +02:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-12-23 12:06:52 +01:00
|
|
|
/** @file network_base.h Base core network types and some helper functions to access them. */
|
|
|
|
|
|
|
|
#ifndef NETWORK_BASE_H
|
|
|
|
#define NETWORK_BASE_H
|
|
|
|
|
|
|
|
#include "network_type.h"
|
2010-01-15 17:41:15 +01:00
|
|
|
#include "core/address.h"
|
2009-05-22 17:39:22 +02:00
|
|
|
#include "../core/pool_type.hpp"
|
2010-01-15 17:41:15 +01:00
|
|
|
#include "../company_type.h"
|
2024-01-22 15:04:34 +01:00
|
|
|
#include "../timer/timer_game_economy.h"
|
2008-12-23 12:06:52 +01:00
|
|
|
|
2011-05-04 22:24:23 +02:00
|
|
|
/** Type for the pool with client information. */
|
2011-02-20 00:05:47 +01:00
|
|
|
typedef Pool<NetworkClientInfo, ClientIndex, 8, MAX_CLIENT_SLOTS, PT_NCLIENT> NetworkClientInfoPool;
|
2009-05-22 17:13:50 +02:00
|
|
|
extern NetworkClientInfoPool _networkclientinfo_pool;
|
2008-12-23 21:52:27 +01:00
|
|
|
|
2011-05-04 22:24:23 +02:00
|
|
|
/** Container for all information known about a client. */
|
2009-05-22 17:13:50 +02:00
|
|
|
struct NetworkClientInfo : NetworkClientInfoPool::PoolItem<&_networkclientinfo_pool> {
|
2021-05-15 08:31:45 +02:00
|
|
|
ClientID client_id; ///< Client identifier (same as ClientState->client_id)
|
|
|
|
std::string client_name; ///< Name of the client
|
2024-03-23 11:53:08 +01:00
|
|
|
std::string public_key; ///< The public key of the client.
|
2021-05-15 08:31:45 +02:00
|
|
|
CompanyID client_playas; ///< As which company is this client playing (CompanyID)
|
2024-01-22 15:04:34 +01:00
|
|
|
TimerGameEconomy::Date join_date; ///< Gamedate the client has joined
|
2008-12-23 12:06:52 +01:00
|
|
|
|
2011-05-04 22:24:23 +02:00
|
|
|
/**
|
|
|
|
* Create a new client.
|
|
|
|
* @param client_id The unique identifier of the client.
|
|
|
|
*/
|
2008-12-23 21:52:27 +01:00
|
|
|
NetworkClientInfo(ClientID client_id = INVALID_CLIENT_ID) : client_id(client_id) {}
|
2009-10-07 19:36:33 +02:00
|
|
|
~NetworkClientInfo();
|
2011-04-22 17:54:16 +02:00
|
|
|
|
|
|
|
static NetworkClientInfo *GetByClientID(ClientID client_id);
|
2024-03-23 13:38:37 +01:00
|
|
|
|
|
|
|
bool CanJoinCompany(CompanyID company_id) const;
|
2008-12-23 12:06:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* NETWORK_BASE_H */
|