diff options
Diffstat (limited to 'src/core/cvar.cc')
-rw-r--r-- | src/core/cvar.cc | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/src/core/cvar.cc b/src/core/cvar.cc index 2a9fd67..1732d1a 100644 --- a/src/core/cvar.cc +++ b/src/core/cvar.cc @@ -36,19 +36,18 @@ Cvar *Cvar::net_framerate = 0; Cvar::Registry Cvar::cvar_registry; -Cvar::Cvar(const char *name, const unsigned int flags) : cvar_name(), cvar_info(), cvar_str() +Cvar::Cvar(const char* name, const unsigned int flags) : cvar_name(name), cvar_info(), cvar_str() { cvar_flags = flags; - cvar_name.assign(name); } -void Cvar::set_info(const char *info) +void Cvar::set_info(const char* info) { if (info) cvar_info.assign(info); } -Cvar & Cvar::operator=(const std::string &other) +Cvar & Cvar::operator=(const std::string& other) { cvar_str = other; std::stringstream s(cvar_str); @@ -57,13 +56,13 @@ Cvar & Cvar::operator=(const std::string &other) return (*this); } -Cvar & Cvar::operator=(const char *other) +Cvar & Cvar::operator=(const char* other) { std::string value(other); return (this->operator=(value)); } -Cvar & Cvar::operator=(float other) +Cvar & Cvar::operator=(const float other) { std::stringstream s; s << other; @@ -72,13 +71,10 @@ Cvar & Cvar::operator=(float other) return (*this); } -Cvar* Cvar::get(const char *name, const char *value, const unsigned int flags) +Cvar* Cvar::get(const char* name, const char* value, const unsigned int flags) { Cvar *c = find(name); - if (c) { - //con_debug << "get " << name << " already exist with value " << cvar->str() << std::endl; - } else { - //con_debug << "get " << name << " " << value << std::endl; + if (!c) { c = new Cvar(name, flags); cvar_registry[c->name()] = c; (*c) = value; @@ -87,13 +83,10 @@ Cvar* Cvar::get(const char *name, const char *value, const unsigned int flags) return c; } -Cvar* Cvar::get(const char *name, float value, const unsigned int flags) +Cvar* Cvar::get(const char* name, const float value, const unsigned int flags) { Cvar *c = find(name); - if (c) { - //con_debug << "get " << name << " already exist with value " << cvar->str() << std::endl; - } else { - //con_debug << "get " << name << " " << value << std::endl; + if (!c) { c = new Cvar(name, flags); cvar_registry[c->name()] = c; (*c) = value; @@ -102,7 +95,7 @@ Cvar* Cvar::get(const char *name, float value, const unsigned int flags) return c; } -Cvar* Cvar::set(const char *name, const char *value, const unsigned int flags) +Cvar* Cvar::set(const char* name, const char* value, const unsigned int flags) { Cvar *c = find(name); if (!c) { @@ -116,7 +109,7 @@ Cvar* Cvar::set(const char *name, const char *value, const unsigned int flags) return c; } -Cvar* Cvar::set(const char *name, float value, unsigned int flags) +Cvar* Cvar::set(const char* name, const float value, const unsigned int flags) { Cvar *c = find(name); if (!c) { @@ -130,7 +123,7 @@ Cvar* Cvar::set(const char *name, float value, unsigned int flags) return c; } -void Cvar::unset(std::string const &name) +void Cvar::unset(const std::string& name) { Cvar *c = find(name); if (c) { @@ -140,12 +133,12 @@ void Cvar::unset(std::string const &name) } } -void Cvar::unset(const char *name) +void Cvar::unset(const char* name) { unset(std::string(name)); } -Cvar *Cvar::find(std::string const &name) +Cvar *Cvar::find(const std::string& name) { Registry::iterator it = cvar_registry.find(name); if (it == cvar_registry.end()) @@ -154,7 +147,7 @@ Cvar *Cvar::find(std::string const &name) return (*it).second; } -Cvar *Cvar::find(const char *name) +Cvar *Cvar::find(const char* name) { std::string s(name); return(find(s)); |