From 0d6edd227a13f1447938da1d1b020303c2545eb2 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Thu, 22 Feb 2018 18:15:53 -0600 Subject: [PATCH] Support Unicode characters greater than 0xFF in cl_consoleKeys Unrelated: make '0x' value be -1 (invalid) instead of 0. Reported by MAN-AT-ARMS. --- code/qcommon/q_shared.c | 8 ++++---- code/sdl/sdl_input.c | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/code/qcommon/q_shared.c b/code/qcommon/q_shared.c index aa17f1c1..a9fd68c7 100644 --- a/code/qcommon/q_shared.c +++ b/code/qcommon/q_shared.c @@ -660,15 +660,15 @@ Com_HexStrToInt */ int Com_HexStrToInt( const char *str ) { - if ( !str || !str[ 0 ] ) + if ( !str ) return -1; // check for hex code - if( str[ 0 ] == '0' && str[ 1 ] == 'x' ) + if( str[ 0 ] == '0' && str[ 1 ] == 'x' && str[ 2 ] != '\0' ) { - int i, n = 0; + int i, n = 0, len = strlen( str ); - for( i = 2; i < strlen( str ); i++ ) + for( i = 2; i < len; i++ ) { char digit; diff --git a/code/sdl/sdl_input.c b/code/sdl/sdl_input.c index 6af67518..9b957354 100644 --- a/code/sdl/sdl_input.c +++ b/code/sdl/sdl_input.c @@ -138,8 +138,7 @@ static qboolean IN_IsConsoleKey( keyNum_t key, int character ) if( !token[ 0 ] ) break; - if( strlen( token ) == 4 ) - charCode = Com_HexStrToInt( token ); + charCode = Com_HexStrToInt( token ); if( charCode > 0 ) {