[Dvar] Use set raw method on dvars by default

This commit is contained in:
Diavolo 2021-08-29 17:41:21 +02:00
parent ebebaf173c
commit 89165a96b4
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
6 changed files with 15 additions and 26 deletions

View File

@ -218,7 +218,7 @@ namespace Components
{ {
if (!Dedicated::IsEnabled() && Dvar::Var("sv_dontrotate").get<bool>()) if (!Dedicated::IsEnabled() && Dvar::Var("sv_dontrotate").get<bool>())
{ {
Dvar::Var("sv_dontrotate").setRaw(0); Dvar::Var("sv_dontrotate").set(0);
return; return;
} }

View File

@ -88,7 +88,7 @@ namespace Components
{ {
if (this->dvar && this->dvar->name) if (this->dvar && this->dvar->name)
{ {
Game::Dvar_SetCommand(this->dvar->name, string); this->dvar->current.string = string;
} }
} }
void Dvar::Var::set(const std::string& string) void Dvar::Var::set(const std::string& string)
@ -99,32 +99,23 @@ namespace Components
{ {
if (this->dvar && this->dvar->name) if (this->dvar && this->dvar->name)
{ {
Game::Dvar_SetCommand(this->dvar->name, Utils::String::VA("%i", integer)); this->dvar->current.integer = integer;
} }
} }
void Dvar::Var::set(float value) void Dvar::Var::set(float value)
{ {
if (this->dvar && this->dvar->name) if (this->dvar && this->dvar->name)
{
Game::Dvar_SetCommand(this->dvar->name, Utils::String::VA("%f", value));
}
}
void Dvar::Var::setRaw(int integer)
{
if (this->dvar)
{
this->dvar->current.integer = integer;
}
}
void Dvar::Var::setRaw(float value)
{
if (this->dvar)
{ {
this->dvar->current.value = value; this->dvar->current.value = value;
} }
} }
void Dvar::Var::set(bool enabled)
{
if (this->dvar && this->dvar->name)
{
this->dvar->current.enabled = enabled;
}
}
template<> static Dvar::Var Dvar::Register(const char* name, bool value, Dvar::Flag flag, const char* description) template<> static Dvar::Var Dvar::Register(const char* name, bool value, Dvar::Flag flag, const char* description)
{ {

View File

@ -31,10 +31,7 @@ namespace Components
void set(int integer); void set(int integer);
void set(float value); void set(float value);
void set(bool enabled);
// TODO: Add others
void setRaw(int integer);
void setRaw(float value);
private: private:
Game::dvar_t* dvar; Game::dvar_t* dvar;

View File

@ -22,7 +22,7 @@ namespace Components
{ {
if (!Game::CL_IsCgameInitialized()) if (!Game::CL_IsCgameInitialized())
{ {
Dvar::Var("com_timescale").setRaw(1.0f); Dvar::Var("com_timescale").set(1.0f);
} }
}); });

View File

@ -560,7 +560,7 @@ namespace Components
} }
hasDlc.push_back(hasAllMaps); hasDlc.push_back(hasAllMaps);
Dvar::Var(Utils::String::VA("isDlcInstalled_%d", pack.index)).setRaw(hasAllMaps ? 1 : 0); Dvar::Var(Utils::String::VA("isDlcInstalled_%d", pack.index)).set(hasAllMaps ? 1 : 0);
} }
// Must have all of dlc 3 to 5 or it causes issues // Must have all of dlc 3 to 5 or it causes issues
@ -571,7 +571,7 @@ namespace Components
sentMessage = true; sentMessage = true;
} }
Dvar::Var("isDlcInstalled_All").setRaw(hasAllDlcs ? 1 : 0); Dvar::Var("isDlcInstalled_All").set(hasAllDlcs ? 1 : 0);
} }
bool Maps::IsCustomMap() bool Maps::IsCustomMap()

View File

@ -90,6 +90,7 @@ 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