From 8900291f0d937c42df0f79a6debe48e2453b6ce0 Mon Sep 17 00:00:00 2001 From: myT Date: Wed, 29 Nov 2017 18:25:09 +0100 Subject: [PATCH] fixed key release of bind '+vstr a b' wrongly executing 'b' when key press didn't execute 'a' --- changelog.txt | 2 ++ code/client/cl_keys.cpp | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 2a21e50..45c3bf4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,8 @@ DD Mmm 17 - 1.49 +fix: the release of a key bound to "+vstr a b" would execute "b" even though the key press didn't execute "a" + chg: r_brightness <0.25..32.0> (default: 2) replaces r_overBrightBits r_mapBrightness <0.25..32.0> (default: 2) replaces r_mapOverBrightBits the new cvars use floating-point values (more control) and a linear scale (more intuitive) diff --git a/code/client/cl_keys.cpp b/code/client/cl_keys.cpp index 543a561..3678e19 100644 --- a/code/client/cl_keys.cpp +++ b/code/client/cl_keys.cpp @@ -41,8 +41,9 @@ static qbool key_overstrikeMode; typedef struct { qbool down; - int repeats; // if > 1, it is autorepeating - char *binding; + qbool sendMinusCmd; // if +cmd was sent on first key press + int repeats; // if > 1, it is autorepeating + char *binding; } qkey_t; #define MAX_KEYS 256 @@ -966,7 +967,7 @@ static void CL_AddKeyUpCommands( int key, const char* kb ) for ( i = 0; ; i++ ) { if ( kb[i] == ';' || !kb[i] ) { *buttonPtr = '\0'; - if ( button[0] == '+') { + if ( button[0] == '+' && keys[key].sendMinusCmd ) { // button commands add keynum and time as parms so that multiple // sources can be discriminated and subframe corrected char cmd[1024]; @@ -1007,6 +1008,9 @@ void CL_KeyEvent( int key, qbool down, unsigned time ) if (down) { keys[key].repeats++; if ( keys[key].repeats == 1) { + const qbool cgameForwarding = (cls.cgameForwardInput & 2) && cgvm; + const qbool disconnected = cls.state == CA_DISCONNECTED; + keys[key].sendMinusCmd = !cls.keyCatchers && !cgameForwarding && !disconnected; anykeydown++; } } else { @@ -1201,7 +1205,8 @@ void Key_ClearStates() if ( keys[i].down ) { CL_KeyEvent( i, qfalse, 0 ); } - keys[i].down = 0; + keys[i].down = qfalse; + keys[i].sendMinusCmd = qfalse; keys[i].repeats = 0; }