diff options
author | Bendegúz Nagy | 2016-08-10 13:55:12 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | c380ccf3f324f1266f894c29c38d9e188488e119 (patch) | |
tree | a7cc9db5bc2eea8e453bae6490de1bf0b928fe1a | |
parent | 172477b1153b08ac776bc2ff6d7d82eac87150a0 (diff) | |
download | scummvm-rg350-c380ccf3f324f1266f894c29c38d9e188488e119.tar.gz scummvm-rg350-c380ccf3f324f1266f894c29c38d9e188488e119.tar.bz2 scummvm-rg350-c380ccf3f324f1266f894c29c38d9e188488e119.zip |
DM: Add SingleUseFlag to console.cpp
-rw-r--r-- | engines/dm/console.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/engines/dm/console.cpp b/engines/dm/console.cpp index 46a654b074..7bafc3c48e 100644 --- a/engines/dm/console.cpp +++ b/engines/dm/console.cpp @@ -32,6 +32,17 @@ namespace DM { bool cstrEquals(const char* a, const char *b) { return strcmp(a, b) == 0; } +class SingleUseFlag { + bool _flag; +public: + SingleUseFlag(): _flag(true) {} + bool check() { + bool currFlagState = _flag; + _flag = false; + return currFlagState; + } +}; + Console::Console(DM::DMEngine* vm) : _vm(vm) { _debugGodmodeMana = false; _debugGodmodeHP = false; @@ -81,11 +92,9 @@ bool Console::Cmd_noclip(int argc, const char** argv) { if (cstrEquals("on", argv[1])) { _debugNoclip = true; - static bool warnedForNoclip = false; - if (!warnedForNoclip) { + static SingleUseFlag warnedForNoclip; + if (warnedForNoclip.check()) debugPrintf("Noclip can cause unexpected glitches and crashes.\n"); - warnedForNoclip = true; - } } else if (cstrEquals("off", argv[1])) { _debugNoclip = false; } else @@ -98,4 +107,6 @@ argumentError: debugPrintf("Usage: %s <on/off>\n", argv[0]); return true; } + + } |