From 2233ca98c1d35a52b04766688354b6ce7dce19c9 Mon Sep 17 00:00:00 2001 From: Alexander Akulich Date: Mon, 7 Feb 2022 01:30:19 +0300 Subject: [PATCH] CBinds::GetModifierMask: Make the method actually returning the mask ... instead of the modifier enum value. This fixes CMenusKeyBinder which now saves the bindings into the right slot. --- src/game/client/components/binds.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/game/client/components/binds.cpp b/src/game/client/components/binds.cpp index 91e9bc32e..7122c3b5f 100644 --- a/src/game/client/components/binds.cpp +++ b/src/game/client/components/binds.cpp @@ -87,14 +87,24 @@ void CBinds::Bind(int KeyID, const char *pStr, bool FreeOnly, int ModifierCombin int CBinds::GetModifierMask(IInput *i) { int Mask = 0; - Mask |= i->KeyIsPressed(KEY_LSHIFT) << CBinds::MODIFIER_SHIFT; - Mask |= i->KeyIsPressed(KEY_RSHIFT) << CBinds::MODIFIER_SHIFT; - Mask |= i->KeyIsPressed(KEY_LCTRL) << CBinds::MODIFIER_CTRL; - Mask |= i->KeyIsPressed(KEY_RCTRL) << CBinds::MODIFIER_CTRL; - Mask |= i->KeyIsPressed(KEY_LALT) << CBinds::MODIFIER_ALT; - Mask |= i->KeyIsPressed(KEY_RALT) << CBinds::MODIFIER_ALT; - Mask |= i->KeyIsPressed(KEY_LGUI) << CBinds::MODIFIER_GUI; - Mask |= i->KeyIsPressed(KEY_RGUI) << CBinds::MODIFIER_GUI; + static const auto ModifierKeys = { + KEY_LSHIFT, + KEY_RSHIFT, + KEY_LCTRL, + KEY_RCTRL, + KEY_LALT, + KEY_RALT, + KEY_LGUI, + KEY_RGUI, + }; + for(const auto Key : ModifierKeys) + { + if(i->KeyIsPressed(Key)) + { + Mask |= GetModifierMaskOfKey(Key); + } + } + if(!Mask) return 1 << CBinds::MODIFIER_NONE;