From 01d8479d189ee1ec3f39fe71c3711140d57cfb47 Mon Sep 17 00:00:00 2001 From: Sude Date: Thu, 24 Jul 2014 16:00:50 +0300 Subject: [PATCH] Remove the ugly hack to get details for Linux installers GOG fixed API response for Linux installers --- include/api.h | 2 +- src/api.cpp | 30 ------------------------------ 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/include/api.h b/include/api.h index 2ac2af4..a2f2fb2 100644 --- a/include/api.h +++ b/include/api.h @@ -85,7 +85,7 @@ class API std::string getResponseOAuth(const std::string& url); int getUserDetails(); int getGames(); - gameDetails getGameDetails(const std::string& game_name, const unsigned int& platform = GlobalConstants::PLATFORM_WINDOWS, const unsigned int& lang = GlobalConstants::LANGUAGE_EN, const bool& useDuplicateHandler = false); + gameDetails getGameDetails(const std::string& game_name, const unsigned int& platform = (GlobalConstants::PLATFORM_WINDOWS | GlobalConstants::PLATFORM_LINUX), const unsigned int& lang = GlobalConstants::LANGUAGE_EN, const bool& useDuplicateHandler = false); std::string getInstallerLink(const std::string& game_name, const std::string& id); std::string getExtraLink(const std::string& game_name, const std::string& id); std::string getPatchLink(const std::string& game_name, const std::string& id); diff --git a/src/api.cpp b/src/api.cpp index 626e003..8fa53f4 100644 --- a/src/api.cpp +++ b/src/api.cpp @@ -286,24 +286,6 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int game.title = root["game"]["title"].asString(); game.icon = root["game"]["icon"].asString(); - - // FIXME: Replace this ugly hack when GOG makes the API responses for Linux better - bool bIsLinux = false; - bool bIsMac = false; - if (type & (GlobalConstants::PLATFORM_LINUX | GlobalConstants::PLATFORM_MAC) ) - { - if (type & GlobalConstants::PLATFORM_LINUX) - bIsLinux = true; - else - bIsLinux = false; - if (type & GlobalConstants::PLATFORM_MAC) - bIsMac = true; - else - bIsMac = false; - type |= GlobalConstants::PLATFORM_MAC; // For some reason Linux installers are under Mac installer node so add Mac to installer type - } - - // Installer details // Create a list of installers from JSON std::vector> installers; @@ -348,18 +330,6 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int continue; } - // FIXME: Replace this ugly hack when GOG makes the API responses for Linux better - if (bIsLinux && !bIsMac) - { - if (installer["link"].asString().find("/mac/") != std::string::npos) - continue; - } - if (!bIsLinux && bIsMac) - { - if (installer["link"].asString().find("/linux/") != std::string::npos) - continue; - } - game.installers.push_back( gameFile( installer["notificated"].isInt() ? installer["notificated"].asInt() : std::stoi(installer["notificated"].asString()), installer["id"].isInt() ? std::to_string(installer["id"].asInt()) : installer["id"].asString(),