mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-02-02 05:52:31 +01:00
Some minor code cleanup
This commit is contained in:
parent
129768743e
commit
9b560d786e
@ -75,7 +75,7 @@ class Config
|
|||||||
std::vector<unsigned int> vLanguagePriority;
|
std::vector<unsigned int> vLanguagePriority;
|
||||||
std::vector<unsigned int> vPlatformPriority;
|
std::vector<unsigned int> vPlatformPriority;
|
||||||
|
|
||||||
unsigned int iInstallerType;
|
unsigned int iInstallerPlatform;
|
||||||
unsigned int iInstallerLanguage;
|
unsigned int iInstallerLanguage;
|
||||||
int iRetries;
|
int iRetries;
|
||||||
int iWait;
|
int iWait;
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
struct gameSpecificConfig
|
struct gameSpecificConfig
|
||||||
{
|
{
|
||||||
unsigned int iInstallerType;
|
unsigned int iInstallerPlatform;
|
||||||
unsigned int iInstallerLanguage;
|
unsigned int iInstallerLanguage;
|
||||||
bool bDLC;
|
bool bDLC;
|
||||||
bool bIgnoreDLCCount;
|
bool bIgnoreDLCCount;
|
||||||
|
6
main.cpp
6
main.cpp
@ -157,7 +157,7 @@ int main(int argc, char *argv[])
|
|||||||
("limit-rate", bpo::value<curl_off_t>(&config.iDownloadRate)->default_value(0), "Limit download rate to value in kB\n0 = unlimited")
|
("limit-rate", bpo::value<curl_off_t>(&config.iDownloadRate)->default_value(0), "Limit download rate to value in kB\n0 = unlimited")
|
||||||
("xml-directory", bpo::value<std::string>(&config.sXMLDirectory), "Set directory for GOG XML files")
|
("xml-directory", bpo::value<std::string>(&config.sXMLDirectory), "Set directory for GOG XML files")
|
||||||
("chunk-size", bpo::value<size_t>(&config.iChunkSize)->default_value(10), "Chunk size (in MB) when creating XML")
|
("chunk-size", bpo::value<size_t>(&config.iChunkSize)->default_value(10), "Chunk size (in MB) when creating XML")
|
||||||
("platform", bpo::value<unsigned int>(&config.iInstallerType)->default_value(GlobalConstants::PLATFORM_WINDOWS|GlobalConstants::PLATFORM_LINUX), platform_text.c_str())
|
("platform", bpo::value<unsigned int>(&config.iInstallerPlatform)->default_value(GlobalConstants::PLATFORM_WINDOWS|GlobalConstants::PLATFORM_LINUX), platform_text.c_str())
|
||||||
("language", bpo::value<unsigned int>(&config.iInstallerLanguage)->default_value(GlobalConstants::LANGUAGE_EN), language_text.c_str())
|
("language", bpo::value<unsigned int>(&config.iInstallerLanguage)->default_value(GlobalConstants::LANGUAGE_EN), language_text.c_str())
|
||||||
("no-installers", bpo::value<bool>(&bNoInstallers)->zero_tokens()->default_value(false), "Don't download/list/repair installers")
|
("no-installers", bpo::value<bool>(&bNoInstallers)->zero_tokens()->default_value(false), "Don't download/list/repair installers")
|
||||||
("no-extras", bpo::value<bool>(&bNoExtras)->zero_tokens()->default_value(false), "Don't download/list/repair extras")
|
("no-extras", bpo::value<bool>(&bNoExtras)->zero_tokens()->default_value(false), "Don't download/list/repair extras")
|
||||||
@ -338,7 +338,7 @@ int main(int argc, char *argv[])
|
|||||||
if (!config.sLanguagePriority.empty())
|
if (!config.sLanguagePriority.empty())
|
||||||
handle_priority("languages", config.sLanguagePriority, config.vLanguagePriority, config.iInstallerLanguage);
|
handle_priority("languages", config.sLanguagePriority, config.vLanguagePriority, config.iInstallerLanguage);
|
||||||
if (!config.sPlatformPriority.empty())
|
if (!config.sPlatformPriority.empty())
|
||||||
handle_priority("platforms", config.sPlatformPriority, config.vPlatformPriority, config.iInstallerType);
|
handle_priority("platforms", config.sPlatformPriority, config.vPlatformPriority, config.iInstallerPlatform);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
@ -352,7 +352,7 @@ int main(int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.iInstallerType < GlobalConstants::PLATFORMS[0].id || config.iInstallerType > platform_sum)
|
if (config.iInstallerPlatform < GlobalConstants::PLATFORMS[0].id || config.iInstallerPlatform > platform_sum)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid value for --platform" << std::endl;
|
std::cout << "Invalid value for --platform" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -275,7 +275,6 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
|||||||
{
|
{
|
||||||
std::string url;
|
std::string url;
|
||||||
gameDetails game;
|
gameDetails game;
|
||||||
unsigned int type = platform;
|
|
||||||
struct gameFileInfo
|
struct gameFileInfo
|
||||||
{
|
{
|
||||||
Json::Value jsonNode;
|
Json::Value jsonNode;
|
||||||
@ -305,7 +304,7 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
|||||||
std::vector<gameFileInfo> installers;
|
std::vector<gameFileInfo> installers;
|
||||||
for (unsigned int i = 0; i < GlobalConstants::PLATFORMS.size(); ++i)
|
for (unsigned int i = 0; i < GlobalConstants::PLATFORMS.size(); ++i)
|
||||||
{ // Check against the specified platforms
|
{ // Check against the specified platforms
|
||||||
if (type & GlobalConstants::PLATFORMS[i].id)
|
if (platform & GlobalConstants::PLATFORMS[i].id)
|
||||||
{
|
{
|
||||||
std::string installer = "installer_" + GlobalConstants::PLATFORMS[i].code + "_";
|
std::string installer = "installer_" + GlobalConstants::PLATFORMS[i].code + "_";
|
||||||
for (unsigned int j = 0; j < GlobalConstants::LANGUAGES.size(); ++j)
|
for (unsigned int j = 0; j < GlobalConstants::LANGUAGES.size(); ++j)
|
||||||
@ -402,7 +401,7 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
|||||||
else
|
else
|
||||||
patchInfo.platform = GlobalConstants::PLATFORM_WINDOWS;
|
patchInfo.platform = GlobalConstants::PLATFORM_WINDOWS;
|
||||||
|
|
||||||
if (type & patchInfo.platform)
|
if (platform & patchInfo.platform)
|
||||||
patches.push_back(patchInfo);
|
patches.push_back(patchInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,14 +249,14 @@ int Downloader::getGameDetails()
|
|||||||
conf.bDLC = config.bDLC;
|
conf.bDLC = config.bDLC;
|
||||||
conf.bIgnoreDLCCount = false;
|
conf.bIgnoreDLCCount = false;
|
||||||
conf.iInstallerLanguage = config.iInstallerLanguage;
|
conf.iInstallerLanguage = config.iInstallerLanguage;
|
||||||
conf.iInstallerType = config.iInstallerType;
|
conf.iInstallerPlatform = config.iInstallerPlatform;
|
||||||
if (!config.bUpdateCache) // Disable game specific config files for cache update
|
if (!config.bUpdateCache) // Disable game specific config files for cache update
|
||||||
{
|
{
|
||||||
if (Util::getGameSpecificConfig(gameItems[i].name, &conf) > 0)
|
if (Util::getGameSpecificConfig(gameItems[i].name, &conf) > 0)
|
||||||
std::cout << std::endl << gameItems[i].name << " - Language: " << conf.iInstallerLanguage << ", Platform: " << conf.iInstallerType << ", DLC: " << (conf.bDLC ? "true" : "false") << ", Ignore DLC count: " << (conf.bIgnoreDLCCount ? "true" : "false") << std::endl;
|
std::cout << std::endl << gameItems[i].name << " - Language: " << conf.iInstallerLanguage << ", Platform: " << conf.iInstallerPlatform << ", DLC: " << (conf.bDLC ? "true" : "false") << ", Ignore DLC count: " << (conf.bIgnoreDLCCount ? "true" : "false") << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
game = gogAPI->getGameDetails(gameItems[i].name, conf.iInstallerType, conf.iInstallerLanguage, config.bDuplicateHandler);
|
game = gogAPI->getGameDetails(gameItems[i].name, conf.iInstallerPlatform, conf.iInstallerLanguage, config.bDuplicateHandler);
|
||||||
if (!gogAPI->getError())
|
if (!gogAPI->getError())
|
||||||
{
|
{
|
||||||
game.filterWithPriorities(config);
|
game.filterWithPriorities(config);
|
||||||
@ -289,7 +289,7 @@ int Downloader::getGameDetails()
|
|||||||
for (unsigned int j = 0; j < gameItems[i].dlcnames.size(); ++j)
|
for (unsigned int j = 0; j < gameItems[i].dlcnames.size(); ++j)
|
||||||
{
|
{
|
||||||
gameDetails dlc;
|
gameDetails dlc;
|
||||||
dlc = gogAPI->getGameDetails(gameItems[i].dlcnames[j], conf.iInstallerType, conf.iInstallerLanguage, config.bDuplicateHandler);
|
dlc = gogAPI->getGameDetails(gameItems[i].dlcnames[j], conf.iInstallerPlatform, conf.iInstallerLanguage, config.bDuplicateHandler);
|
||||||
if (dlc.extras.empty() && config.bExtras) // Try to get extras from account page if API didn't return any extras
|
if (dlc.extras.empty() && config.bExtras) // Try to get extras from account page if API didn't return any extras
|
||||||
{
|
{
|
||||||
if (gameDetailsJSON.empty())
|
if (gameDetailsJSON.empty())
|
||||||
@ -2163,7 +2163,7 @@ std::vector<gameItem> Downloader::getGames()
|
|||||||
platform |= GlobalConstants::PLATFORM_LINUX;
|
platform |= GlobalConstants::PLATFORM_LINUX;
|
||||||
|
|
||||||
// Skip if platform doesn't match
|
// Skip if platform doesn't match
|
||||||
if (config.bPlatformDetection && !(platform & config.iInstallerType))
|
if (config.bPlatformDetection && !(platform & config.iInstallerPlatform))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Filter the game list
|
// Filter the game list
|
||||||
@ -3043,9 +3043,9 @@ std::vector<gameDetails> Downloader::getGameDetailsFromJsonNode(Json::Value root
|
|||||||
gameSpecificConfig conf;
|
gameSpecificConfig conf;
|
||||||
conf.bDLC = config.bDLC;
|
conf.bDLC = config.bDLC;
|
||||||
conf.iInstallerLanguage = config.iInstallerLanguage;
|
conf.iInstallerLanguage = config.iInstallerLanguage;
|
||||||
conf.iInstallerType = config.iInstallerType;
|
conf.iInstallerPlatform = config.iInstallerPlatform;
|
||||||
if (Util::getGameSpecificConfig(game.gamename, &conf) > 0)
|
if (Util::getGameSpecificConfig(game.gamename, &conf) > 0)
|
||||||
std::cout << game.gamename << " - Language: " << conf.iInstallerLanguage << ", Platform: " << conf.iInstallerType << ", DLC: " << (conf.bDLC ? "true" : "false") << std::endl;
|
std::cout << game.gamename << " - Language: " << conf.iInstallerLanguage << ", Platform: " << conf.iInstallerPlatform << ", DLC: " << (conf.bDLC ? "true" : "false") << std::endl;
|
||||||
|
|
||||||
for (unsigned int j = 0; j < nodes.size(); ++j)
|
for (unsigned int j = 0; j < nodes.size(); ++j)
|
||||||
{
|
{
|
||||||
@ -3069,7 +3069,7 @@ std::vector<gameDetails> Downloader::getGameDetailsFromJsonNode(Json::Value root
|
|||||||
fileDetails.language = fileDetailsNode["language"].asUInt();
|
fileDetails.language = fileDetailsNode["language"].asUInt();
|
||||||
fileDetails.silent = fileDetailsNode["silent"].asInt();
|
fileDetails.silent = fileDetailsNode["silent"].asInt();
|
||||||
|
|
||||||
if (nodeName != "extras" && !(fileDetails.platform & conf.iInstallerType))
|
if (nodeName != "extras" && !(fileDetails.platform & conf.iInstallerPlatform))
|
||||||
continue;
|
continue;
|
||||||
if (nodeName != "extras" && !(fileDetails.language & conf.iInstallerLanguage))
|
if (nodeName != "extras" && !(fileDetails.language & conf.iInstallerLanguage))
|
||||||
continue;
|
continue;
|
||||||
@ -3103,12 +3103,8 @@ std::vector<gameDetails> Downloader::getGameDetailsFromJsonNode(Json::Value root
|
|||||||
void Downloader::updateCache()
|
void Downloader::updateCache()
|
||||||
{
|
{
|
||||||
// Make sure that all details get cached
|
// Make sure that all details get cached
|
||||||
unsigned int all_platforms = GlobalConstants::PLATFORM_WINDOWS;
|
unsigned int all_platforms = (2 << (GlobalConstants::PLATFORMS.size() - 1)) - 1;
|
||||||
unsigned int all_languages = GlobalConstants::LANGUAGE_EN;
|
unsigned int all_languages = (2 << (GlobalConstants::LANGUAGES.size() - 1)) - 1;
|
||||||
for (unsigned int i = 0; i < GlobalConstants::PLATFORMS.size(); ++i)
|
|
||||||
all_platforms |= GlobalConstants::PLATFORMS[i].id;
|
|
||||||
for (unsigned int i = 0; i < GlobalConstants::LANGUAGES.size(); ++i)
|
|
||||||
all_languages |= GlobalConstants::LANGUAGES[i].id;
|
|
||||||
|
|
||||||
config.bExtras = true;
|
config.bExtras = true;
|
||||||
config.bInstallers = true;
|
config.bInstallers = true;
|
||||||
@ -3117,7 +3113,7 @@ void Downloader::updateCache()
|
|||||||
config.bDLC = true;
|
config.bDLC = true;
|
||||||
config.sGameRegex = ".*";
|
config.sGameRegex = ".*";
|
||||||
config.iInstallerLanguage = all_languages;
|
config.iInstallerLanguage = all_languages;
|
||||||
config.iInstallerType = all_platforms;
|
config.iInstallerPlatform = all_platforms;
|
||||||
config.vLanguagePriority.clear();
|
config.vLanguagePriority.clear();
|
||||||
config.vPlatformPriority.clear();
|
config.vPlatformPriority.clear();
|
||||||
|
|
||||||
@ -3266,7 +3262,7 @@ void Downloader::showWishlist()
|
|||||||
platform |= GlobalConstants::PLATFORM_LINUX;
|
platform |= GlobalConstants::PLATFORM_LINUX;
|
||||||
|
|
||||||
// Skip if platform doesn't match
|
// Skip if platform doesn't match
|
||||||
if (config.bPlatformDetection && !(platform & config.iInstallerType))
|
if (config.bPlatformDetection && !(platform & config.iInstallerPlatform))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (unsigned int j = 0; j < GlobalConstants::PLATFORMS.size(); ++j)
|
for (unsigned int j = 0; j < GlobalConstants::PLATFORMS.size(); ++j)
|
||||||
|
@ -245,7 +245,7 @@ int Util::getGameSpecificConfig(std::string gamename, gameSpecificConfig* conf,
|
|||||||
}
|
}
|
||||||
if (root.isMember("platform"))
|
if (root.isMember("platform"))
|
||||||
{
|
{
|
||||||
conf->iInstallerType = root["platform"].asUInt();
|
conf->iInstallerPlatform = root["platform"].asUInt();
|
||||||
res++;
|
res++;
|
||||||
}
|
}
|
||||||
if (root.isMember("dlc"))
|
if (root.isMember("dlc"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user