From b75bee106481f955898072010d30912facfbb36a Mon Sep 17 00:00:00 2001 From: Kacper K <149746050+kk1201@users.noreply.github.com> Date: Wed, 8 Jul 2026 21:51:08 +0100 Subject: [PATCH] Improve CD key prevalidation (#880) * Improve CD key prevalidation * Use tolower instead of ascii math --- code/client/cl_main.c | 31 ++++++++++++++----------------- code/q3_ui/ui_cdkey.c | 2 +- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/code/client/cl_main.c b/code/client/cl_main.c index 1fe312ef..086cc7e5 100644 --- a/code/client/cl_main.c +++ b/code/client/cl_main.c @@ -4719,26 +4719,23 @@ qboolean CL_CDKeyValidate( const char *key, const char *checksum ) { // for loop gets rid of conditional assignment warning for (i = 0; i < len; i++) { ch = *key++; - if (ch>='a' && ch<='z') { - ch -= 32; - } - switch( ch ) { + switch(tolower(ch)) { case '2': case '3': case '7': - case 'A': - case 'B': - case 'C': - case 'D': - case 'G': - case 'H': - case 'J': - case 'L': - case 'P': - case 'R': - case 'S': - case 'T': - case 'W': + case 'a': + case 'b': + case 'c': + case 'd': + case 'g': + case 'h': + case 'j': + case 'l': + case 'p': + case 'r': + case 's': + case 't': + case 'w': sum += ch; continue; default: diff --git a/code/q3_ui/ui_cdkey.c b/code/q3_ui/ui_cdkey.c index ec3029bd..c4c96f95 100644 --- a/code/q3_ui/ui_cdkey.c +++ b/code/q3_ui/ui_cdkey.c @@ -96,7 +96,7 @@ static int UI_CDKeyMenu_PreValidateKey( const char *key ) { } while( ( ch = *key++ ) ) { - switch( ch ) { + switch(tolower(ch)) { case '2': case '3': case '7':