mirror of https://github.com/OpenTTD/OpenTTD
Codechange: use std::string_view for connection/URI strings
parent
a5812a45f8
commit
42f0aa24f6
|
@ -21,7 +21,7 @@
|
|||
* @param fallback The fallback in case the environment variable is not set.
|
||||
* @return The environment value, or when that does not exist the given fallback value.
|
||||
*/
|
||||
static const char *GetEnv(const char *variable, const char *fallback)
|
||||
static std::string_view GetEnv(const char *variable, std::string_view fallback)
|
||||
{
|
||||
const char *value = std::getenv(variable);
|
||||
return StrEmpty(value) ? fallback : value;
|
||||
|
@ -32,7 +32,7 @@ static const char *GetEnv(const char *variable, const char *fallback)
|
|||
* or when it has not been set a hard coded default DNS hostname of the production server.
|
||||
* @return The game coordinator's connection string.
|
||||
*/
|
||||
const char *NetworkCoordinatorConnectionString()
|
||||
std::string_view NetworkCoordinatorConnectionString()
|
||||
{
|
||||
return GetEnv("OTTD_COORDINATOR_CS", "coordinator.openttd.org");
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ const char *NetworkCoordinatorConnectionString()
|
|||
* or when it has not been set a hard coded default DNS hostname of the production server.
|
||||
* @return The STUN server's connection string.
|
||||
*/
|
||||
const char *NetworkStunConnectionString()
|
||||
std::string_view NetworkStunConnectionString()
|
||||
{
|
||||
return GetEnv("OTTD_STUN_CS", "stun.openttd.org");
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ const char *NetworkStunConnectionString()
|
|||
* or when it has not been set a hard coded default DNS hostname of the production server.
|
||||
* @return The content server's connection string.
|
||||
*/
|
||||
const char *NetworkContentServerConnectionString()
|
||||
std::string_view NetworkContentServerConnectionString()
|
||||
{
|
||||
return GetEnv("OTTD_CONTENT_SERVER_CS", "content.openttd.org");
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ const char *NetworkContentServerConnectionString()
|
|||
* or when it has not been set a hard coded URI of the production server.
|
||||
* @return The content mirror's URI string.
|
||||
*/
|
||||
const char *NetworkContentMirrorUriString()
|
||||
std::string_view NetworkContentMirrorUriString()
|
||||
{
|
||||
return GetEnv("OTTD_CONTENT_MIRROR_URI", "https://binaries.openttd.org/bananas");
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ const char *NetworkContentMirrorUriString()
|
|||
* or when it has not been set a hard coded URI of the production server.
|
||||
* @return The survey's URI string.
|
||||
*/
|
||||
const char *NetworkSurveyUriString()
|
||||
std::string_view NetworkSurveyUriString()
|
||||
{
|
||||
return GetEnv("OTTD_SURVEY_URI", "https://survey-participate.openttd.org/");
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
#ifndef NETWORK_CORE_CONFIG_H
|
||||
#define NETWORK_CORE_CONFIG_H
|
||||
|
||||
const char *NetworkCoordinatorConnectionString();
|
||||
const char *NetworkStunConnectionString();
|
||||
const char *NetworkContentServerConnectionString();
|
||||
const char *NetworkContentMirrorUriString();
|
||||
const char *NetworkSurveyUriString();
|
||||
std::string_view NetworkCoordinatorConnectionString();
|
||||
std::string_view NetworkStunConnectionString();
|
||||
std::string_view NetworkContentServerConnectionString();
|
||||
std::string_view NetworkContentMirrorUriString();
|
||||
std::string_view NetworkSurveyUriString();
|
||||
|
||||
static const uint16_t NETWORK_COORDINATOR_SERVER_PORT = 3976; ///< The default port of the Game Coordinator server (TCP)
|
||||
static const uint16_t NETWORK_STUN_SERVER_PORT = 3975; ///< The default port of the STUN server (TCP)
|
||||
|
|
Loading…
Reference in New Issue