From a0e6ec0de72f4df6862af3174a2f8868c898d4e5 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 21 Oct 2019 01:53:03 -0400 Subject: [PATCH] Console: Make State enum an enum class Makes the enum strongly typed and impervious to implicit conversions. --- hecl/include/hecl/Console.hpp | 2 +- hecl/lib/Console.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hecl/include/hecl/Console.hpp b/hecl/include/hecl/Console.hpp index f0a0215ea..ef68054e8 100644 --- a/hecl/include/hecl/Console.hpp +++ b/hecl/include/hecl/Console.hpp @@ -55,7 +55,7 @@ public: Fatal /**< Non-recoverable error message (Kept for compatibility with logvisor) */ }; - enum State { Closed, Closing, Opened, Opening }; + enum class State { Closed, Closing, Opened, Opening }; private: CVarManager* m_cvarMgr = nullptr; diff --git a/hecl/lib/Console.cpp b/hecl/lib/Console.cpp index dc438ff33..5da392843 100644 --- a/hecl/lib/Console.cpp +++ b/hecl/lib/Console.cpp @@ -242,8 +242,9 @@ void Console::handleCharCode(unsigned long chr, boo::EModifierKey /*mod*/, bool } void Console::handleSpecialKeyDown(boo::ESpecialKey sp, boo::EModifierKey mod, bool /*repeat*/) { - if (m_state != Opened) + if (m_state != State::Opened) { return; + } switch (sp) { case boo::ESpecialKey::Insert: