Check for dvar type

This commit is contained in:
Diavolo 2021-08-29 22:09:45 +02:00
parent 62cc1fff78
commit 9a1ab2c660
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5

View File

@ -86,7 +86,7 @@ namespace Components
} }
void Dvar::Var::set(const char* string) void Dvar::Var::set(const char* string)
{ {
if (this->dvar && this->dvar->name) if (this->dvar && this->dvar->type == Game::dvar_type::DVAR_TYPE_STRING)
{ {
this->dvar->current.string = string; this->dvar->current.string = string;
} }
@ -97,21 +97,21 @@ namespace Components
} }
void Dvar::Var::set(int integer) void Dvar::Var::set(int integer)
{ {
if (this->dvar && this->dvar->name) if (this->dvar && this->dvar->name && this->dvar->type == Game::dvar_type::DVAR_TYPE_INT)
{ {
this->dvar->current.integer = 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 && this->dvar->type == Game::dvar_type::DVAR_TYPE_FLOAT)
{ {
this->dvar->current.value = value; this->dvar->current.value = value;
} }
} }
void Dvar::Var::set(bool enabled) void Dvar::Var::set(bool enabled)
{ {
if (this->dvar && this->dvar->name) if (this->dvar && this->dvar->name && this->dvar->type == Game::dvar_type::DVAR_TYPE_BOOL)
{ {
this->dvar->current.enabled = enabled; this->dvar->current.enabled = enabled;
} }