mirror of
https://github.com/XLabsProject/s1x-client.git
synced 2023-08-02 15:02:12 +02:00
Merge pull request #350 from diamante0018/better-strip
[Utils] Refactor strip function
This commit is contained in:
commit
44b372f967
@ -87,7 +87,7 @@ namespace colors
|
||||
|
||||
char* i_clean_str_stub(char* string)
|
||||
{
|
||||
utils::string::strip(string, string, static_cast<int>(strlen(string)) + 1);
|
||||
utils::string::strip(string, string, std::strlen(string) + 1);
|
||||
|
||||
return string;
|
||||
}
|
||||
@ -99,7 +99,7 @@ namespace colors
|
||||
const auto result = reinterpret_cast<size_t(*)(int, int, char*, int, size_t, size_t)>(0x140213E60)(
|
||||
local_client_num, index, buf, size, unk, unk2);
|
||||
|
||||
utils::string::strip(buf, buf, size);
|
||||
utils::string::strip(buf, buf, static_cast<size_t>(size));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -48,11 +48,10 @@ namespace dedicated_info
|
||||
}
|
||||
}
|
||||
|
||||
std::string cleaned_hostname;
|
||||
cleaned_hostname.resize(static_cast<int>(strlen(sv_hostname->current.string) + 1));
|
||||
std::string cleaned_hostname = sv_hostname->current.string;
|
||||
|
||||
utils::string::strip(sv_hostname->current.string, cleaned_hostname.data(),
|
||||
static_cast<int>(strlen(sv_hostname->current.string)) + 1);
|
||||
cleaned_hostname.size() + 1);
|
||||
|
||||
console::set_title(utils::string::va("%s on %s [%d/%d] (%d)", cleaned_hostname.data(),
|
||||
mapname->current.string, client_count,
|
||||
|
@ -55,7 +55,7 @@ namespace discord
|
||||
|
||||
// get server host name
|
||||
auto* const host_name = reinterpret_cast<char*>(0x141646CC4);
|
||||
utils::string::strip(host_name, host_name, static_cast<int>(strlen(host_name)) + 1);
|
||||
utils::string::strip(host_name, host_name, std::strlen(host_name) + 1);
|
||||
|
||||
// get number of clients in game
|
||||
auto clients = reinterpret_cast<int*>(0x1414CC290);
|
||||
|
@ -105,12 +105,12 @@ namespace utils::string
|
||||
return {};
|
||||
}
|
||||
|
||||
void strip(const char* in, char* out, int max)
|
||||
void strip(const char* in, char* out, size_t max)
|
||||
{
|
||||
if (!in || !out) return;
|
||||
|
||||
max--;
|
||||
auto current = 0;
|
||||
auto current = 0u;
|
||||
while (*in != 0 && current < max)
|
||||
{
|
||||
const auto color_index = (*(in + 1) - 48) >= 0xC ? 7 : (*(in + 1) - 48);
|
||||
@ -128,11 +128,10 @@ namespace utils::string
|
||||
|
||||
++in;
|
||||
}
|
||||
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4100)
|
||||
std::string convert(const std::wstring& wstr)
|
||||
{
|
||||
std::string result;
|
||||
@ -158,7 +157,6 @@ namespace utils::string
|
||||
|
||||
return result;
|
||||
}
|
||||
#pragma warning(pop)
|
||||
|
||||
std::string replace(std::string str, const std::string& from, const std::string& to)
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ namespace utils::string
|
||||
|
||||
std::string get_clipboard_data();
|
||||
|
||||
void strip(const char* in, char* out, int max);
|
||||
void strip(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