OpenTTD Source  20240919-master-gdf0233f4c2
ServerAddress Class Reference

Address to a game server. More...

#include <address.h>

Static Public Member Functions

static ServerAddress Parse (const std::string &connection_string, uint16_t default_port, CompanyID *company_id=nullptr)
 Convert a string containing either "hostname", "hostname:port" or invite code to a ServerAddress, where the string can be postfixed with "#company" to indicate the requested company. More...
 

Data Fields

ServerAddressType type
 The type of this ServerAddress.
 
std::string connection_string
 The connection string for this ServerAddress.
 

Private Member Functions

 ServerAddress (ServerAddressType type, const std::string &connection_string)
 Create a new ServerAddress object. More...
 

Detailed Description

Address to a game server.

This generalises addresses which are based on different identifiers.

Definition at line 196 of file address.h.

Constructor & Destructor Documentation

◆ ServerAddress()

ServerAddress::ServerAddress ( ServerAddressType  type,
const std::string &  connection_string 
)
inlineprivate

Create a new ServerAddress object.

Please use ServerAddress::Parse() instead of calling this directly.

Parameters
typeThe type of the ServerAdress.
connection_stringThe connection_string that belongs to this ServerAddress type.

Definition at line 206 of file address.h.

Member Function Documentation

◆ Parse()

ServerAddress ServerAddress::Parse ( const std::string &  connection_string,
uint16_t  default_port,
CompanyID company_id = nullptr 
)
static

Convert a string containing either "hostname", "hostname:port" or invite code to a ServerAddress, where the string can be postfixed with "#company" to indicate the requested company.

Parameters
connection_stringThe string to parse.
default_portThe default port to set port to if not in connection_string.
companyPointer to the company variable to set iff indicated.
Returns
A valid ServerAddress of the parsed information.

Definition at line 450 of file address.cpp.

Referenced by NetworkClientConnectGame(), and NetworkGameListAddItem().


The documentation for this class was generated from the following files: