OpenTTD Source 20241224-master-gf74b0cf984
config.cpp
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 <http://www.gnu.org/licenses/>.
6 */
7
12#include "../../stdafx.h"
13
14#include "../../string_func.h"
15
16#include "../../safeguards.h"
17
24static const char *GetEnv(const char *variable, const char *fallback)
25{
26 const char *value = std::getenv(variable);
27 return StrEmpty(value) ? fallback : value;
28}
29
36{
37 return GetEnv("OTTD_COORDINATOR_CS", "coordinator.openttd.org");
38}
39
46{
47 return GetEnv("OTTD_STUN_CS", "stun.openttd.org");
48}
49
56{
57 return GetEnv("OTTD_CONTENT_SERVER_CS", "content.openttd.org");
58}
59
66{
67 return GetEnv("OTTD_CONTENT_MIRROR_URI", "https://binaries.openttd.org/bananas");
68}
69
76{
77 return GetEnv("OTTD_SURVEY_URI", "https://survey-participate.openttd.org/");
78}
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),...
Definition config.cpp:24
const char * NetworkStunConnectionString()
Get the connection string for the STUN server from the environment variable OTTD_STUN_CS,...
Definition config.cpp:45
const char * NetworkContentMirrorUriString()
Get the URI string for the content mirror from the environment variable OTTD_CONTENT_MIRROR_URI,...
Definition config.cpp:65
const char * NetworkContentServerConnectionString()
Get the connection string for the content server from the environment variable OTTD_CONTENT_SERVER_CS...
Definition config.cpp:55
const char * NetworkCoordinatorConnectionString()
Get the connection string for the game coordinator from the environment variable OTTD_COORDINATOR_CS,...
Definition config.cpp:35
const char * NetworkSurveyUriString()
Get the URI string for the survey from the environment variable OTTD_SURVEY_URI, or when it has not b...
Definition config.cpp:75
bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition string_func.h:57