Skip to content

Commit 6e5e1ed

Browse files
committed
Revert "#9178 - Fix bindKey & unbindKey on commands (#201)"
This reverts commit c5c6b3c.
1 parent 9eee957 commit 6e5e1ed

File tree

2 files changed

+41
-35
lines changed

2 files changed

+41
-35
lines changed

Client/core/CKeyBinds.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,6 @@ bool CKeyBinds::SetCommandActive(const char* szKey, const char* szCommand, bool
770770
{
771771
NullEmptyStrings(szKey, szCommand, szArguments);
772772

773-
bool bReturn = false;
774773
list<CKeyBind*>::const_iterator iter = m_pList->begin();
775774
for (; iter != m_pList->end(); iter++)
776775
{
@@ -785,25 +784,18 @@ bool CKeyBinds::SetCommandActive(const char* szKey, const char* szCommand, bool
785784
{
786785
if (!checkHitState || (pBind->bHitState == bState))
787786
{
788-
if ((!szArguments && (!bActive || !pBind->szArguments))
789-
|| (szArguments && pBind->szArguments && strcmp(pBind->szArguments, szArguments) == 0))
787+
if (!szArguments || (pBind->szArguments && strcmp(pBind->szArguments, szArguments) == 0))
790788
{
791-
bool bOldActive = pBind->bActive;
792789
pBind->bActive = bActive;
793-
if (szArguments)
794-
{
795-
return true;
796-
}
797-
else
798-
bReturn = (bReturn || bOldActive != bActive);
790+
return true;
799791
}
800792
}
801793
}
802794
}
803795
}
804796
}
805797
}
806-
return bReturn;
798+
return false;
807799
}
808800

809801
void CKeyBinds::SetAllCommandsActive(const char* szResource, bool bActive, const char* szCommand, bool bState, const char* szArguments, bool checkHitState)

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6420,24 +6420,6 @@ bool CStaticFunctionDefinitions::BindKey(const char* szKey, const char* szHitSta
64206420
return bSuccess;
64216421
}
64226422

6423-
static inline void BindKeyAtHitState(CKeyBindsInterface* pKeyBinds, const char* szKey, const char* szCommandName, const char* szArguments, const char* szResource, const bool bHitState, bool& bSuccess)
6424-
{
6425-
// Check if its binded already (dont rebind)
6426-
if (!pKeyBinds->CommandExists(szKey, szCommandName, true, bHitState, szArguments, szResource, true, true))
6427-
{
6428-
if (pKeyBinds->AddCommand(szKey, szCommandName, szArguments, bHitState, szResource, true))
6429-
{
6430-
pKeyBinds->SetCommandActive(szKey, szCommandName, bHitState, szArguments, szResource, true, true);
6431-
bSuccess = true;
6432-
}
6433-
}
6434-
else
6435-
{
6436-
pKeyBinds->SetCommandActive(szKey, szCommandName, bHitState, szArguments, szResource, true, true);
6437-
bSuccess = true;
6438-
}
6439-
}
6440-
64416423
bool CStaticFunctionDefinitions::BindKey(const char* szKey, const char* szHitState, const char* szCommandName, const char* szArguments, const char* szResource)
64426424
{
64436425
assert(szKey);
@@ -6449,13 +6431,30 @@ bool CStaticFunctionDefinitions::BindKey(const char* szKey, const char* szHitSta
64496431
bool bKey = pKeyBinds->IsKey(szKey);
64506432
if (bKey)
64516433
{
6452-
if (!stricmp(szHitState, "down") || !stricmp(szHitState, "both"))
6434+
bool bHitState = true;
6435+
// Activate all keys for this command
6436+
pKeyBinds->SetAllCommandsActive(szResource, true, szCommandName, bHitState, szArguments, true);
6437+
// Check if its binded already (dont rebind)
6438+
if (pKeyBinds->CommandExists(szKey, szCommandName, true, bHitState, szArguments, szResource, true, true))
6439+
return true;
6440+
6441+
if ((!stricmp(szHitState, "down") || !stricmp(szHitState, "both")) &&
6442+
pKeyBinds->AddCommand(szKey, szCommandName, szArguments, bHitState, szResource, true))
64536443
{
6454-
BindKeyAtHitState(pKeyBinds, szKey, szCommandName, szArguments, szResource, true, bSuccess);
6444+
pKeyBinds->SetCommandActive(szKey, szCommandName, bHitState, szArguments, szResource, true, true);
6445+
bSuccess = true;
64556446
}
6456-
if (!stricmp(szHitState, "up") || !stricmp(szHitState, "both"))
6447+
6448+
bHitState = false;
6449+
pKeyBinds->SetAllCommandsActive(szResource, true, szCommandName, bHitState, szArguments, true);
6450+
if (pKeyBinds->CommandExists(szKey, szCommandName, true, bHitState, szArguments, szResource, true, true))
6451+
return true;
6452+
6453+
if ((!stricmp(szHitState, "up") || !stricmp(szHitState, "both")) &&
6454+
pKeyBinds->AddCommand(szKey, szCommandName, szArguments, bHitState, szResource, true))
64576455
{
6458-
BindKeyAtHitState(pKeyBinds, szKey, szCommandName, szArguments, szResource, false, bSuccess);
6456+
pKeyBinds->SetCommandActive(szKey, szCommandName, bHitState, szArguments, szResource, true, true);
6457+
bSuccess = true;
64596458
}
64606459
}
64616460
return bSuccess;
@@ -6511,14 +6510,29 @@ bool CStaticFunctionDefinitions::UnbindKey(const char* szKey, const char* szHitS
65116510
bool bKey = pKeyBinds->IsKey(szKey);
65126511
if (bKey)
65136512
{
6513+
bool bCheckHitState = false, bHitState = true;
6514+
if (szHitState)
6515+
{
6516+
if (stricmp(szHitState, "down") == 0)
6517+
{
6518+
bCheckHitState = true, bHitState = true;
6519+
}
6520+
else if (stricmp(szHitState, "up") == 0)
6521+
{
6522+
bCheckHitState = true, bHitState = false;
6523+
}
6524+
}
65146525
if ((!stricmp(szHitState, "down") || !stricmp(szHitState, "both")) &&
6515-
pKeyBinds->SetCommandActive(szKey, szCommandName, true, NULL, szResource, false, true))
6526+
pKeyBinds->SetCommandActive(szKey, szCommandName, bHitState, NULL, szResource, false, true))
65166527
{
6528+
pKeyBinds->SetAllCommandsActive(szResource, false, szCommandName, bHitState, NULL, true);
65176529
bSuccess = true;
65186530
}
6531+
bHitState = false;
65196532
if ((!stricmp(szHitState, "up") || !stricmp(szHitState, "both")) &&
6520-
pKeyBinds->SetCommandActive(szKey, szCommandName, false, NULL, szResource, false, true))
6533+
pKeyBinds->SetCommandActive(szKey, szCommandName, bHitState, NULL, szResource, false, true))
65216534
{
6535+
pKeyBinds->SetAllCommandsActive(szResource, false, szCommandName, bHitState, NULL, true);
65226536
bSuccess = true;
65236537
}
65246538
}

0 commit comments

Comments
 (0)