From 609af5e4b7b2c9fd38b27ca4254d1768c9cfdf1c Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Fri, 24 Jun 2022 14:23:12 +0200 Subject: [PATCH] Strip tilde/grave/space characters from console properly If input only contains the '~', '`' or ' ' character, it gets stripped from the input buffer. e.g. '````````' or '~' gets stripped, but 'script_ui printl("test `````")' or 'script_client printl("~CEngineClient()")' does not. --- r5dev/gameui/IConsole.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/r5dev/gameui/IConsole.cpp b/r5dev/gameui/IConsole.cpp index 8570b2e1..8a1cc666 100644 --- a/r5dev/gameui/IConsole.cpp +++ b/r5dev/gameui/IConsole.cpp @@ -765,6 +765,20 @@ int CConsole::TextEditCallback(ImGuiInputTextCallbackData* iData) } case ImGuiInputTextFlags_CallbackEdit: { + for (size_t i = 0, n = strlen(iData->Buf); i < n; i++) + { + if (iData->Buf[i] != '~' + && iData->Buf[i] != '`' + && iData->Buf[i] != ' ') + { + break; + } + else if (i == (n - 1)) + { + iData->DeleteChars(0, n); + } + } + m_bCanAutoComplete = true; BuildSummary(iData->Buf); break;