1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-02-20 13:54:14 +01:00

Do s1/s2 split on GetCommandLineValue

This commit is contained in:
Nick Hastings 2023-04-02 10:15:58 -04:00
parent b727c5455e
commit 088e2d80c7
6 changed files with 28 additions and 21 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;