@@ -6408,6 +6408,24 @@ bool CStaticFunctionDefinitions::BindKey(const char* szKey, const char* szHitSta
6408
6408
return bSuccess;
6409
6409
}
6410
6410
6411
+ static inline void BindKeyAtHitState (CKeyBindsInterface* pKeyBinds, const char * szKey, const char * szCommandName, const char * szArguments, const char * szResource, const bool bHitState, bool & bSuccess)
6412
+ {
6413
+ // Check if its binded already (dont rebind)
6414
+ if (!pKeyBinds->CommandExists (szKey, szCommandName, true , bHitState, szArguments, szResource, true , true ))
6415
+ {
6416
+ if (pKeyBinds->AddCommand (szKey, szCommandName, szArguments, bHitState, szResource, true ))
6417
+ {
6418
+ pKeyBinds->SetCommandActive (szKey, szCommandName, bHitState, szArguments, szResource, true , true );
6419
+ bSuccess = true ;
6420
+ }
6421
+ }
6422
+ else
6423
+ {
6424
+ pKeyBinds->SetCommandActive (szKey, szCommandName, bHitState, szArguments, szResource, true , true );
6425
+ bSuccess = true ;
6426
+ }
6427
+ }
6428
+
6411
6429
bool CStaticFunctionDefinitions::BindKey (const char * szKey, const char * szHitState, const char * szCommandName, const char * szArguments, const char * szResource)
6412
6430
{
6413
6431
assert (szKey);
@@ -6419,30 +6437,13 @@ bool CStaticFunctionDefinitions::BindKey(const char* szKey, const char* szHitSta
6419
6437
bool bKey = pKeyBinds->IsKey (szKey);
6420
6438
if (bKey)
6421
6439
{
6422
- bool bHitState = true ;
6423
- // Activate all keys for this command
6424
- pKeyBinds->SetAllCommandsActive (szResource, true , szCommandName, bHitState, szArguments, true );
6425
- // Check if its binded already (dont rebind)
6426
- if (pKeyBinds->CommandExists (szKey, szCommandName, true , bHitState, szArguments, szResource, true , true ))
6427
- return true ;
6428
-
6429
- if ((!stricmp (szHitState, " down" ) || !stricmp (szHitState, " both" )) &&
6430
- pKeyBinds->AddCommand (szKey, szCommandName, szArguments, bHitState, szResource, true ))
6440
+ if (!stricmp (szHitState, " down" ) || !stricmp (szHitState, " both" ))
6431
6441
{
6432
- pKeyBinds->SetCommandActive (szKey, szCommandName, bHitState, szArguments, szResource, true , true );
6433
- bSuccess = true ;
6442
+ BindKeyAtHitState (pKeyBinds, szKey, szCommandName, szArguments, szResource, true , bSuccess);
6434
6443
}
6435
-
6436
- bHitState = false ;
6437
- pKeyBinds->SetAllCommandsActive (szResource, true , szCommandName, bHitState, szArguments, true );
6438
- if (pKeyBinds->CommandExists (szKey, szCommandName, true , bHitState, szArguments, szResource, true , true ))
6439
- return true ;
6440
-
6441
- if ((!stricmp (szHitState, " up" ) || !stricmp (szHitState, " both" )) &&
6442
- pKeyBinds->AddCommand (szKey, szCommandName, szArguments, bHitState, szResource, true ))
6444
+ if (!stricmp (szHitState, " up" ) || !stricmp (szHitState, " both" ))
6443
6445
{
6444
- pKeyBinds->SetCommandActive (szKey, szCommandName, bHitState, szArguments, szResource, true , true );
6445
- bSuccess = true ;
6446
+ BindKeyAtHitState (pKeyBinds, szKey, szCommandName, szArguments, szResource, false , bSuccess);
6446
6447
}
6447
6448
}
6448
6449
return bSuccess;
@@ -6498,29 +6499,14 @@ bool CStaticFunctionDefinitions::UnbindKey(const char* szKey, const char* szHitS
6498
6499
bool bKey = pKeyBinds->IsKey (szKey);
6499
6500
if (bKey)
6500
6501
{
6501
- bool bCheckHitState = false , bHitState = true ;
6502
- if (szHitState)
6503
- {
6504
- if (stricmp (szHitState, " down" ) == 0 )
6505
- {
6506
- bCheckHitState = true , bHitState = true ;
6507
- }
6508
- else if (stricmp (szHitState, " up" ) == 0 )
6509
- {
6510
- bCheckHitState = true , bHitState = false ;
6511
- }
6512
- }
6513
6502
if ((!stricmp (szHitState, " down" ) || !stricmp (szHitState, " both" )) &&
6514
- pKeyBinds->SetCommandActive (szKey, szCommandName, bHitState , NULL , szResource, false , true ))
6503
+ pKeyBinds->SetCommandActive (szKey, szCommandName, true , NULL , szResource, false , true ))
6515
6504
{
6516
- pKeyBinds->SetAllCommandsActive (szResource, false , szCommandName, bHitState, NULL , true );
6517
6505
bSuccess = true ;
6518
6506
}
6519
- bHitState = false ;
6520
6507
if ((!stricmp (szHitState, " up" ) || !stricmp (szHitState, " both" )) &&
6521
- pKeyBinds->SetCommandActive (szKey, szCommandName, bHitState , NULL , szResource, false , true ))
6508
+ pKeyBinds->SetCommandActive (szKey, szCommandName, false , NULL , szResource, false , true ))
6522
6509
{
6523
- pKeyBinds->SetAllCommandsActive (szResource, false , szCommandName, bHitState, NULL , true );
6524
6510
bSuccess = true ;
6525
6511
}
6526
6512
}
0 commit comments