From 0b3f36313080a02d3c2a21e9574e88193afcdf1e Mon Sep 17 00:00:00 2001 From: MysterD Date: Sat, 31 Jul 2021 02:58:42 -0700 Subject: [PATCH] DJUI: Ignore garbage text inputs if there are no valid characters --- developer/dx.sh | 8 +------- src/pc/djui/djui_inputbox.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/developer/dx.sh b/developer/dx.sh index 28c87575..a5f6db7f 100644 --- a/developer/dx.sh +++ b/developer/dx.sh @@ -1,7 +1 @@ -function compiler() { - make RENDER_API=$1 WINDOW_API=$2 AUDIO_API=$3 CONTROLLER_API=$4 -} - -compiler D3D12 DXGI SDL2 SDL2 d3d12_2 - -./build/us_pc/sm64.us.f3dex2e.exe +make RENDER_API=D3D12 WINDOW_API=DXGI BETTERCAMERA=1 NODRAWINGDISTANCE=1 DEBUG=1 IMMEDIATELOAD=1 DEVELOPMENT=1 && ./build/us_pc/sm64.us.f3dex2e.exe diff --git a/src/pc/djui/djui_inputbox.c b/src/pc/djui/djui_inputbox.c index afb4d680..595d353e 100644 --- a/src/pc/djui/djui_inputbox.c +++ b/src/pc/djui/djui_inputbox.c @@ -307,6 +307,20 @@ static void djui_inputbox_on_text_input(struct DjuiBase *base, char* text) { int msgLen = strlen(msg); int textLen = strlen(text); + // make sure we're not just printing garbage characters + bool containsValidAscii = false; + char* tinput = text; + while (*tinput != NULL) { + if (*tinput >= '!' && *tinput <= '~') { + containsValidAscii = true; + break; + } + tinput++; + } + if (!containsValidAscii) { + return; + } + // truncate if (textLen + msgLen >= inputbox->bufferSize) { int space = (inputbox->bufferSize - msgLen);