From 1821d9072e6a335288047c7a41930f5692499e39 Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 7 Sep 2021 14:51:36 +0200 Subject: [PATCH] Use TextRenderer to strip material text icons from dedicated server names and chat messages --- src/Components/Modules/Dedicated.cpp | 25 +------------------------ src/Components/Modules/Dedicated.hpp | 2 -- src/Components/Modules/ServerList.cpp | 8 ++++---- 3 files changed, 5 insertions(+), 30 deletions(-) diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index 8f4f7806..c2716002 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -76,29 +76,6 @@ namespace Components } } - void Dedicated::StripMaterialTextIcons(char* text) - { - char* currentChar = text; - bool isEscaped = false; - while (*currentChar) - { - if (*currentChar == '^') - { - isEscaped = true; - } - else if(isEscaped == true && (*currentChar == '\x01' || *currentChar == '\x02')) - { - *currentChar = ' '; - } - else - { - isEscaped = false; - } - - currentChar++; - } - } - const char* Dedicated::EvaluateSay(char* text, Game::gentity_t* player) { Dedicated::SendChat = true; @@ -110,7 +87,7 @@ namespace Components ++text; } - StripMaterialTextIcons(text); + TextRenderer::StripMaterialTextIcons(text, text, strlen(text) + 1); Game::Scr_AddEntity(player); Game::Scr_AddString(text + 1); diff --git a/src/Components/Modules/Dedicated.hpp b/src/Components/Modules/Dedicated.hpp index 0b362465..002d28bb 100644 --- a/src/Components/Modules/Dedicated.hpp +++ b/src/Components/Modules/Dedicated.hpp @@ -14,8 +14,6 @@ namespace Components static void Heartbeat(); - static void StripMaterialTextIcons(char* text); - private: static bool SendChat; diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index 86b313e5..166f444f 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -469,10 +469,10 @@ namespace Components server.ping = (Game::Sys_Milliseconds() - i->sendTime); server.addr = address; - Dedicated::StripMaterialTextIcons(server.hostname.data()); - Dedicated::StripMaterialTextIcons(server.mapname.data()); - Dedicated::StripMaterialTextIcons(server.gametype.data()); - Dedicated::StripMaterialTextIcons(server.mod.data()); + server.hostname = TextRenderer::StripMaterialTextIcons(server.hostname); + server.mapname = TextRenderer::StripMaterialTextIcons(server.mapname); + server.gametype = TextRenderer::StripMaterialTextIcons(server.gametype); + server.mod = TextRenderer::StripMaterialTextIcons(server.mod); // Remove server from queue i = ServerList::RefreshContainer.servers.erase(i);