mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Move all classes deriving from ConCommandBase to a single file, and split out CCommand, CCvar, CCvarUtilities etc to their own files. This makes it possible to use CCommand and stuff in external tools without linker errors/warnings.
81 lines
2.1 KiB
C++
81 lines
2.1 KiB
C++
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||
//
|
||
// Purpose:
|
||
//
|
||
// $Workfile: $
|
||
// $Date: $
|
||
//
|
||
//-----------------------------------------------------------------------------
|
||
// $NoKeywords: $
|
||
//===========================================================================//
|
||
|
||
#ifndef TIER1_CMD_H
|
||
#define TIER1_CMD_H
|
||
|
||
#include "tier1/characterset.h"
|
||
|
||
//-----------------------------------------------------------------------------
|
||
// Purpose: Command buffer context
|
||
//-----------------------------------------------------------------------------
|
||
enum class ECommandTarget_t : int
|
||
{
|
||
CBUF_FIRST_PLAYER = 0,
|
||
CBUF_LAST_PLAYER = MAX_SPLITSCREEN_CLIENTS - 1,
|
||
CBUF_SERVER = CBUF_LAST_PLAYER + 1,
|
||
|
||
CBUF_COUNT,
|
||
};
|
||
|
||
//-----------------------------------------------------------------------------
|
||
// Sources of console commands
|
||
//-----------------------------------------------------------------------------
|
||
enum class cmd_source_t : int
|
||
{
|
||
kCommandSrcCode,
|
||
kCommandSrcClientCmd,
|
||
kCommandSrcUserInput,
|
||
kCommandSrcNetClient,
|
||
kCommandSrcNetServer,
|
||
kCommandSrcDemoFile,
|
||
kCommandSrcInvalid = -1
|
||
};
|
||
|
||
//-----------------------------------------------------------------------------
|
||
// Purpose: Command tokenizer
|
||
//-----------------------------------------------------------------------------
|
||
class CCommand
|
||
{
|
||
private:
|
||
enum
|
||
{
|
||
COMMAND_MAX_ARGC = 64,
|
||
COMMAND_MAX_LENGTH = 512,
|
||
};
|
||
|
||
public:
|
||
CCommand();
|
||
CCommand(int nArgC, const char** ppArgV, cmd_source_t source);
|
||
bool Tokenize(const char* pCommand, cmd_source_t source = cmd_source_t::kCommandSrcCode, characterset_t* pBreakSet = nullptr);
|
||
|
||
int64_t ArgC(void) const;
|
||
const char** ArgV(void) const;
|
||
const char* ArgS(void) const;
|
||
const char* GetCommandString(void) const;
|
||
const char* Arg(int nIndex) const;
|
||
const char* operator[](int nIndex) const;
|
||
|
||
void Reset();
|
||
int MaxCommandLength(void) const;
|
||
bool HasOnlyDigits(int nIndex) const;
|
||
|
||
private:
|
||
cmd_source_t m_nQueuedVal;
|
||
int m_nArgc;
|
||
int64_t m_nArgv0Size;
|
||
char m_pArgSBuffer[COMMAND_MAX_LENGTH];
|
||
char m_pArgvBuffer[COMMAND_MAX_LENGTH];
|
||
const char* m_ppArgv[COMMAND_MAX_ARGC];
|
||
};
|
||
|
||
#endif // TIER1_CMD_H
|