From bd41382233ab671cd65841bacd03235101f0baa4 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Mon, 6 Dec 2021 09:00:57 +0100 Subject: [PATCH] Application::TSettings: Improve default initialisation --- include/Common.h | 49 +++++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/include/Common.h b/include/Common.h index 79d53f8..7b0322b 100644 --- a/include/Common.h +++ b/include/Common.h @@ -35,38 +35,23 @@ class Application final { public: // types struct TSettings { - TSettings() noexcept - : ServerName("BeamMP Server") - , ServerDesc("BeamMP Default Description") - , Resource("Resources") - , MapName("/levels/gridmap_v2/info.json") - , SSLKeyPath("./.ssl/HttpServer/key.pem") - , SSLCertPath("./.ssl/HttpServer/cert.pem") - , HTTPServerPort(8080) - , MaxPlayers(10) - , Private(true) - , MaxCars(1) - , DebugModeEnabled(false) - , Port(30814) - , SendErrors(true) - , SendErrorsMessageEnabled(true) { } - std::string ServerName; - std::string ServerDesc; - std::string Resource; - std::string MapName; - std::string Key; - std::string SSLKeyPath; - std::string SSLCertPath; - int MaxPlayers; - bool Private; - int MaxCars; - bool DebugModeEnabled; - int Port; - std::string CustomIP; - bool SendErrors; - bool SendErrorsMessageEnabled; + std::string ServerName { "BeamMP Server" }; + std::string ServerDesc { "BeamMP Default Description" }; + std::string Resource { "Resources" }; + std::string MapName { "/levels/gridmap_v2/info.json" }; + std::string Key {}; + std::string SSLKeyPath { "./.ssl/HttpServer/key.pem" }; + std::string SSLCertPath { "./.ssl/HttpServer/cert.pem" }; + int MaxPlayers { 10 }; + bool Private { true }; + int MaxCars { 1 }; + bool DebugModeEnabled { false }; + int Port { 30814 }; + std::string CustomIP {}; + bool SendErrors { true }; + bool SendErrorsMessageEnabled { true }; + int HTTPServerPort { 8080 }; [[nodiscard]] bool HasCustomIP() const { return !CustomIP.empty(); } - int HTTPServerPort; }; using TShutdownHandler = std::function; @@ -173,7 +158,7 @@ void RegisterThread(const std::string& str); if (Application::Settings.DebugModeEnabled) { \ Application::Console().Write(_this_location + std::string("[EVENT] ") + (x)); \ } \ - }while(false) + } while (false) // for those times when you just need to ignore something :^) // explicity disables a [[nodiscard]] warning #define beammp_ignore(x) (void)x