diff --git a/src/client/component/colors.cpp b/src/client/component/colors.cpp index 470c0c5..e918a4f 100644 --- a/src/client/component/colors.cpp +++ b/src/client/component/colors.cpp @@ -87,7 +87,7 @@ namespace colors char* i_clean_str_stub(char* string) { - utils::string::strip(string, string, static_cast(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(0x140213E60)( local_client_num, index, buf, size, unk, unk2); - utils::string::strip(buf, buf, size); + utils::string::strip(buf, buf, static_cast(size)); return result; } diff --git a/src/client/component/dedicated_info.cpp b/src/client/component/dedicated_info.cpp index 9cc5b5c..761ae07 100644 --- a/src/client/component/dedicated_info.cpp +++ b/src/client/component/dedicated_info.cpp @@ -48,11 +48,10 @@ namespace dedicated_info } } - std::string cleaned_hostname; - cleaned_hostname.resize(static_cast(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(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, diff --git a/src/client/component/discord.cpp b/src/client/component/discord.cpp index 22d6a77..e1fdd6e 100644 --- a/src/client/component/discord.cpp +++ b/src/client/component/discord.cpp @@ -55,7 +55,7 @@ namespace discord // get server host name auto* const host_name = reinterpret_cast(0x141646CC4); - utils::string::strip(host_name, host_name, static_cast(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(0x1414CC290); diff --git a/src/common/utils/string.cpp b/src/common/utils/string.cpp index 653ecff..fc6d85b 100644 --- a/src/common/utils/string.cpp +++ b/src/common/utils/string.cpp @@ -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) { diff --git a/src/common/utils/string.hpp b/src/common/utils/string.hpp index 20fa482..28cea97 100644 --- a/src/common/utils/string.hpp +++ b/src/common/utils/string.hpp @@ -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);