Skip to content

Commit 062aa3f

Browse files
authored
Fix #1596: getBoundKeys still returning table (#1615)
* Fix #1596: getBoundKeys still returning table Fixed getBoundKeys still still returns a table when an unbound command is passed to it. * Updating code format
1 parent 6941e0b commit 062aa3f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6982,9 +6982,12 @@ bool CStaticFunctionDefinitions::UnbindKey(const char* szKey, const char* szHitS
69826982

69836983
CKeyBindsInterface* pKeyBinds = g_pCore->GetKeyBinds();
69846984
bool bKey = pKeyBinds->IsKey(szKey);
6985+
CCommandBind* pBind;
6986+
69856987
if (bKey)
69866988
{
69876989
bool bCheckHitState = false, bHitState = true;
6990+
69886991
if (szHitState)
69896992
{
69906993
if (stricmp(szHitState, "down") == 0)
@@ -6996,17 +6999,29 @@ bool CStaticFunctionDefinitions::UnbindKey(const char* szKey, const char* szHitS
69966999
bCheckHitState = true, bHitState = false;
69977000
}
69987001
}
7002+
7003+
7004+
pBind = g_pCore->GetKeyBinds()->GetBindFromCommand(szCommandName, NULL, false, szKey, bCheckHitState, bHitState);
7005+
69997006
if ((!stricmp(szHitState, "down") || !stricmp(szHitState, "both")) &&
70007007
pKeyBinds->SetCommandActive(szKey, szCommandName, bHitState, NULL, szResource, false, true, true))
70017008
{
70027009
pKeyBinds->SetAllCommandsActive(szResource, false, szCommandName, bHitState, NULL, true, szKey);
7010+
7011+
if (pBind)
7012+
pKeyBinds->Remove(pBind);
7013+
70037014
bSuccess = true;
70047015
}
70057016
bHitState = false;
70067017
if ((!stricmp(szHitState, "up") || !stricmp(szHitState, "both")) &&
70077018
pKeyBinds->SetCommandActive(szKey, szCommandName, bHitState, NULL, szResource, false, true, true))
70087019
{
70097020
pKeyBinds->SetAllCommandsActive(szResource, false, szCommandName, bHitState, NULL, true, szKey);
7021+
7022+
if (pBind)
7023+
pKeyBinds->Remove(pBind);
7024+
70107025
bSuccess = true;
70117026
}
70127027
}

0 commit comments

Comments
 (0)