Keep a non-ASCII last letter in the server browser's tag name

tag_text dropped a trailing lead byte even when its character was whole, so
"Skate Café" was listed as "Skate Caf". The browser shows the tag name until
the server answers a query, so hosts without a forwarded query port kept it.
This commit is contained in:
xThrasherrr committed 2026-10-04 13:27:55 -06:00
1 parent 7e774f4f71
commit 5e557d184e
2 files changed
+18 -8

No files matched your search

+7 -8
View File
@@ -1,4 +1,5 @@
#include "steam_server.h"
#include "server_text.h"
#include "Extension/Multiplayer/Net/protocol.h"
#ifdef _WIN32
#include <Windows.h>
@@ -12,6 +13,7 @@
#include <thread>
#include <unistd.h>
#endif
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <optional>
@@ -45,14 +47,11 @@ struct SteamIP {
// Tags are comma separated, so a name loses its commas; the whole list must
// stay under Steam's 128 byte limit.
std::string tag_text(std::string_view text, std::size_t limit) {
std::string result;
for (const char c : text) {
if (result.size() >= limit) break;
result += c == ',' ? ' ' : c;
}
// Never end inside a UTF-8 sequence.
while (!result.empty() && (static_cast<unsigned char>(result.back()) & 0xC0) == 0x80) result.pop_back();
if (!result.empty() && (static_cast<unsigned char>(result.back()) & 0xC0) == 0xC0) result.pop_back();
std::string result(text);
std::replace(result.begin(), result.end(), ',', ' ');
// Cut at the limit only, and never through a character: a whole last character
// is kept ("Café" stays "Café"), one the limit splits is dropped.
cut_text(result, limit);
return result;
}
// Steam's library prints its own crash-reporting notes ("Setting breakpad