From 06189e303ff48c4a1cc961f343e017f9be3d4e3e Mon Sep 17 00:00:00 2001 From: otavepto <153766569+otavepto@users.noreply.github.com> Date: Fri, 7 Jun 2024 19:56:35 +0300 Subject: [PATCH] don't allow achievement trigger to propagate its error to next lines, this allows ahievements to be initialzied properly --- dll/steam_user_stats.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/dll/steam_user_stats.cpp b/dll/steam_user_stats.cpp index d8f1ae06..9806d2c3 100644 --- a/dll/steam_user_stats.cpp +++ b/dll/steam_user_stats.cpp @@ -730,25 +730,27 @@ Steam_User_Stats::Steam_User_Stats(Settings *settings, class Networking *network std::string name = static_cast(it["name"]); sorted_achievement_names.push_back(name); - achievement_trigger trig; - 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"])); - 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); - + achievement_trigger trig{}; + 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"])); + 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); + } catch(...) {} + if (user_achievements.find(name) == user_achievements.end()) { user_achievements[name]["earned"] = false; user_achievements[name]["earned_time"] = static_cast(0); user_achievements[name]["progress"] = std::stoi(trig.min_value); user_achievements[name]["max_progress"] = std::stoi(trig.max_value); } - } catch (...) {} + } catch(...) {} try { it["hidden"] = std::to_string(it["hidden"].get()); - } catch (...) {} + } catch(...) {} it["displayName"] = get_value_for_language(it, "displayName", settings->get_language()); it["description"] = get_value_for_language(it, "description", settings->get_language());