Use game functions to safely change dvar value
This commit is contained in:
parent
dded312064
commit
36a025e1d0
@ -86,7 +86,8 @@ namespace Components
|
|||||||
}
|
}
|
||||||
void Dvar::Var::set(const char* string)
|
void Dvar::Var::set(const char* string)
|
||||||
{
|
{
|
||||||
if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_STRING)
|
assert(this->dvar->type == Game::DVAR_TYPE_STRING);
|
||||||
|
if (this->dvar)
|
||||||
{
|
{
|
||||||
Game::Dvar_SetString(this->dvar, string);
|
Game::Dvar_SetString(this->dvar, string);
|
||||||
}
|
}
|
||||||
@ -97,26 +98,26 @@ namespace Components
|
|||||||
}
|
}
|
||||||
void Dvar::Var::set(int integer)
|
void Dvar::Var::set(int integer)
|
||||||
{
|
{
|
||||||
if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_INT)
|
assert(this->dvar->type == Game::DVAR_TYPE_INT);
|
||||||
|
if (this->dvar)
|
||||||
{
|
{
|
||||||
this->dvar->current.integer = integer;
|
Game::Dvar_SetInt(this->dvar, integer);
|
||||||
this->dvar->latched.integer = integer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Dvar::Var::set(float value)
|
void Dvar::Var::set(float value)
|
||||||
{
|
{
|
||||||
if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT)
|
assert(this->dvar->type == Game::DVAR_TYPE_FLOAT);
|
||||||
|
if (this->dvar)
|
||||||
{
|
{
|
||||||
this->dvar->current.value = value;
|
Game::Dvar_SetFloat(this->dvar, value);
|
||||||
this->dvar->latched.value = value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Dvar::Var::set(bool enabled)
|
void Dvar::Var::set(bool enabled)
|
||||||
{
|
{
|
||||||
if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_BOOL)
|
assert(this->dvar->type == Game::DVAR_TYPE_BOOL);
|
||||||
|
if (this->dvar)
|
||||||
{
|
{
|
||||||
this->dvar->current.enabled = enabled;
|
Game::Dvar_SetBool(this->dvar, enabled);
|
||||||
this->dvar->latched.enabled = enabled;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,6 +280,9 @@ namespace Game
|
|||||||
Dvar_SetFromStringByNameFromSource_t Dvar_SetFromStringByNameFromSource = Dvar_SetFromStringByNameFromSource_t(0x4FC770);
|
Dvar_SetFromStringByNameFromSource_t Dvar_SetFromStringByNameFromSource = Dvar_SetFromStringByNameFromSource_t(0x4FC770);
|
||||||
Dvar_SetStringByName_t Dvar_SetStringByName = Dvar_SetStringByName_t(0x44F060);
|
Dvar_SetStringByName_t Dvar_SetStringByName = Dvar_SetStringByName_t(0x44F060);
|
||||||
Dvar_SetString_t Dvar_SetString = Dvar_SetString_t(0x4A9580);
|
Dvar_SetString_t Dvar_SetString = Dvar_SetString_t(0x4A9580);
|
||||||
|
Dvar_SetBool_t Dvar_SetBool = Dvar_SetBool_t(0x4A9510);
|
||||||
|
Dvar_SetFloat_t Dvar_SetFloat = Dvar_SetFloat_t(0x40BB20);
|
||||||
|
Dvar_SetInt_t Dvar_SetInt = Dvar_SetInt_t(0x421DA0);
|
||||||
|
|
||||||
SL_ConvertToString_t SL_ConvertToString = SL_ConvertToString_t(0x4EC1D0);
|
SL_ConvertToString_t SL_ConvertToString = SL_ConvertToString_t(0x4EC1D0);
|
||||||
SL_GetString_t SL_GetString = SL_GetString_t(0x4CDC10);
|
SL_GetString_t SL_GetString = SL_GetString_t(0x4CDC10);
|
||||||
|
@ -247,6 +247,15 @@ namespace Game
|
|||||||
typedef void (__cdecl * Dvar_SetString_t)(dvar_t* cvar, const char* value);
|
typedef void (__cdecl * Dvar_SetString_t)(dvar_t* cvar, const char* value);
|
||||||
extern Dvar_SetString_t Dvar_SetString;
|
extern Dvar_SetString_t Dvar_SetString;
|
||||||
|
|
||||||
|
typedef void (__cdecl * Dvar_SetBool_t)(dvar_t* cvar, bool enabled);
|
||||||
|
extern Dvar_SetBool_t Dvar_SetBool;
|
||||||
|
|
||||||
|
typedef void (__cdecl * Dvar_SetFloat_t)(dvar_t* cvar, float value);
|
||||||
|
extern Dvar_SetFloat_t Dvar_SetFloat;
|
||||||
|
|
||||||
|
typedef void (__cdecl * Dvar_SetInt_t)(dvar_t* cvar, int integer);
|
||||||
|
extern Dvar_SetInt_t Dvar_SetInt;
|
||||||
|
|
||||||
typedef void(__cdecl * Dvar_GetUnpackedColorByName_t)(const char* name, float* color);
|
typedef void(__cdecl * Dvar_GetUnpackedColorByName_t)(const char* name, float* color);
|
||||||
extern Dvar_GetUnpackedColorByName_t Dvar_GetUnpackedColorByName;
|
extern Dvar_GetUnpackedColorByName_t Dvar_GetUnpackedColorByName;
|
||||||
|
|
||||||
|
@ -90,7 +90,6 @@ namespace Game
|
|||||||
DVAR_FLAG_SERVERINFO = 0x400, //in the getstatus oob
|
DVAR_FLAG_SERVERINFO = 0x400, //in the getstatus oob
|
||||||
DVAR_FLAG_WRITEPROTECTED = 0x800, //write protected
|
DVAR_FLAG_WRITEPROTECTED = 0x800, //write protected
|
||||||
DVAR_FLAG_UNKNOWN1000 = 0x1000, //unknown
|
DVAR_FLAG_UNKNOWN1000 = 0x1000, //unknown
|
||||||
DVAR_FLAG_UNKNOWN1800 = 0x1800, //unknown
|
|
||||||
DVAR_FLAG_READONLY = 0x2000, //read only (same as 0x800?)
|
DVAR_FLAG_READONLY = 0x2000, //read only (same as 0x800?)
|
||||||
DVAR_FLAG_UNKNOWN4000 = 0x4000, //unknown
|
DVAR_FLAG_UNKNOWN4000 = 0x4000, //unknown
|
||||||
DVAR_FLAG_UNKNOWN8000 = 0x8000, //unknown
|
DVAR_FLAG_UNKNOWN8000 = 0x8000, //unknown
|
||||||
@ -2382,7 +2381,7 @@ namespace Game
|
|||||||
const char *name;
|
const char *name;
|
||||||
const char *description;
|
const char *description;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
char type;
|
dvar_type type;
|
||||||
bool modified;
|
bool modified;
|
||||||
DvarValue current;
|
DvarValue current;
|
||||||
DvarValue latched;
|
DvarValue latched;
|
||||||
|
Loading…
Reference in New Issue
Block a user