From 19b1c114e62981408f17582e90b7548d9360c198 Mon Sep 17 00:00:00 2001 From: Diavolo Date: Mon, 24 Apr 2023 19:08:00 +0200 Subject: [PATCH] small fixes --- src/client/component/workshop.cpp | 6 +++--- src/common/utils/string.cpp | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/client/component/workshop.cpp b/src/client/component/workshop.cpp index 42375b7c..29a00a6b 100644 --- a/src/client/component/workshop.cpp +++ b/src/client/component/workshop.cpp @@ -82,7 +82,7 @@ namespace workshop utils::string::copy(item.description, doc["Description"].GetString()); utils::string::copy(item.folderName, doc["FolderName"].GetString()); utils::string::copy(item.publisherId, doc["PublisherID"].GetString()); - item.publisherIdInteger = std::stoul(item.publisherId); + item.publisherIdInteger = std::strtoul(item.publisherId, nullptr, 10); } void load_usermap_content_stub(void* usermaps_count, int type) @@ -94,7 +94,7 @@ namespace workshop auto& usermap_data = game::usermapsPool[i]; // foldername == title -> non-steam workshop usercontent - if (std::strcmp(usermap_data.folderName, usermap_data.title)) + if (std::strcmp(usermap_data.folderName, usermap_data.title) != 0) { continue; } @@ -111,7 +111,7 @@ namespace workshop { auto& mod_data = game::modsPool[i]; - if (std::strcmp(mod_data.folderName, mod_data.title)) + if (std::strcmp(mod_data.folderName, mod_data.title) != 0) { continue; } diff --git a/src/common/utils/string.cpp b/src/common/utils/string.cpp index 7e87fe0a..88846e6b 100644 --- a/src/common/utils/string.cpp +++ b/src/common/utils/string.cpp @@ -68,11 +68,13 @@ namespace utils::string bool is_numeric(const std::string& text) { - if (text.size() <= 0 || !std::isdigit(text[0])) return false; - return std::ranges::all_of(text.begin(), text.end(), [](const char input) + auto it = text.begin(); + while (it != text.end() && std::isdigit(static_cast(*it))) { - return std::isdigit(input) != 0; - }); + ++it; + } + + return !text.empty() && it == text.end(); } std::string dump_hex(const std::string& data, const std::string& separator) @@ -154,9 +156,9 @@ namespace utils::string if (*in != '$' && *in != '{' && *in != '}') { *out++ = *in; - i++; + ++i; } - in++; + ++in; } *out = '\0';