mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-01-09 18:48:51 +08:00
Update ICvar, ConVar & ConCommand classes
This commit is contained in:
parent
11fc23faa0
commit
e56c443c09
@ -56,24 +56,24 @@ abstract_class ICvar : public IAppSystem
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// allow_developer - Allows finding convars with FCVAR_DEVELOPMENTONLY flag
|
// allow_developer - Allows finding convars with FCVAR_DEVELOPMENTONLY flag
|
||||||
virtual ConVarID FindConVar(const char *szName, bool bAllowDeveloper = false) = 0;
|
virtual ConVarHandle FindConVar(const char *szName, bool bAllowDeveloper = false) = 0;
|
||||||
virtual ConVarID FindFirstConVar() = 0;
|
virtual ConVarHandle FindFirstConVar() = 0;
|
||||||
virtual ConVarID FindNextConVar(ConVarID previous) = 0;
|
virtual ConVarHandle FindNextConVar(ConVarHandle previous) = 0;
|
||||||
|
|
||||||
virtual void SetConVarValue(ConVarID cvarid, CSplitScreenSlot nSlot, CVValue_t *pNewValue, CVValue_t *pOldValue) = 0;
|
virtual void SetConVarValue(ConVarHandle cvarid, CSplitScreenSlot nSlot, CVValue_t *pNewValue, CVValue_t *pOldValue) = 0;
|
||||||
|
|
||||||
virtual ConCommandID FindCommand(const char *szName) = 0;
|
virtual ConCommandHandle FindCommand(const char *szName) = 0;
|
||||||
virtual ConCommandID FindFirstCommand() = 0;
|
virtual ConCommandHandle FindFirstCommand() = 0;
|
||||||
virtual ConCommandID FindNextCommand(ConCommandID previous) = 0;
|
virtual ConCommandHandle FindNextCommand(ConCommandHandle previous) = 0;
|
||||||
|
|
||||||
virtual void DispatchConCommand(ConCommandID commandid, CCommandContext& ctx, CCommand& tok) = 0;
|
virtual void DispatchConCommand(ConCommandHandle commandid, CCommandContext& ctx, CCommand& tok) = 0;
|
||||||
|
|
||||||
// Install a global change callback (to be called when any convar changes)
|
// Install a global change callback (to be called when any convar changes)
|
||||||
virtual void InstallGlobalChangeCallback(FnChangeCallbackGlobal_t callback) = 0;
|
virtual void InstallGlobalChangeCallback(FnChangeCallbackGlobal_t callback) = 0;
|
||||||
virtual void RemoveGlobalChangeCallback(FnChangeCallbackGlobal_t callback) = 0;
|
virtual void RemoveGlobalChangeCallback(FnChangeCallbackGlobal_t callback) = 0;
|
||||||
virtual void CallGlobalChangeCallbacks(ConVarRefAbstract *cvar, CSplitScreenSlot nSlot, const char *pNewValue, const char* pOldValue) = 0;
|
virtual void CallGlobalChangeCallbacks(ConVarRefAbstract *cvar, CSplitScreenSlot nSlot, const char *pNewValue, const char* pOldValue) = 0;
|
||||||
|
|
||||||
// Reverts cvars which contain a specific flag
|
// Reverts to default cvars which contain a specific flag
|
||||||
virtual void RevertFlaggedConVars(int nFlag) = 0;
|
virtual void RevertFlaggedConVars(int nFlag) = 0;
|
||||||
|
|
||||||
virtual void SetMaxSplitScreenSlots(int nSlots) = 0;
|
virtual void SetMaxSplitScreenSlots(int nSlots) = 0;
|
||||||
@ -94,13 +94,13 @@ public:
|
|||||||
|
|
||||||
virtual void SetConVarsFromGameInfo(KeyValues *) = 0;
|
virtual void SetConVarsFromGameInfo(KeyValues *) = 0;
|
||||||
|
|
||||||
virtual void RegisterConVar(ConVarDesc_t*, void*, ConVarID&, ConVar&) = 0;
|
virtual void RegisterConVar(ConVarDesc_t *pDesc, bool bAdditionalFlags, ConVarRefAbstract &pCvarRef) = 0;
|
||||||
virtual void UnregisterConVar(ConVarID cvarid) = 0;
|
virtual void UnregisterConVar(ConVarHandle handle) = 0;
|
||||||
virtual ConVar* GetConVar(ConVarID cvarid) = 0;
|
virtual ConVar* GetConVar(ConVarHandle handle) = 0;
|
||||||
|
|
||||||
virtual void RegisterConCommand(void*, void*, ConCommandID&, ConCommand&) = 0;
|
virtual ConCommandRef* RegisterConCommand(ConCommandDesc_t *pDesc, bool bAdditionalFlags = FCVAR_NONE) = 0;
|
||||||
virtual void UnregisterConCommand(ConCommandID commandid) = 0;
|
virtual void UnregisterConCommand(ConCommandHandle handle) = 0;
|
||||||
virtual ConCommand* GetConCommand(ConCommandID commandid) = 0;
|
virtual ConCommand* GetConCommand(ConCommandHandle handle) = 0;
|
||||||
|
|
||||||
virtual void QueueThreadSetValue(ConVarRefAbstract *ref, CSplitScreenSlot nSlot, CVValue_t *value) = 0;
|
virtual void QueueThreadSetValue(ConVarRefAbstract *ref, CSplitScreenSlot nSlot, CVValue_t *value) = 0;
|
||||||
};
|
};
|
||||||
|
@ -51,11 +51,11 @@ union CVValue_t;
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//#define CONVAR_TEST_MATERIAL_THREAD_CONVARS 1
|
//#define CONVAR_TEST_MATERIAL_THREAD_CONVARS 1
|
||||||
|
|
||||||
DECLARE_HANDLE_32BIT(ConVarID);
|
DECLARE_HANDLE_32BIT(ConVarHandle);
|
||||||
#define CONVAR_ID_INVALID ConVarID::MakeHandle( 0xFFFFFFFF )
|
#define CONVAR_ID_INVALID ConVarHandle::MakeHandle( 0xFFFFFFFF )
|
||||||
|
|
||||||
DECLARE_HANDLE_32BIT(ConCommandID);
|
DECLARE_HANDLE_32BIT(ConCommandHandle);
|
||||||
#define CONCOMMAND_ID_INVALID ConCommandID::MakeHandle( 0xFFFFFFFF )
|
#define CONCOMMAND_ID_INVALID ConCommandHandle::MakeHandle( 0xFFFFFFFF )
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// ConVar flags
|
// ConVar flags
|
||||||
@ -122,7 +122,7 @@ class ICreationListenerCallbacks
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void ConVarCreationCallback(ConVarRefAbstract *pNewCvar) = 0;
|
virtual void ConVarCreationCallback(ConVarRefAbstract *pNewCvar) = 0;
|
||||||
virtual void ConCommandCreationCallback(ConCommandID commandID) = 0;
|
virtual void ConCommandCreationCallback(ConCommandRef *pNewCommand) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CCommandContext
|
struct CCommandContext
|
||||||
@ -167,9 +167,9 @@ void ConVar_PublishToVXConsole();
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Called when a ConCommand needs to execute
|
// Called when a ConCommand needs to execute
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
typedef void ( *FnCommandCallbackV1_t )( const CCommandContext &context );
|
typedef void ( *FnCommandCallback_t )( const CCommandContext &context );
|
||||||
typedef void ( *FnCommandCallbackV2_t )( const CCommandContext &context, const CCommand &command );
|
typedef void ( *FnCommandCallbackDefault_t )( const CCommandContext &context, const CCommand &command );
|
||||||
typedef void ( *FnCommandCallback_t )( const CCommand &command );
|
typedef void ( *FnCommandCallbackEmpty_t )( );
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Returns 0 to COMMAND_COMPLETION_MAXITEMS worth of completion strings
|
// Returns 0 to COMMAND_COMPLETION_MAXITEMS worth of completion strings
|
||||||
@ -229,47 +229,59 @@ union CVValue_t
|
|||||||
Vector4D m_vec4Value;
|
Vector4D m_vec4Value;
|
||||||
QAngle m_angValue;
|
QAngle m_angValue;
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
struct ConVarDataType_t
|
struct ConVarDataType_t
|
||||||
{
|
{
|
||||||
const char* name;
|
const char* name;
|
||||||
int data_size;
|
int data_size;
|
||||||
int primitive; // 1 for primitive types, 0 for others
|
int primitive;
|
||||||
void* InitValue;
|
|
||||||
|
void* InitValue; // Only used for string type
|
||||||
void* CloneValue;
|
void* CloneValue;
|
||||||
void* DestroyValue;
|
void* DestroyValue; // Only used for string type
|
||||||
void* FromString;
|
void* FromString;
|
||||||
void* ToString;
|
void* ToString;
|
||||||
void* IsEqual;
|
void* IsEqual;
|
||||||
void* Clamp;
|
void* Clamp;
|
||||||
|
|
||||||
const char* default_string_value;
|
const char* default_string_value;
|
||||||
ConVar* undefined_cvar;
|
ConVarDataType_t* default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ConVarRefAbstract
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ConVarHandle *handle;
|
||||||
|
ConVar *cvar;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Should be size of 56 (0x38)
|
||||||
|
struct ConVarValueDescription_t
|
||||||
|
{
|
||||||
|
// This gets copied to the ConVar class on creation
|
||||||
|
int unk1;
|
||||||
|
|
||||||
|
bool has_default;
|
||||||
|
bool has_min;
|
||||||
|
bool has_max;
|
||||||
|
|
||||||
|
CVValue_t default_value;
|
||||||
|
CVValue_t min_value;
|
||||||
|
CVValue_t max_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Should be size of 96 (0x60)
|
||||||
struct ConVarDesc_t
|
struct ConVarDesc_t
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *description;
|
const char *description;
|
||||||
int64 flags;
|
int64 flags;
|
||||||
char unk[64];
|
ConVarValueDescription_t value_info;
|
||||||
ConVarDataType_t type;
|
|
||||||
void *handle;
|
|
||||||
void *convar;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ConCommandDesc_t
|
|
||||||
{
|
|
||||||
const char* name;
|
|
||||||
const char* description;
|
|
||||||
int64 flags;
|
|
||||||
void *callback;
|
void *callback;
|
||||||
void* unk1;
|
EConVarType type;
|
||||||
void* unk2;
|
|
||||||
void* unk3;
|
|
||||||
void* output_id_holder;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Should be size of 64 (0x40)
|
||||||
class ConVar
|
class ConVar
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -279,26 +291,75 @@ public:
|
|||||||
CVValue_t *maxValue;
|
CVValue_t *maxValue;
|
||||||
const char *description;
|
const char *description;
|
||||||
EConVarType type;
|
EConVarType type;
|
||||||
char padding[2];
|
|
||||||
|
// This gets copied from the ConVarDesc_t on creation
|
||||||
|
short unk1;
|
||||||
|
|
||||||
unsigned int timesChanged;
|
unsigned int timesChanged;
|
||||||
int64 flags;
|
int64 flags;
|
||||||
unsigned int callbackId;
|
unsigned int callback_index;
|
||||||
int unk;
|
|
||||||
CVValue_t value[];
|
// Used when setting default, max, min values from the ConVarDesc_t
|
||||||
|
// although that's not the only place of usage
|
||||||
|
// flags seems to be:
|
||||||
|
// (1 << 0) Skip setting value to split screen slots and also something keyvalues related
|
||||||
|
// (1 << 1) Skip setting default value
|
||||||
|
// (1 << 2) Skip setting min/max values
|
||||||
|
int allocation_flag_of_some_sort;
|
||||||
|
|
||||||
|
CVValue_t values[];
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConCommand
|
class ConCommandRef
|
||||||
{
|
{
|
||||||
|
ConCommandHandle handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConVarRefAbstract
|
class ConCommandBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConVarID *cvarid;
|
const char *name;
|
||||||
ConVar *cvar;
|
const char *description;
|
||||||
|
int64 flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ConCommandCB
|
||||||
|
{
|
||||||
|
// Call this function when executing the command
|
||||||
|
union
|
||||||
|
{
|
||||||
|
void *m_fnCallbackAny;
|
||||||
|
FnCommandCallback_t m_fnCommandCallback;
|
||||||
|
FnCommandCallbackEmpty_t m_fnCommandCallbackEmpty;
|
||||||
|
FnCommandCallbackDefault_t m_fnCommandCallbackDefault;
|
||||||
|
ICommandCallback *m_pCommandCallback;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool m_bUsingCommandCallbackInterface : 1;
|
||||||
|
bool m_bUsingEmptyCommandCallback : 1;
|
||||||
|
bool m_bUsingCommandCallback : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Should be size of 64 (0x40)
|
||||||
|
class ConCommandDesc_t : ConCommandBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ConCommandCB callback;
|
||||||
|
ConCommandCB autocompletion_callback;
|
||||||
|
ConCommandRef *parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Should be size of 48 (0x30) (56 in linked list)
|
||||||
|
class ConCommand : ConCommandBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ConCommandCB autocompletion_callback;
|
||||||
|
int ccvar_autocomplete_callback_index;
|
||||||
|
int ccvar_callbackslist_callback_index;
|
||||||
|
};
|
||||||
|
|
||||||
|
//class CConCommandMemberAccessor : IConCommandAccessor, ConCommandRef
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: The base console invoked command/cvar interface
|
// Purpose: The base console invoked command/cvar interface
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user