From 9ec090567986b5d273c90cceaceae42922b84afe Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 9 Jul 2017 13:04:26 +0200 Subject: Fixed a gcc 7 warning. --- src/core/commandbuffer.cc | 8 ++++---- src/core/cvar.h | 6 ++++++ src/core/entity.h | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc index 4234f0e..a9b8117 100644 --- a/src/core/commandbuffer.cc +++ b/src/core/commandbuffer.cc @@ -229,7 +229,7 @@ void func_set(std::string const &args) value += c; Cvar *cvar = Cvar::set(varname.c_str(), value.c_str()); - if (cvar->flags() && Cvar::Info) { + if (cvar->has_flag(Cvar::Info)) { localplayer()->set_dirty(); } @@ -264,7 +264,7 @@ void func_toggle(std::string const &args) (*cvar) = valueone; } - if (cvar->flags() && Cvar::Info) { + if (cvar->has_flag(Cvar::Info)) { localplayer()->set_dirty(); } @@ -438,14 +438,14 @@ void CommandBuffer::exec(std::string const &cmdline) if (cvar) { // cvar exists std::string value; - if (((cvar->flags() & Cvar::ReadOnly) == 0) && (cmdstream >> value)) { + if ((!cvar->has_flag(Cvar::ReadOnly)) && (cmdstream >> value)) { // we're setting a new value char c; while (cmdstream.get(c)) value += c; (*cvar) = value; - if (cvar->flags() && Cvar::Info) { + if (cvar->has_flag(Cvar::Info)) { localplayer()->set_dirty(); } } diff --git a/src/core/cvar.h b/src/core/cvar.h index 864d751..4db09dc 100644 --- a/src/core/cvar.h +++ b/src/core/cvar.h @@ -59,6 +59,12 @@ public: inline const std::string& str() const { return cvar_str; } + + /// returns true if a cvar flag is set + inline const bool has_flag(const Flags flag) const + { + return ((cvar_flags & (unsigned int)flag) == (unsigned int)flag); + } /*----- mutators -------------------------------------------------- */ diff --git a/src/core/entity.h b/src/core/entity.h index 27d888c..3e0cea8 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -142,7 +142,7 @@ public: return entity_flags; } - /// returns true of a flag is set + /// returns true if an entity flag is set inline const bool has_flag(const Flags flag) const { return ((entity_flags & (unsigned int)flag) == (unsigned int)flag); -- cgit v1.2.3