1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 17:42:29 +01:00

Refactor Version to use new JSON library

This commit is contained in:
Simon Jarrett
2020-08-18 14:27:35 +01:00
parent 2c92c652e2
commit 660c137958

View File

@@ -81,24 +81,12 @@ NewVersionInfo get_latest_version()
return {};
}
json_t* root = Json::FromString(res.body);
json_t root = Json::FromString(res.body);
auto get_as_string = [root](std::string name) {
std::string value;
json_t* json_value = json_object_get(root, name.c_str());
if (json_is_string(json_value))
{
value = (json_string_value(json_value));
}
return value;
};
verinfo.tag = get_as_string("tag_name");
verinfo.name = get_as_string("name");
verinfo.changelog = get_as_string("body");
verinfo.url = get_as_string("html_url");
json_decref(root);
verinfo.tag = Json::GetString(root["tag_name"]);
verinfo.name = Json::GetString(root["name"]);
verinfo.changelog = Json::GetString(root["body"]);
verinfo.url = Json::GetString(root["html_url"]);
gConfigGeneral.last_version_check_time = now;
config_save_default();