From 366a942a3a3dd9c3005c0f29d9e0b498eaf976ef Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 30 Dec 2011 13:03:39 -0600 Subject: [PATCH] KEYMAPPER: Simplify calling getKeymap --- backends/keymapper/keymapper.cpp | 9 ++++++--- backends/keymapper/keymapper.h | 2 +- engines/kyra/lol.cpp | 3 +-- gui/gui-manager.cpp | 3 +-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index 29f495cd530..025e9172737 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -128,21 +128,24 @@ void Keymapper::cleanupGameKeymaps() { _activeMaps = newStack; } -Keymap *Keymapper::getKeymap(const String& name, bool &global) { +Keymap *Keymapper::getKeymap(const String& name, bool *globalReturn) { Keymap *keymap = _gameDomain.getKeymap(name); - global = false; + bool global = false; if (!keymap) { keymap = _globalDomain.getKeymap(name); global = true; } + if (globalReturn) + *globalReturn = global; + return keymap; } bool Keymapper::pushKeymap(const String& name, bool inherit) { bool global; - Keymap *newMap = getKeymap(name, global); + Keymap *newMap = getKeymap(name, &global); if (!newMap) { warning("Keymap '%s' not registered", name.c_str()); diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index c5a2558964a..d38109f2102 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -116,7 +116,7 @@ public: * @param name name of the keymap to return * @param global set to true if returned keymap is global, false if game */ - Keymap *getKeymap(const String& name, bool &global); + Keymap *getKeymap(const String& name, bool *global = 0); /** * Push a new keymap to the top of the active stack, activating diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index db71b806111..b36f598649f 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -467,11 +467,10 @@ Common::Error LoLEngine::init() { void LoLEngine::initKeymap() { #ifdef ENABLE_KEYMAPPER - bool tmp; Common::Keymapper *mapper = _eventMan->getKeymapper(); // Do not try to recreate same keymap over again - if (mapper->getKeymap(kKeymapName, tmp) != 0) + if (mapper->getKeymap(kKeymapName) != 0) return; Common::Action *act; diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp index 98840e6dafe..3a665009cbf 100644 --- a/gui/gui-manager.cpp +++ b/gui/gui-manager.cpp @@ -103,11 +103,10 @@ GuiManager::~GuiManager() { void GuiManager::initKeymap() { using namespace Common; - bool tmp; Keymapper *mapper = _system->getEventManager()->getKeymapper(); // Do not try to recreate same keymap over again - if (mapper->getKeymap(kGuiKeymapName, tmp) != 0) + if (mapper->getKeymap(kGuiKeymapName) != 0) return; Action *act;