From 088e2d80c7dd589110d4828c3f9a1aa3043ca563 Mon Sep 17 00:00:00 2001 From: Nick Hastings Date: Sun, 2 Apr 2023 10:15:58 -0400 Subject: [PATCH] Do s1/s2 split on GetCommandLineValue --- core/provider/provider_base.cpp | 20 -------------------- core/provider/provider_base.h | 2 +- core/provider/source/provider_source.cpp | 20 ++++++++++++++++++++ core/provider/source/provider_source.h | 1 + core/provider/source2/provider_source2.cpp | 5 +++++ core/provider/source2/provider_source2.h | 1 + 6 files changed, 28 insertions(+), 21 deletions(-) diff --git a/core/provider/provider_base.cpp b/core/provider/provider_base.cpp index 0776190..d8e8947 100644 --- a/core/provider/provider_base.cpp +++ b/core/provider/provider_base.cpp @@ -61,26 +61,6 @@ bool BaseProvider::IsSourceEngineBuildCompatible(int build) || build == SOURCE_ENGINE_EPISODEONE); } -const char *BaseProvider::GetCommandLineValue(const char *key, const char *defval) -{ - if (key[0] == '-' || key[0] == '+') - { - return CommandLine()->ParmValue(key, defval); - } - else if (icvar) - { - const char *val; - if ((val = icvar->GetCommandLineValue(key)) == NULL) - { - return defval; - } - - return val; - } - - return NULL; -} - int BaseProvider::TryServerGameDLL(const char *iface) { if (strncmp(iface, "ServerGameDLL", 13) != 0) diff --git a/core/provider/provider_base.h b/core/provider/provider_base.h index 9abdff4..7e7e7ed 100644 --- a/core/provider/provider_base.h +++ b/core/provider/provider_base.h @@ -58,6 +58,7 @@ public: // Must implement virtual void GetGamePath(char *pszBuffer, int len) override = 0; virtual const char *GetGameDescription() override = 0; virtual bool ProcessVDF(const char* file, char path[], size_t path_len, char alias[], size_t alias_len) override = 0; + virtual const char* GetCommandLineValue(const char* key, const char* defval) override = 0; virtual void ConsolePrint(const char* msg) override = 0; virtual void ClientConsolePrint(edict_t* client, const char* msg) override = 0; virtual void ServerCommand(const char* cmd) override = 0; @@ -77,7 +78,6 @@ public: // May implement/override (stubbed) public: // May implement/override virtual bool IsSourceEngineBuildCompatible(int build) override; virtual bool LogMessage(const char *buffer) override; - virtual const char *GetCommandLineValue(const char *key, const char *defval) override; virtual void DisplayError(const char *fmt, ...) override; virtual void DisplayWarning(const char *fmt, ...) override; virtual void DisplayDevMsg(const char* fmt, ...) override; diff --git a/core/provider/source/provider_source.cpp b/core/provider/source/provider_source.cpp index c678eef..ebec087 100644 --- a/core/provider/source/provider_source.cpp +++ b/core/provider/source/provider_source.cpp @@ -329,6 +329,26 @@ void SourceProvider::ConsolePrint(const char* str) #endif } +const char* SourceProvider::GetCommandLineValue(const char* key, const char* defval) +{ + if (key[0] == '-' || key[0] == '+') + { + return CommandLine()->ParmValue(key, defval); + } + else if (icvar) + { + const char* val; + if ((val = icvar->GetCommandLineValue(key)) == NULL) + { + return defval; + } + + return val; + } + + return NULL; +} + void SourceProvider::ClientConsolePrint(edict_t* pEdict, const char* message) { engine->ClientPrintf(pEdict, message); diff --git a/core/provider/source/provider_source.h b/core/provider/source/provider_source.h index f09532a..425e6cc 100644 --- a/core/provider/source/provider_source.h +++ b/core/provider/source/provider_source.h @@ -43,6 +43,7 @@ public: // BaseProvider virtual const char* GetEngineDescription() const override; virtual void GetGamePath(char* pszBuffer, int len) override; virtual const char* GetGameDescription() override; + virtual const char* GetCommandLineValue(const char* key, const char* defval) override; virtual void ConsolePrint(const char* msg) override; virtual void ClientConsolePrint(edict_t* client, const char* msg) override; virtual void ServerCommand(const char* cmd) override; diff --git a/core/provider/source2/provider_source2.cpp b/core/provider/source2/provider_source2.cpp index d6dd8cd..34eb0e1 100644 --- a/core/provider/source2/provider_source2.cpp +++ b/core/provider/source2/provider_source2.cpp @@ -226,6 +226,11 @@ bool Source2Provider::Hook_AllowDedicatedServers(EUniverse universe) const } #endif +const char* Source2Provider::GetCommandLineValue(const char* key, const char* defval) +{ + return CommandLine()->ParmValue(key, defval); +} + void Source2Provider::ConsolePrint(const char* str) { ConMsg("%s", str); diff --git a/core/provider/source2/provider_source2.h b/core/provider/source2/provider_source2.h index bdb00ad..a26bebe 100644 --- a/core/provider/source2/provider_source2.h +++ b/core/provider/source2/provider_source2.h @@ -50,6 +50,7 @@ public: virtual const char* GetEngineDescription() const override; virtual void GetGamePath(char* pszBuffer, int len) override; virtual const char* GetGameDescription() override; + virtual const char* GetCommandLineValue(const char* key, const char* defval) override; virtual void ConsolePrint(const char* msg) override; virtual void ClientConsolePrint(edict_t* client, const char* msg) override; virtual void ServerCommand(const char* cmd) override;