CCommandLine additions

This commit is contained in:
Kawe Mazidjatari 2022-06-24 12:10:46 +02:00
parent ef454ac126
commit 479adc4b85
3 changed files with 52 additions and 3 deletions

View File

@ -0,0 +1,9 @@
#ifndef ICOMMANDLINE_H
#define ICOMMANDLINE_H
class ICommandLine
{
void* __vftable /*VFT*/;
};
#endif // ICOMMANDLINE_H

View File

@ -8,6 +8,24 @@
#include "tier0/commandline.h"
#include "tier1/cvar.h"
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CCommandLine::CCommandLine(void)
{
m_pszCmdLine = NULL;
m_nParmCount = 0;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CCommandLine::~CCommandLine(void)
{
CleanUpParms();
delete[] m_pszCmdLine;
}
//-----------------------------------------------------------------------------
// Purpose: Create a command line from the passed in string
// Note that if you pass in a @filename, then the routine will read settings
@ -126,8 +144,18 @@ void CCommandLine::SetParm(int nIndex, char const* pParm)
CallVFunc<void>(index, this, nIndex, pParm);
}
///////////////////////////////////////////////////////////////////////////////
CCommandLine* g_pCmdLine = nullptr;
//-----------------------------------------------------------------------------
// Individual command line arguments
//-----------------------------------------------------------------------------
void CCommandLine::CleanUpParms(void)
{
for (int i = 0; i < m_nParmCount; ++i)
{
delete[] m_ppParms[i];
m_ppParms[i] = NULL;
}
m_nParmCount = 0;
}
//-----------------------------------------------------------------------------
// Instance singleton and expose interface to rest of code
@ -136,3 +164,6 @@ CCommandLine* CommandLine(void)
{
return g_pCmdLine;
}
///////////////////////////////////////////////////////////////////////////////
CCommandLine* g_pCmdLine = nullptr;

View File

@ -4,21 +4,30 @@
class CCommandLine : public ICommandLine // VTABLE @0x141369C78 in R5pc_r5launch_N1094_CL456479_2019_10_30_05_20_PM
{
public:
CCommandLine(void);
~CCommandLine(void);
void CreateCmdLine(const char* pszCommandline);
void CreateCmdLine(int argc, char** argv);
void CreatePool(void* pMem);
const char* GetCmdLine(void);
const char* CheckParm(const char* psz, const char** ppszValue = NULL);
void RemoveParm(const char* pszParm);
void AppendParm(const char* pszParm, const char* pszValues);
const char* ParmValue(const char* psz, const char* pDefaultVal = NULL);
int ParmValue(const char* psz, int nDefaultVal);
float ParmValue(const char* psz, float flDefaultVal);
int ParmCount(void);
int FindParm(const char* psz);
const char* GetParm(int nIndex);
void SetParm(int nIndex, char const* pParm);
void CleanUpParms(void);
private:
enum
{
@ -27,7 +36,7 @@ private:
};
char* m_pszCmdLine;
char m_Pad[0x18];
char m_Pad[0x18]; // <-- thread/mutex stuff.
int m_nParmCount;
char* m_ppParms[MAX_PARAMETERS];
};