Malformed achievements config should not crash stuff anymore.

test_ci
Mr_Goldberg 2022-08-02 01:16:40 -04:00
parent 173c65a229
commit 0fc5a564e1
No known key found for this signature in database
GPG Key ID: 8597D87419DEF278
1 changed files with 13 additions and 0 deletions

View File

@ -134,6 +134,16 @@ Steam_User_Stats(Settings *settings, Local_Storage *local_storage, class SteamCa
load_achievements_db(); // achievements db
load_achievements(); // achievements per user
auto x = defined_achievements.begin();
while (x != defined_achievements.end()) {
if (!x->contains("name")) {
x = defined_achievements.erase(x);
} else {
++x;
}
}
for (auto & it : defined_achievements) {
try {
std::string name = static_cast<std::string const&>(it["name"]);
@ -155,6 +165,9 @@ Steam_User_Stats(Settings *settings, Local_Storage *local_storage, class SteamCa
try {
it["hidden"] = std::to_string(it["hidden"].get<int>());
} catch (...) {}
it["displayName"] = it.value("displayName", "");
it["description"] = it.value("description", "");
}
//TODO: not sure if the sort is actually case insensitive, ach names seem to be treated by steam as case insensitive so I assume they are.