From e84e0774a6ea5da748f63b8f3ceef9ab02d0e875 Mon Sep 17 00:00:00 2001 From: Jan Date: Fri, 20 Aug 2021 17:49:36 +0200 Subject: [PATCH 1/4] Fix material text icons with some techsets causing issues when rendering --- src/Components/Modules/Materials.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Components/Modules/Materials.cpp b/src/Components/Modules/Materials.cpp index 79d70a12..5b53c434 100644 --- a/src/Components/Modules/Materials.cpp +++ b/src/Components/Modules/Materials.cpp @@ -161,7 +161,12 @@ namespace Components Materials::ImageNameLength = 4 + length; std::string image(imagePtr, length); - return Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, image.data()).material; + auto* material = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, image.data()).material; + + if(material == nullptr || material->techniqueSet == nullptr || material->techniqueSet->name == nullptr || strcmp(material->techniqueSet->name, "2d") != 0) + return Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, "default").material; + + return material; } Materials::ImageNameLength = 4; From a7a8207a347468c97d5e47a32d2fc11ae41f9f52 Mon Sep 17 00:00:00 2001 From: Jan Date: Fri, 20 Aug 2021 18:36:36 +0200 Subject: [PATCH 2/4] Strip material text icons from chat messages --- src/Components/Modules/Dedicated.cpp | 25 +++++++++++++++++++++++++ src/Components/Modules/Dedicated.hpp | 2 ++ 2 files changed, 27 insertions(+) diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index 98a77fbc..71c40451 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -76,6 +76,29 @@ 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; @@ -87,6 +110,8 @@ namespace Components ++text; } + StripMaterialTextIcons(text); + Game::Scr_AddEntity(player); Game::Scr_AddString(text + 1); Game::Scr_NotifyLevel(Game::SL_GetString("say", 0), 2); diff --git a/src/Components/Modules/Dedicated.hpp b/src/Components/Modules/Dedicated.hpp index 002d28bb..0b362465 100644 --- a/src/Components/Modules/Dedicated.hpp +++ b/src/Components/Modules/Dedicated.hpp @@ -14,6 +14,8 @@ namespace Components static void Heartbeat(); + static void StripMaterialTextIcons(char* text); + private: static bool SendChat; From f3c2b999eb1f664baab8c2f62aa99cb3c7135520 Mon Sep 17 00:00:00 2001 From: Jan Date: Fri, 20 Aug 2021 18:37:08 +0200 Subject: [PATCH 3/4] Strip material text messages from server names --- src/Components/Modules/ServerList.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index 8ffd4861..70dad728 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -454,6 +454,9 @@ namespace Components ServerInfo server; server.hostname = info.get("hostname"); + + Dedicated::StripMaterialTextIcons(server.hostname.data()); + server.mapname = info.get("mapname"); server.gametype = info.get("gametype"); server.shortversion = info.get("shortversion"); From aaace9db35b03406794e431a7b339e4fd2aa31f0 Mon Sep 17 00:00:00 2001 From: Jan Date: Sat, 21 Aug 2021 12:35:32 +0200 Subject: [PATCH 4/4] Do not only strip material text icons from server names but for all server attributes that are displayed in the server list --- src/Components/Modules/ServerList.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index 70dad728..d7b1f3bc 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -454,9 +454,6 @@ namespace Components ServerInfo server; server.hostname = info.get("hostname"); - - Dedicated::StripMaterialTextIcons(server.hostname.data()); - server.mapname = info.get("mapname"); server.gametype = info.get("gametype"); server.shortversion = info.get("shortversion"); @@ -472,6 +469,11 @@ 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()); + // Remove server from queue i = ServerList::RefreshContainer.servers.erase(i);