mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Finish ConCommandBase/Concommand/ConVar classes
This commit is contained in:
parent
e8993d1396
commit
4cfb06ff4a
@ -126,6 +126,24 @@ void ConVar::Init(void) const
|
||||
r5net_show_debug = new ConVar("r5net_show_debug" , "1" , FCVAR_DEVELOPMENTONLY, "Shows debug output for R5Net.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Add's flags to ConVar.
|
||||
// Input : nFlags -
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConVar::AddFlags(int nFlags)
|
||||
{
|
||||
m_pParent->m_ConCommandBase.m_nFlags |= nFlags;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Removes flags from ConVar.
|
||||
// Input : nFlags -
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConVar::RemoveFlags(int nFlags)
|
||||
{
|
||||
m_ConCommandBase.m_nFlags &= ~nFlags;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns the base ConVar name.
|
||||
// Output : const char*
|
||||
@ -153,33 +171,6 @@ const char* ConVar::GetUsageText(void) const
|
||||
return m_pParent->m_ConCommandBase.m_pszUsageString;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Add's flags to ConVar.
|
||||
// Input : nFlags -
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConVar::AddFlags(int nFlags)
|
||||
{
|
||||
m_pParent->m_ConCommandBase.m_nFlags |= nFlags;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Removes flags from ConVar.
|
||||
// Input : nFlags -
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConVar::RemoveFlags(int nFlags)
|
||||
{
|
||||
m_ConCommandBase.m_nFlags &= ~nFlags;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Checks if ConVar is registered.
|
||||
// Output : bool
|
||||
//-----------------------------------------------------------------------------
|
||||
bool ConVar::IsRegistered(void) const
|
||||
{
|
||||
return m_pParent->m_ConCommandBase.m_bRegistered;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Return ConVar value as a boolean.
|
||||
// Output : bool
|
||||
@ -563,6 +554,24 @@ bool ConVar::ClampValue(float& flValue)
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Checks if ConVar is registered.
|
||||
// Output : bool
|
||||
//-----------------------------------------------------------------------------
|
||||
bool ConVar::IsRegistered(void) const
|
||||
{
|
||||
return m_pParent->m_ConCommandBase.m_bRegistered;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns true if this is a command
|
||||
// Output : bool
|
||||
//-----------------------------------------------------------------------------
|
||||
bool ConVar::IsCommand(void) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Test each ConVar query before setting the value.
|
||||
// Input : *pConVar - nFlags
|
||||
|
@ -92,14 +92,12 @@ public:
|
||||
|
||||
void Init(void) const;
|
||||
|
||||
const char* GetBaseName(void) const;
|
||||
const char* GetHelpText(void) const;
|
||||
const char* GetUsageText(void) const;
|
||||
|
||||
void AddFlags(int nFlags);
|
||||
void RemoveFlags(int nFlags);
|
||||
|
||||
bool IsRegistered(void) const;
|
||||
const char* GetBaseName(void) const;
|
||||
const char* GetHelpText(void) const;
|
||||
const char* GetUsageText(void) const;
|
||||
|
||||
bool GetBool(void) const;
|
||||
float GetFloat(void) const;
|
||||
@ -128,7 +126,10 @@ public:
|
||||
bool SetColorFromString(const char* pszValue);
|
||||
bool ClampValue(float& value);
|
||||
|
||||
bool IsRegistered(void) const;
|
||||
bool IsCommand(void) const;
|
||||
static bool IsFlagSet(ConVar* pConVar, int nFlags);
|
||||
|
||||
void ClearHostNames(void);
|
||||
|
||||
struct CVValue_t
|
||||
|
@ -133,31 +133,30 @@ void ConCommand::Init(void)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Add's flags to ConCommand.
|
||||
// Input : nFlags -
|
||||
// Purpose: Returns true if this is a command
|
||||
// Output : bool
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConCommandBase::AddFlags(int nFlags)
|
||||
bool ConCommand::IsCommand(void) const
|
||||
{
|
||||
m_nFlags |= nFlags;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Removes flags from ConCommand.
|
||||
// Input : nFlags -
|
||||
// Purpose: Returns true if this is a command
|
||||
// Output : bool
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConCommandBase::RemoveFlags(int nFlags)
|
||||
bool ConCommandBase::IsCommand(void) const
|
||||
{
|
||||
m_nFlags &= ~nFlags;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Checks if ConCommand has requested flags.
|
||||
// Input : nFlags -
|
||||
// Output : True if ConCommand has nFlags.
|
||||
// Purpose: Has this cvar been registered
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool ConCommandBase::HasFlags(int nFlags)
|
||||
bool ConCommandBase::IsRegistered(void) const
|
||||
{
|
||||
return m_nFlags & nFlags;
|
||||
return m_bRegistered;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -201,6 +200,85 @@ bool ConCommandBase::IsFlagSet(ConCommandBase* pCommandBase, int nFlags)
|
||||
return pCommandBase->HasFlags(nFlags) != 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Checks if ConCommand has requested flags.
|
||||
// Input : nFlags -
|
||||
// Output : True if ConCommand has nFlags.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool ConCommandBase::HasFlags(int nFlags)
|
||||
{
|
||||
return m_nFlags & nFlags;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Add's flags to ConCommand.
|
||||
// Input : nFlags -
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConCommandBase::AddFlags(int nFlags)
|
||||
{
|
||||
m_nFlags |= nFlags;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Removes flags from ConCommand.
|
||||
// Input : nFlags -
|
||||
//-----------------------------------------------------------------------------
|
||||
void ConCommandBase::RemoveFlags(int nFlags)
|
||||
{
|
||||
m_nFlags &= ~nFlags;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns current flags.
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int ConCommandBase::GetFlags(void) const
|
||||
{
|
||||
return m_nFlags;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Output : const ConCommandBase
|
||||
//-----------------------------------------------------------------------------
|
||||
ConCommandBase* ConCommandBase::GetNext(void) const
|
||||
{
|
||||
return m_pNext;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns the ConCommandBase help text.
|
||||
// Output : const char*
|
||||
//-----------------------------------------------------------------------------
|
||||
const char* ConCommandBase::GetHelpText(void) const
|
||||
{
|
||||
return m_pszHelpString;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Copies string using local new/delete operators
|
||||
// Input : *szFrom -
|
||||
// Output : char
|
||||
//-----------------------------------------------------------------------------
|
||||
char* ConCommandBase::CopyString(const char* szFrom) const
|
||||
{
|
||||
size_t nLen;
|
||||
char* szTo;
|
||||
|
||||
nLen = strlen(szFrom);
|
||||
if (nLen <= 0)
|
||||
{
|
||||
szTo = new char[1];
|
||||
szTo[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
szTo = new char[nLen + 1];
|
||||
strncpy(szTo, szFrom, nLen + 1);
|
||||
}
|
||||
return szTo;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void ConCommand_Attach()
|
||||
{
|
||||
|
@ -80,12 +80,21 @@ private:
|
||||
class ConCommandBase
|
||||
{
|
||||
public:
|
||||
bool HasFlags(int nFlags);
|
||||
void AddFlags(int nFlags);
|
||||
void RemoveFlags(int nFlags);
|
||||
bool HasFlags(int nFlags);
|
||||
|
||||
bool IsCommand(void) const;
|
||||
bool IsRegistered(void) const;
|
||||
static bool IsFlagSet(ConCommandBase* pCommandBase, int nFlags);
|
||||
|
||||
void* m_pConCommandBaseVTable; //0x0000
|
||||
int GetFlags(void) const;
|
||||
ConCommandBase* GetNext(void) const;
|
||||
const char* GetHelpText(void) const;
|
||||
|
||||
char* CopyString(const char* szFrom) const;
|
||||
|
||||
void* m_pConCommandBaseVTable; //0x0000
|
||||
ConCommandBase* m_pNext; //0x0008
|
||||
bool m_bRegistered; //0x0010
|
||||
char pad_0011[7]; //0x0011
|
||||
@ -100,13 +109,14 @@ public:
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: The console invoked command
|
||||
//-----------------------------------------------------------------------------
|
||||
class ConCommand
|
||||
class ConCommand : public ConCommandBase
|
||||
{
|
||||
friend class CCVar;
|
||||
public:
|
||||
ConCommand(void) {};
|
||||
ConCommand(const char* szName, const char* szHelpString, int nFlags, void* pCallback, void* pCommandCompletionCallback);
|
||||
void Init(void);
|
||||
bool IsCommand(void) const;
|
||||
|
||||
ConCommandBase m_ConCommandBase {}; //0x0000
|
||||
void* m_nNullCallBack {}; //0x0040
|
||||
|
Loading…
x
Reference in New Issue
Block a user