Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gameclient): time key repeat in milliseconds, not input frames
Olcay Seygande03c52472d4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e0f90ef93..52c44d5d8 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -661,6 +661,7 @@ found and fixed — EA's own, not port damage.**- `help` lists what it takes, `clear` empties it, `echo` says a line back. The up and down arrows walk back through the last thirty-two things you typed.- It opens in the main menu as well as in a match. Nothing it does yet touches the rules of a game, so it is safe to leave open while one runs.- The general's promotion screen moved off that key onto the backslash beside it.+- One press is one letter. Holding a key repeats it, and the game timed that wait in frames: a third of a second at the 30 frames a second it was written for, 70 milliseconds on a 144 Hz screen, which is shorter than an ordinary keypress. It waits 0.4 seconds now whatever the frame rate, in the console, the chat box and every text field.## Your Razer hardware plays alongdiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Keyboard.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Keyboard.hindex 45973ed2f..27574409f 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Keyboard.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Keyboard.h@@ -87,7 +87,9 @@ struct KeyboardIOclass Keyboard : public SubsystemInterface{- enum { KEY_REPEAT_DELAY = 10 };+ // wall clock, not input frames: ten frames was a third of a second at the 30 fps the game+ // was written for and 70ms at 144, shorter than an ordinary keypress+ enum { KEY_REPEAT_DELAY_MS = 400, KEY_REPEAT_INTERVAL_MS = 40 };public:diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Keyboard.cppindex d5a87b02a..a3c6c0aec 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp@@ -150,7 +150,7 @@ void Keyboard::updateKeys( void )m_keyStatus[ m_keys[ index ].key ].state = m_keys[ index ].state;m_keyStatus[ m_keys[ index ].key ].status = m_keys[ index ].status;- m_keyStatus[ m_keys[ index ].key ].sequence = m_inputFrame;+ m_keyStatus[ m_keys[ index ].key ].sequence = timeGetTime();// prevent ALT-TAB from causing a TAB eventif( m_keys[ index ].key == KEY_TAB )@@ -222,6 +222,8 @@ Bool Keyboard::checkKeyRepeat( void )while( m_keys[ index ].key != KEY_NONE )index++;+ const UnsignedInt nowMs = timeGetTime();+// Scan Keyboard status array for first key down// long enough to repeatfor( key = 0; key < 256; key++ )@@ -230,7 +232,7 @@ Bool Keyboard::checkKeyRepeat( void )if( BitTest( m_keyStatus[ key ].state, KEY_STATE_DOWN ) ){- if( (m_inputFrame - m_keyStatus[ key ].sequence) > Keyboard::KEY_REPEAT_DELAY )+ if( (nowMs - m_keyStatus[ key ].sequence) > Keyboard::KEY_REPEAT_DELAY_MS ){// Add key to this framem_keys[ index ].key = (UnsignedByte)key;@@ -245,10 +247,10 @@ Bool Keyboard::checkKeyRepeat( void )// (own counter: this loop used to reuse `index`, the live write cursor into// m_keys, and only got away with it because of the break below.)for( Int resetIndex = 0; resetIndex < NUM_KEYS; resetIndex++ )- m_keyStatus[ resetIndex ].sequence = m_inputFrame;+ m_keyStatus[ resetIndex ].sequence = nowMs;- // Set repeated key so it will repeat again in two frames- m_keyStatus[ key ].sequence = m_inputFrame - (Keyboard::KEY_REPEAT_DELAY + 2);+ // Set repeated key so it will repeat again one interval from now+ m_keyStatus[ key ].sequence = nowMs - (Keyboard::KEY_REPEAT_DELAY_MS - Keyboard::KEY_REPEAT_INTERVAL_MS);retVal = TRUE;break; // exit for key