From 54bdbf531d9bfc868d2661077f56fc67a5e82a61 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 21 Jan 2025 13:06:50 +0300 Subject: Steam: emoticons processing --- protocols/Steam/src/steam_utils.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'protocols/Steam/src') diff --git a/protocols/Steam/src/steam_utils.cpp b/protocols/Steam/src/steam_utils.cpp index 8579c6830a..15ccc7dd1a 100644 --- a/protocols/Steam/src/steam_utils.cpp +++ b/protocols/Steam/src/steam_utils.cpp @@ -51,9 +51,14 @@ void DecodeBbcodes(SESSION_INFO *si, CMStringA &szText) if (iEnd == -1) return; + bool bPlaceFirst = false; CMStringA szReplace; + + auto *p = szText.c_str() + idx; + if (!strncmp(p, "emoticon", 8)) + szReplace = ":"; + if (!isClosing) { - auto *p = szText.c_str() + idx; if (!strncmp(p, "mention=", 8)) { CMStringW wszId(FORMAT, L"%lld", AccountIdToSteamId(_atoi64(p + 8))); if (auto *pUser = g_chatApi.UM_FindUser(si, wszId)) { @@ -63,6 +68,7 @@ void DecodeBbcodes(SESSION_INFO *si, CMStringA &szText) iEnd = iEnd2 + 10; szReplace.Format("%s:", T2Utf(pUser->pszNick).get()); + bPlaceFirst = true; } } else if (!strncmp(p, "lobbyinvite ", 12)) { @@ -72,9 +78,14 @@ void DecodeBbcodes(SESSION_INFO *si, CMStringA &szText) } else iEnd++, idx--; - szText.Delete(idx - 1, iEnd - idx + 1); - if (!szReplace.IsEmpty()) - szText = szReplace + szText; + idx--; + szText.Delete(idx, iEnd - idx); + if (!szReplace.IsEmpty()) { + if (bPlaceFirst) + szText = szReplace + szText; + else + szText.Insert(idx, szReplace); + } idx = iEnd; } } -- cgit v1.2.3