remove material strings from hostnames
This commit is contained in:
parent
6fecdeb68d
commit
c3d29e6675
@ -28,6 +28,13 @@ namespace steam
|
||||
::utils::concurrency::container<servers> queried_servers{};
|
||||
std::atomic<matchmaking_server_list_response*> current_response{};
|
||||
|
||||
template <typename T>
|
||||
void copy_safe(T& dest, const char* in)
|
||||
{
|
||||
::utils::string::copy(dest, in);
|
||||
::utils::string::strip_material(dest, dest, std::extent<T>::value);
|
||||
}
|
||||
|
||||
gameserveritem_t create_server_item(const game::netadr_t& address, const ::utils::info_string& info,
|
||||
const uint32_t ping, const bool success)
|
||||
{
|
||||
@ -40,9 +47,11 @@ namespace steam
|
||||
server.m_nPing = static_cast<int>(ping);
|
||||
server.m_bHadSuccessfulResponse = success;
|
||||
server.m_bDoNotRefresh = false;
|
||||
::utils::string::copy(server.m_szGameDir, "");
|
||||
::utils::string::copy(server.m_szMap, info.get("mapname").data());
|
||||
::utils::string::copy(server.m_szGameDescription, info.get("description").data());
|
||||
|
||||
copy_safe(server.m_szGameDir, "");
|
||||
copy_safe(server.m_szMap, info.get("mapname").data());
|
||||
copy_safe(server.m_szGameDescription, info.get("description").data());
|
||||
|
||||
server.m_nAppID = (sub_protocol == SUB_PROTOCOL || sub_protocol == (SUB_PROTOCOL - 1)) ? 311210 : 0;
|
||||
server.m_nPlayers = atoi(info.get("clients").data());
|
||||
server.m_nMaxPlayers = atoi(info.get("sv_maxclients").data());
|
||||
@ -51,7 +60,8 @@ namespace steam
|
||||
server.m_bSecure = true;
|
||||
server.m_ulTimeLastPlayed = 0;
|
||||
server.m_nServerVersion = 1000;
|
||||
::utils::string::copy(server.m_szServerName, info.get("hostname").data());
|
||||
|
||||
copy_safe(server.m_szServerName, info.get("hostname").data());
|
||||
|
||||
const auto playmode = info.get("playmode");
|
||||
const auto mode = game::eModes(std::atoi(playmode.data()));
|
||||
@ -66,7 +76,8 @@ namespace steam
|
||||
atoi(info.get("bots").data()),
|
||||
info.get("modname").data());
|
||||
|
||||
::utils::string::copy(server.m_szGameTags, tags);
|
||||
copy_safe(server.m_szGameTags, tags);
|
||||
|
||||
server.m_steamID.bits = strtoull(info.get("xuid").data(), nullptr, 16);
|
||||
|
||||
return server;
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "string.hpp"
|
||||
#include <sstream>
|
||||
#include <cstdarg>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdarg>
|
||||
#include <sstream>
|
||||
|
||||
#include "nt.hpp"
|
||||
|
||||
@ -107,11 +108,12 @@ namespace utils::string
|
||||
|
||||
void strip(const char* in, char* out, size_t max)
|
||||
{
|
||||
assert(max);
|
||||
if (!in || !out) return;
|
||||
|
||||
max--;
|
||||
size_t current = 0;
|
||||
while (*in != 0 && current < max)
|
||||
while (*in != '\0' && current < max)
|
||||
{
|
||||
const auto color_index = (*(in + 1) - 48) >= 0xC ? 7 : (*(in + 1) - 48);
|
||||
|
||||
@ -132,6 +134,25 @@ namespace utils::string
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
void strip_material(const char* in, char* out, size_t max)
|
||||
{
|
||||
assert(max);
|
||||
if (!in || !out) return;
|
||||
|
||||
size_t i = 0;
|
||||
while (*in != '\0' && i < max - 1)
|
||||
{
|
||||
if (*in != '$' && *in != '{' && *in != '}')
|
||||
{
|
||||
*out++ = *in;
|
||||
i++;
|
||||
}
|
||||
in++;
|
||||
}
|
||||
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
std::string convert(const std::wstring& wstr)
|
||||
{
|
||||
std::string result;
|
||||
|
@ -89,6 +89,7 @@ namespace utils::string
|
||||
std::string get_clipboard_data();
|
||||
|
||||
void strip(const char* in, char* out, size_t max);
|
||||
void strip_material(const char* in, char* out, size_t max);
|
||||
|
||||
std::string convert(const std::wstring& wstr);
|
||||
std::wstring convert(const std::string& str);
|
||||
|
Loading…
Reference in New Issue
Block a user