From 8fd40efe362f7fcd371e30b66a815e4261d86dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sun, 4 Aug 2024 21:25:04 +0200 Subject: [PATCH] Fix key names for composite binds with multiple modifiers This was only affecting the key names displayed in the voting HUD, e.g. with `bind "ctrl+alt+f3" "vote yes"` the voting HUD previously showed `+f3` as the key name. --- src/game/client/components/binds.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/game/client/components/binds.cpp b/src/game/client/components/binds.cpp index 50ef83e90..90efe3269 100644 --- a/src/game/client/components/binds.cpp +++ b/src/game/client/components/binds.cpp @@ -196,21 +196,18 @@ const char *CBinds::Get(int KeyId, int ModifierCombination) void CBinds::GetKey(const char *pBindStr, char *pBuf, size_t BufSize) { - pBuf[0] = 0; - for(int Mod = 0; Mod < MODIFIER_COMBINATION_COUNT; Mod++) + pBuf[0] = '\0'; + for(int Modifier = MODIFIER_NONE; Modifier < MODIFIER_COMBINATION_COUNT; Modifier++) { - for(int KeyId = 0; KeyId < KEY_LAST; KeyId++) + for(int KeyId = KEY_FIRST; KeyId < KEY_LAST; KeyId++) { - const char *pBind = Get(KeyId, Mod); + const char *pBind = Get(KeyId, Modifier); if(!pBind[0]) continue; if(str_comp(pBind, pBindStr) == 0) { - if(Mod) - str_format(pBuf, BufSize, "%s+%s", GetModifierName(Mod), Input()->KeyName(KeyId)); - else - str_copy(pBuf, Input()->KeyName(KeyId), BufSize); + str_format(pBuf, BufSize, "%s%s", GetKeyBindModifiersName(Modifier), Input()->KeyName(KeyId)); return; } }