Merge pull request #590 from diamante0018/main

small fixes
This commit is contained in:
Maurice Heumann 2023-04-24 19:15:56 +02:00 committed by GitHub
commit ca8fe5849d
2 changed files with 11 additions and 9 deletions

View File

@ -82,7 +82,7 @@ namespace workshop
utils::string::copy(item.description, doc["Description"].GetString()); utils::string::copy(item.description, doc["Description"].GetString());
utils::string::copy(item.folderName, doc["FolderName"].GetString()); utils::string::copy(item.folderName, doc["FolderName"].GetString());
utils::string::copy(item.publisherId, doc["PublisherID"].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) void load_usermap_content_stub(void* usermaps_count, int type)
@ -94,7 +94,7 @@ namespace workshop
auto& usermap_data = game::usermapsPool[i]; auto& usermap_data = game::usermapsPool[i];
// foldername == title -> non-steam workshop usercontent // 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; continue;
} }
@ -111,7 +111,7 @@ namespace workshop
{ {
auto& mod_data = game::modsPool[i]; 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; continue;
} }

View File

@ -68,11 +68,13 @@ namespace utils::string
bool is_numeric(const std::string& text) bool is_numeric(const std::string& text)
{ {
if (text.size() <= 0 || !std::isdigit(text[0])) return false; auto it = text.begin();
return std::ranges::all_of(text.begin(), text.end(), [](const char input) while (it != text.end() && std::isdigit(static_cast<unsigned char>(*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) std::string dump_hex(const std::string& data, const std::string& separator)
@ -154,9 +156,9 @@ namespace utils::string
if (*in != '$' && *in != '{' && *in != '}') if (*in != '$' && *in != '{' && *in != '}')
{ {
*out++ = *in; *out++ = *in;
i++; ++i;
} }
in++; ++in;
} }
*out = '\0'; *out = '\0';