From 2586001d1dd57fcb247b561e09869ac267b0fd04 Mon Sep 17 00:00:00 2001 From: DrPerkyLegit Date: Thu, 16 Apr 2026 00:22:36 -0400 Subject: [PATCH] move translateables to chat format, restore original empty message results --- Minecraft.Client/ClientConnection.cpp | 10 +--------- Minecraft.Client/Common/Consoles_App.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Minecraft.Client/ClientConnection.cpp b/Minecraft.Client/ClientConnection.cpp index 41a337d29..41108ace0 100644 --- a/Minecraft.Client/ClientConnection.cpp +++ b/Minecraft.Client/ClientConnection.cpp @@ -65,7 +65,6 @@ #include "../Minecraft.World/DurangoStats.h" #include "../Minecraft.World/GenericStats.h" #endif -#include ClientConnection::ClientConnection(Minecraft *minecraft, const wstring& ip, int port) { @@ -1547,8 +1546,6 @@ void ClientConnection::handleChat(shared_ptr packet) bool replaceEntitySource = false; bool replaceItem = false; - static std::wregex IDS_Pattern(LR"(\{\*IDS_(\d+)\*\})"); //maybe theres a better way to do translateable IDS - int stringArgsSize = packet->m_stringArgs.size(); wstring playerDisplayName = L""; @@ -1565,15 +1562,10 @@ void ClientConnection::handleChat(shared_ptr packet) if (stringArgsSize >= 1) { message = packet->m_stringArgs[0]; - std::wsmatch match; - while (std::regex_search(message, match, IDS_Pattern)) { - message = replaceAll(message, match[0], app.GetString(std::stoi(match[1].str()))); - } - message = app.EscapeHTMLString(message); //do this to enforce escaped string message = app.FormatChatMessage(message); //this needs to be last cause it converts colors to html colors that would have been escaped } else { - message = L"empty message"; + message = L""; } displayOnGui = (packet->m_messageType == ChatPacket::e_ChatCustom); break; diff --git a/Minecraft.Client/Common/Consoles_App.cpp b/Minecraft.Client/Common/Consoles_App.cpp index 8e08abbc9..f7dda71d8 100644 --- a/Minecraft.Client/Common/Consoles_App.cpp +++ b/Minecraft.Client/Common/Consoles_App.cpp @@ -70,6 +70,7 @@ #endif #include "../Common/Leaderboards/LeaderboardManager.h" +#include //CMinecraftApp app; unsigned int CMinecraftApp::m_uiLastSignInData = 0; @@ -6620,6 +6621,7 @@ wstring CMinecraftApp::EscapeHTMLString(const wstring& desc) wstring CMinecraftApp::FormatChatMessage(const wstring& desc, bool applyColor) { + static std::wregex IDS_Pattern(LR"(\{\*IDS_(\d+)\*\})"); //maybe theres a better way to do translateable IDS static std::wstring_view colorFormatString = L""; wstring results = desc; @@ -6673,6 +6675,11 @@ wstring CMinecraftApp::FormatChatMessage(const wstring& desc, bool applyColor) swprintf(replacements, 64, (applyColor ? colorFormatString.data() : L""), GetHTMLColour(eHTMLColor_f), 0xFFFFFFFF); results = replaceAll(results, L"§f", replacements); + std::wsmatch match; + while (std::regex_search(results, match, IDS_Pattern)) { + results = replaceAll(results, match[0], app.GetString(std::stoi(match[1].str()))); + } + return results; }