OpenTTD Source  20241121-master-g67a0fccfad
config.cpp File Reference

Configuration of the connection strings for network stuff using environment variables. More...

#include "../../stdafx.h"
#include "../../string_func.h"
#include "../../safeguards.h"

Go to the source code of this file.

Functions

static const char * GetEnv (const char *variable, const char *fallback)
 Get the environment variable using std::getenv and when it is an empty string (or nullptr), return a fallback value instead. More...
 
const char * NetworkCoordinatorConnectionString ()
 Get the connection string for the game coordinator from the environment variable OTTD_COORDINATOR_CS, or when it has not been set a hard coded default DNS hostname of the production server. More...
 
const char * NetworkStunConnectionString ()
 Get the connection string for the STUN server from the environment variable OTTD_STUN_CS, or when it has not been set a hard coded default DNS hostname of the production server. More...
 
const char * NetworkContentServerConnectionString ()
 Get the connection string for the content server from the environment variable OTTD_CONTENT_SERVER_CS, or when it has not been set a hard coded default DNS hostname of the production server. More...
 
const char * NetworkContentMirrorUriString ()
 Get the URI string for the content mirror from the environment variable OTTD_CONTENT_MIRROR_URI, or when it has not been set a hard coded URI of the production server. More...
 
const char * NetworkSurveyUriString ()
 Get the URI string for the survey from the environment variable OTTD_SURVEY_URI, or when it has not been set a hard coded URI of the production server. More...
 

Detailed Description

Configuration of the connection strings for network stuff using environment variables.

Definition in file config.cpp.

Function Documentation

◆ GetEnv()

static const char* GetEnv ( const char *  variable,
const char *  fallback 
)
static

Get the environment variable using std::getenv and when it is an empty string (or nullptr), return a fallback value instead.

Parameters
variableThe environment variable to read from.
fallbackThe fallback in case the environment variable is not set.
Returns
The environment value, or when that does not exist the given fallback value.

Definition at line 24 of file config.cpp.

References StrEmpty().

Referenced by NetworkContentMirrorUriString(), NetworkContentServerConnectionString(), NetworkCoordinatorConnectionString(), NetworkStunConnectionString(), and NetworkSurveyUriString().

◆ NetworkContentMirrorUriString()

const char* NetworkContentMirrorUriString ( )

Get the URI string for the content mirror from the environment variable OTTD_CONTENT_MIRROR_URI, or when it has not been set a hard coded URI of the production server.

Returns
The content mirror's URI string.

Definition at line 65 of file config.cpp.

References GetEnv().

Referenced by ClientNetworkContentSocketHandler::DownloadSelectedContentHTTP().

◆ NetworkContentServerConnectionString()

const char* NetworkContentServerConnectionString ( )

Get the connection string for the content server from the environment variable OTTD_CONTENT_SERVER_CS, or when it has not been set a hard coded default DNS hostname of the production server.

Returns
The content server's connection string.

Definition at line 55 of file config.cpp.

References GetEnv().

Referenced by ClientNetworkContentSocketHandler::Connect().

◆ NetworkCoordinatorConnectionString()

const char* NetworkCoordinatorConnectionString ( )

Get the connection string for the game coordinator from the environment variable OTTD_COORDINATOR_CS, or when it has not been set a hard coded default DNS hostname of the production server.

Returns
The game coordinator's connection string.

Definition at line 35 of file config.cpp.

References GetEnv().

◆ NetworkStunConnectionString()

const char* NetworkStunConnectionString ( )

Get the connection string for the STUN server from the environment variable OTTD_STUN_CS, or when it has not been set a hard coded default DNS hostname of the production server.

Returns
The STUN server's connection string.

Definition at line 45 of file config.cpp.

References GetEnv().

Referenced by ClientNetworkStunSocketHandler::Connect().

◆ NetworkSurveyUriString()

const char* NetworkSurveyUriString ( )

Get the URI string for the survey from the environment variable OTTD_SURVEY_URI, or when it has not been set a hard coded URI of the production server.

Returns
The survey's URI string.

Definition at line 75 of file config.cpp.

References GetEnv().