don't allow achievement trigger to propagate its error to next lines, this allows ahievements to be initialzied properly

This commit is contained in:
otavepto 2024-06-07 19:56:35 +03:00
parent f7c7d79e0a
commit 06189e303f

View File

@ -730,13 +730,15 @@ Steam_User_Stats::Steam_User_Stats(Settings *settings, class Networking *network
std::string name = static_cast<std::string const&>(it["name"]); std::string name = static_cast<std::string const&>(it["name"]);
sorted_achievement_names.push_back(name); sorted_achievement_names.push_back(name);
achievement_trigger trig; achievement_trigger trig{};
trig.name = name; try {
trig.value_operation = static_cast<std::string const&>(it["progress"]["value"]["operation"]); trig.name = name;
std::string stat_name = common_helpers::ascii_to_lowercase(static_cast<std::string const&>(it["progress"]["value"]["operand1"])); trig.value_operation = static_cast<std::string const&>(it["progress"]["value"]["operation"]);
trig.min_value = static_cast<std::string const&>(it["progress"]["min_val"]); std::string stat_name = common_helpers::ascii_to_lowercase(static_cast<std::string const&>(it["progress"]["value"]["operand1"]));
trig.max_value = static_cast<std::string const&>(it["progress"]["max_val"]); trig.min_value = static_cast<std::string const&>(it["progress"]["min_val"]);
achievement_stat_trigger[stat_name].push_back(trig); trig.max_value = static_cast<std::string const&>(it["progress"]["max_val"]);
achievement_stat_trigger[stat_name].push_back(trig);
} catch(...) {}
if (user_achievements.find(name) == user_achievements.end()) { if (user_achievements.find(name) == user_achievements.end()) {
user_achievements[name]["earned"] = false; user_achievements[name]["earned"] = false;
@ -744,11 +746,11 @@ Steam_User_Stats::Steam_User_Stats(Settings *settings, class Networking *network
user_achievements[name]["progress"] = std::stoi(trig.min_value); user_achievements[name]["progress"] = std::stoi(trig.min_value);
user_achievements[name]["max_progress"] = std::stoi(trig.max_value); user_achievements[name]["max_progress"] = std::stoi(trig.max_value);
} }
} catch (...) {} } catch(...) {}
try { try {
it["hidden"] = std::to_string(it["hidden"].get<int>()); it["hidden"] = std::to_string(it["hidden"].get<int>());
} catch (...) {} } catch(...) {}
it["displayName"] = get_value_for_language(it, "displayName", settings->get_language()); it["displayName"] = get_value_for_language(it, "displayName", settings->get_language());
it["description"] = get_value_for_language(it, "description", settings->get_language()); it["description"] = get_value_for_language(it, "description", settings->get_language());