OpenTTD Source: src/network/core/config.cpp Source File

OpenTTD Source 12.2

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 <cstdlib>
15 #include "../../string_func.h"
16
17 #include "../../safeguards.h"
18
25 static const char *GetEnv(const char *variable, const char *fallback)
26 {
27 const char *value = std::getenv(variable);
28 return StrEmpty(value) ? fallback : value;
29 }
30
36 const char *NetworkCoordinatorConnectionString()
37 {
38 return GetEnv("OTTD_COORDINATOR_CS", "coordinator.openttd.org");
39 }
40
46 const char *NetworkStunConnectionString()
47 {
48 return GetEnv("OTTD_STUN_CS", "stun.openttd.org");
49 }
50
56 const char *NetworkContentServerConnectionString()
57 {
58 return GetEnv("OTTD_CONTENT_SERVER_CS", "content.openttd.org");
59 }
60
66 const char *NetworkContentMirrorConnectionString()
67 {
68 return GetEnv("OTTD_CONTENT_MIRROR_CS", "binaries.openttd.org");
69 }
NetworkContentMirrorConnectionString
const char * NetworkContentMirrorConnectionString()
Get the connection string for the content mirror from the environment variable OTTD_CONTENT_MIRROR_CS...
Definition: config.cpp:66
NetworkCoordinatorConnectionString
const char * NetworkCoordinatorConnectionString()
Get the connection string for the game coordinator from the environment variable OTTD_COORDINATOR_CS,...
Definition: config.cpp:36
NetworkStunConnectionString
const char * NetworkStunConnectionString()
Get the connection string for the STUN server from the environment variable OTTD_STUN_CS,...
Definition: config.cpp:46
NetworkContentServerConnectionString
const char * NetworkContentServerConnectionString()
Get the connection string for the content server from the environment variable OTTD_CONTENT_SERVER_CS...
Definition: config.cpp:56
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:64
GetEnv
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:25