diff --git a/dll/settings.cpp b/dll/settings.cpp index 6a6d6609..eb19297f 100644 --- a/dll/settings.cpp +++ b/dll/settings.cpp @@ -354,7 +354,7 @@ const std::map& Settings::getStats() const std::map::const_iterator Settings::setStatDefiniton(const std::string &name, const struct Stat_config &stat_config) { - auto ins_it = stats.insert_or_assign(common_helpers::ascii_to_lowercase(name), stat_config); + auto ins_it = stats.insert_or_assign(common_helpers::to_lower(name), stat_config); return ins_it.first; } diff --git a/dll/steam_user_stats.cpp b/dll/steam_user_stats.cpp index c804b087..b7905fa1 100644 --- a/dll/steam_user_stats.cpp +++ b/dll/steam_user_stats.cpp @@ -69,7 +69,7 @@ Steam_User_Stats::Steam_User_Stats(Settings *settings, class Networking *network try { trig.name = name; trig.value_operation = static_cast(it["progress"]["value"]["operation"]); - std::string stat_name = common_helpers::ascii_to_lowercase(static_cast(it["progress"]["value"]["operand1"])); + std::string stat_name = common_helpers::to_lower(static_cast(it["progress"]["value"]["operand1"])); trig.min_value = static_cast(it["progress"]["min_val"]); trig.max_value = static_cast(it["progress"]["max_val"]); achievement_stat_trigger[stat_name].push_back(trig); diff --git a/dll/steam_user_stats_leaderboard.cpp b/dll/steam_user_stats_leaderboard.cpp index 860a1cee..6a812915 100644 --- a/dll/steam_user_stats_leaderboard.cpp +++ b/dll/steam_user_stats_leaderboard.cpp @@ -81,7 +81,7 @@ std::vector Steam_User_Stats::load_leaderboard_entries( std::vector out{}; - std::string leaderboard_name(common_helpers::ascii_to_lowercase(name)); + std::string leaderboard_name(common_helpers::to_lower(name)); unsigned read_bytes = local_storage->file_size(Local_Storage::leaderboard_storage_folder, leaderboard_name); if ((read_bytes == 0) || (read_bytes < (ELEMENT_SIZE * MAIN_HEADER_ELEMENTS_COUNT)) || @@ -138,7 +138,7 @@ void Steam_User_Stats::save_my_leaderboard_entry(const Steam_Leaderboard &leader output.push_back(detail); } - std::string leaderboard_name(common_helpers::ascii_to_lowercase(leaderboard.name)); + std::string leaderboard_name(common_helpers::to_lower(leaderboard.name)); unsigned int buffer_size = static_cast(output.size() * sizeof(output[0])); // in bytes local_storage->store_data(Local_Storage::leaderboard_storage_folder, leaderboard_name, (char* )&output[0], buffer_size); } @@ -186,6 +186,7 @@ unsigned int Steam_User_Stats::cache_leaderboard_ifneeded(const std::string &nam // create a new entry in-memory and try reading the entries from disk struct Steam_Leaderboard new_board{}; + // don't make this lower/upper case, appid 1372280 later calls GetLeaderboardName() and hangs if the name wasn't the same as the original new_board.name = name; new_board.sort_method = eLeaderboardSortMethod; new_board.display_type = eLeaderboardDisplayType; diff --git a/dll/steam_user_stats_stats.cpp b/dll/steam_user_stats_stats.cpp index 6b8a20a0..7b892cef 100644 --- a/dll/steam_user_stats_stats.cpp +++ b/dll/steam_user_stats_stats.cpp @@ -28,7 +28,7 @@ bool Steam_User_Stats::clear_stats_internal() bool notify_server = false; for (const auto &stat : settings->getStats()) { - std::string stat_name(common_helpers::ascii_to_lowercase(stat.first)); + std::string stat_name(common_helpers::to_lower(stat.first)); switch (stat.second.type) { @@ -79,7 +79,7 @@ Steam_User_Stats::InternalSetResult Steam_User_Stats::set_stat_internal( Steam_User_Stats::InternalSetResult result{}; if (!pchName) return result; - std::string stat_name(common_helpers::ascii_to_lowercase(pchName)); + std::string stat_name(common_helpers::to_lower(pchName)); const auto &stats_config = settings->getStats(); auto stats_data = stats_config.find(stat_name); @@ -152,7 +152,7 @@ Steam_User_Stats::InternalSetResult> result{}; if (!pchName) return result; - std::string stat_name(common_helpers::ascii_to_lowercase(pchName)); + std::string stat_name(common_helpers::to_lower(pchName)); const auto &stats_config = settings->getStats(); auto stats_data = stats_config.find(stat_name); @@ -226,7 +226,7 @@ Steam_User_Stats::InternalSetResult> result{}; if (!pchName) return result; - std::string stat_name(common_helpers::ascii_to_lowercase(pchName)); + std::string stat_name(common_helpers::to_lower(pchName)); const auto &stats_config = settings->getStats(); auto stats_data = stats_config.find(stat_name); @@ -305,7 +305,7 @@ bool Steam_User_Stats::GetStat( const char *pchName, int32 *pData ) std::lock_guard lock(global_mutex); if (!pchName) return false; - std::string stat_name = common_helpers::ascii_to_lowercase(pchName); + std::string stat_name = common_helpers::to_lower(pchName); const auto &stats_config = settings->getStats(); auto stats_data = stats_config.find(stat_name); @@ -344,7 +344,7 @@ bool Steam_User_Stats::GetStat( const char *pchName, float *pData ) std::lock_guard lock(global_mutex); if (!pchName) return false; - std::string stat_name = common_helpers::ascii_to_lowercase(pchName); + std::string stat_name = common_helpers::to_lower(pchName); const auto &stats_config = settings->getStats(); auto stats_data = stats_config.find(stat_name); @@ -531,7 +531,7 @@ bool Steam_User_Stats::ResetAllStats( bool bAchievementsToo ) clear_stats_internal(); // this will save stats to disk if necessary if (!settings->disable_sharing_stats_with_gameserver) { for (const auto &stat : settings->getStats()) { - std::string stat_name(common_helpers::ascii_to_lowercase(stat.first)); + std::string stat_name(common_helpers::to_lower(stat.first)); auto &new_stat = (*pending_server_updates.mutable_user_stats())[stat_name]; new_stat.set_stat_type(stat.second.type); diff --git a/helpers/common_helpers.cpp b/helpers/common_helpers.cpp index f040fde0..f7e36f77 100644 --- a/helpers/common_helpers.cpp +++ b/helpers/common_helpers.cpp @@ -225,12 +225,6 @@ bool common_helpers::str_cmp_insensitive(std::wstring_view str1, std::wstring_vi }); } -std::string common_helpers::ascii_to_lowercase(std::string data) { - std::transform(data.begin(), data.end(), data.begin(), - [](char c){ return std::tolower(c); }); - return data; -} - void common_helpers::thisThreadYieldFor(std::chrono::microseconds u) { const auto start = std::chrono::high_resolution_clock::now(); diff --git a/helpers/common_helpers/common_helpers.hpp b/helpers/common_helpers/common_helpers.hpp index 7d6707a0..0f3b11eb 100644 --- a/helpers/common_helpers/common_helpers.hpp +++ b/helpers/common_helpers/common_helpers.hpp @@ -71,8 +71,6 @@ std::string uint8_vector_to_hex_string(const std::vector &v); bool str_cmp_insensitive(std::string_view str1, std::string_view str2); bool str_cmp_insensitive(std::wstring_view str1, std::wstring_view str2); -std::string ascii_to_lowercase(std::string data); - void thisThreadYieldFor(std::chrono::microseconds u); void consume_bom(std::ifstream &input);