From 3982ad31e6b60f334461a07345e12a8a0a783c7b Mon Sep 17 00:00:00 2001 From: Mr_Goldberg Date: Sat, 19 Oct 2019 12:00:45 -0400 Subject: [PATCH] Generate game infos improvements. For some reason https links didn't work. Auto generate a default_item_json. --- generate_game_infos/generate_game_infos.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/generate_game_infos/generate_game_infos.cpp b/generate_game_infos/generate_game_infos.cpp index 0ff8f50..7cbcaf3 100644 --- a/generate_game_infos/generate_game_infos.cpp +++ b/generate_game_infos/generate_game_infos.cpp @@ -352,7 +352,7 @@ static void generate_achievements(CurlEasy &easy) static void generate_items(CurlEasy& easy) { - std::string url = "https://api.steampowered.com/IInventoryService/GetItemDefMeta/v1?key="; + std::string url = "http://api.steampowered.com/IInventoryService/GetItemDefMeta/v1?key="; url += steam_apikey; url += "&appid="; url += app_id; @@ -365,7 +365,7 @@ static void generate_items(CurlEasy& easy) nlohmann::json json = nlohmann::json::parse(easy.get_answer()); std::string digest = json["response"]["digest"]; - url = "https://api.steampowered.com/IGameInventory/GetItemDefArchive/v0001?appid="; + url = "http://api.steampowered.com/IGameInventory/GetItemDefArchive/v0001?appid="; url += app_id; url += "&digest="; url += digest; @@ -374,8 +374,12 @@ static void generate_items(CurlEasy& easy) easy.perform(); nlohmann::json item_json = nlohmann::json::object(); + nlohmann::json default_item_json = nlohmann::json::object(); + json = nlohmann::json::parse(easy.get_answer()); std::ofstream items_file("items.json", std::ios::trunc | std::ios::out); + std::ofstream default_items_file("default_items.json", std::ios::trunc | std::ios::out); + for (auto &i : json) { for (auto j = i.begin(); j != i.end(); ++j) @@ -408,9 +412,11 @@ static void generate_items(CurlEasy& easy) } } item_json[i["itemdefid"].get()] = i; + default_item_json[i["itemdefid"].get()] = 1; } items_file << std::setw(2) << item_json; + default_items_file << std::setw(2) << default_item_json; } catch (std::exception& e) {