Use TextRenderer to strip material text icons from dedicated server names and chat messages

This commit is contained in:
Jan 2021-09-07 14:51:36 +02:00
parent 967eeb2989
commit 1821d9072e
3 changed files with 5 additions and 30 deletions

View File

@ -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) const char* Dedicated::EvaluateSay(char* text, Game::gentity_t* player)
{ {
Dedicated::SendChat = true; Dedicated::SendChat = true;
@ -110,7 +87,7 @@ namespace Components
++text; ++text;
} }
StripMaterialTextIcons(text); TextRenderer::StripMaterialTextIcons(text, text, strlen(text) + 1);
Game::Scr_AddEntity(player); Game::Scr_AddEntity(player);
Game::Scr_AddString(text + 1); Game::Scr_AddString(text + 1);

View File

@ -14,8 +14,6 @@ namespace Components
static void Heartbeat(); static void Heartbeat();
static void StripMaterialTextIcons(char* text);
private: private:
static bool SendChat; static bool SendChat;

View File

@ -469,10 +469,10 @@ namespace Components
server.ping = (Game::Sys_Milliseconds() - i->sendTime); server.ping = (Game::Sys_Milliseconds() - i->sendTime);
server.addr = address; server.addr = address;
Dedicated::StripMaterialTextIcons(server.hostname.data()); server.hostname = TextRenderer::StripMaterialTextIcons(server.hostname);
Dedicated::StripMaterialTextIcons(server.mapname.data()); server.mapname = TextRenderer::StripMaterialTextIcons(server.mapname);
Dedicated::StripMaterialTextIcons(server.gametype.data()); server.gametype = TextRenderer::StripMaterialTextIcons(server.gametype);
Dedicated::StripMaterialTextIcons(server.mod.data()); server.mod = TextRenderer::StripMaterialTextIcons(server.mod);
// Remove server from queue // Remove server from queue
i = ServerList::RefreshContainer.servers.erase(i); i = ServerList::RefreshContainer.servers.erase(i);