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.
This commit is contained in:
Robert Müller 2024-08-04 21:25:04 +02:00
parent d2222f55e7
commit 8fd40efe36

View file

@ -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;
}
}