Fix broken Chat Formatting behavior (#1520)

* fix formatting in chat

iggy doesnt like multiple shadow colors

* enforce html labels

* dont format before sending packet, client formats anyway

* move translateables to chat format, restore original empty message results

* fix crappy string cutoff

* forgot a line on last commit, reset color support

* restore function to strip styling from player messages
This commit is contained in:
DrPerkyLegit
2026-04-16 23:41:50 -04:00
committed by GitHub
parent cccfd860b9
commit 1a552fbd0c
5 changed files with 70 additions and 38 deletions

View File

@@ -65,7 +65,6 @@
#include "../Minecraft.World/DurangoStats.h"
#include "../Minecraft.World/GenericStats.h"
#endif
#include <regex>
ClientConnection::ClientConnection(Minecraft *minecraft, const wstring& ip, int port)
{
@@ -1547,8 +1546,6 @@ void ClientConnection::handleChat(shared_ptr<ChatPacket> 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<ChatPacket> 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;