OpenTTD GameScript API  20240425-master-ge8d25d68b9
Public Types | Static Public Member Functions
GSClient Class Reference

Class that handles all client related functions. More...

Inheritance diagram for GSClient:

Public Types

enum  ClientID : uint32_t {
  CLIENT_INVALID,
  CLIENT_SERVER,
  CLIENT_FIRST
}
 Different constants related to ClientID. More...
 

Static Public Member Functions

static ClientID ResolveClientID (ClientID client)
 Resolves the given client id to the correct index for the client. More...
 
static std::optional< std::string > GetName (ClientID client)
 Get the name of the given client. More...
 
static GSCompany::CompanyID GetCompany (ClientID client)
 Get the company in which the given client is playing. More...
 
static GSDate::Date GetJoinDate (ClientID client)
 Get the game date when the given client has joined. More...
 

Detailed Description

Class that handles all client related functions.

Member Enumeration Documentation

◆ ClientID

enum GSClient::ClientID : uint32_t

Different constants related to ClientID.

Enumerator
CLIENT_INVALID 

Client is not part of anything.

CLIENT_SERVER 

Servers always have this ID.

CLIENT_FIRST 

The first client ID.

Member Function Documentation

◆ GetCompany()

static GSCompany::CompanyID GSClient::GetCompany ( ClientID  client)
static

Get the company in which the given client is playing.

Parameters
clientThe client to get company for.
Precondition
ResolveClientID(client) != CLIENT_INVALID.
Returns
The company in which client is playing or COMPANY_SPECTATOR.

◆ GetJoinDate()

static GSDate::Date GSClient::GetJoinDate ( ClientID  client)
static

Get the game date when the given client has joined.

Parameters
clientThe client to get joining date for.
Precondition
ResolveClientID(client) != CLIENT_INVALID.
Returns
The date when client has joined.

◆ GetName()

static std::optional<std::string> GSClient::GetName ( ClientID  client)
static

Get the name of the given client.

Parameters
clientThe client to get the name for.
Precondition
ResolveClientID(client) != CLIENT_INVALID.
Returns
The name of the given client.

◆ ResolveClientID()

static ClientID GSClient::ResolveClientID ( ClientID  client)
static

Resolves the given client id to the correct index for the client.

If the client with the given id does not exist it will return CLIENT_INVALID.

Parameters
clientThe client id to resolve.
Returns
The resolved client id.