mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-02-01 21:42:31 +01:00
Use global constants to simplify adding support for more languages/platforms
This commit is contained in:
parent
c40b4d96fe
commit
3131b00589
@ -7,6 +7,8 @@
|
||||
#ifndef API_H
|
||||
#define API_H
|
||||
|
||||
#include "globalconstants.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <curl/curl.h>
|
||||
@ -15,31 +17,9 @@ extern "C" {
|
||||
}
|
||||
#include <cstring>
|
||||
|
||||
#define CONSUMER_KEY "1f444d14ea8ec776585524a33f6ecc1c413ed4a5"
|
||||
#define CONSUMER_SECRET "20d175147f9db9a10fc0584aa128090217b9cf88"
|
||||
#define OAUTH_VERIFIER_LENGTH 14
|
||||
#define OAUTH_TOKEN_LENGTH 11
|
||||
#define OAUTH_SECRET_LENGTH 18
|
||||
|
||||
#define INSTALLER_WINDOWS 1
|
||||
#define INSTALLER_MAC 2
|
||||
|
||||
#define LANGUAGE_EN 1
|
||||
#define LANGUAGE_DE 2
|
||||
#define LANGUAGE_FR 4
|
||||
#define LANGUAGE_PL 8
|
||||
#define LANGUAGE_RU 16
|
||||
#define LANGUAGE_CN 32
|
||||
#define LANGUAGE_CZ 64
|
||||
#define LANGUAGE_ES 128
|
||||
#define LANGUAGE_HU 256
|
||||
#define LANGUAGE_IT 512
|
||||
#define LANGUAGE_JP 1024
|
||||
#define LANGUAGE_TR 2048
|
||||
|
||||
class gameFile {
|
||||
public:
|
||||
gameFile(const bool& t_updated, const std::string& t_id, const std::string& t_name, const std::string& t_path, const std::string& t_size, const unsigned int& t_language = LANGUAGE_EN);
|
||||
gameFile(const bool& t_updated, const std::string& t_id, const std::string& t_name, const std::string& t_path, const std::string& t_size, const unsigned int& t_language = GlobalConstants::LANGUAGE_EN);
|
||||
bool updated;
|
||||
std::string id;
|
||||
std::string name;
|
||||
@ -101,7 +81,7 @@ class API
|
||||
std::string getResponseOAuth(const std::string& url);
|
||||
int getUserDetails();
|
||||
int getGames();
|
||||
gameDetails getGameDetails(const std::string& game_name, const unsigned int& type = INSTALLER_WINDOWS, const unsigned int& lang = LANGUAGE_EN);
|
||||
gameDetails getGameDetails(const std::string& game_name, const unsigned int& type = GlobalConstants::INSTALLER_WINDOWS, const unsigned int& lang = GlobalConstants::LANGUAGE_EN);
|
||||
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 getXML(const std::string& game_name, const std::string& id);
|
||||
|
65
include/globalconstants.h
Normal file
65
include/globalconstants.h
Normal file
@ -0,0 +1,65 @@
|
||||
/* This program is free software. It comes without any warranty, to
|
||||
* the extent permitted by applicable law. You can redistribute it
|
||||
* and/or modify it under the terms of the Do What The Fuck You Want
|
||||
* To Public License, Version 2, as published by Sam Hocevar. See
|
||||
* http://sam.zoy.org/wtfpl/COPYING for more details. */
|
||||
|
||||
#ifndef GLOBALCONSTANTS_H_INCLUDED
|
||||
#define GLOBALCONSTANTS_H_INCLUDED
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
namespace GlobalConstants
|
||||
{
|
||||
// API constants
|
||||
const std::string CONSUMER_KEY = "1f444d14ea8ec776585524a33f6ecc1c413ed4a5";
|
||||
const std::string CONSUMER_SECRET = "20d175147f9db9a10fc0584aa128090217b9cf88";
|
||||
const int OAUTH_VERIFIER_LENGTH = 14;
|
||||
const int OAUTH_TOKEN_LENGTH = 11;
|
||||
const int OAUTH_SECRET_LENGTH = 18;
|
||||
|
||||
// Language constants
|
||||
const unsigned int LANGUAGE_EN = 1;
|
||||
const unsigned int LANGUAGE_DE = 2;
|
||||
const unsigned int LANGUAGE_FR = 4;
|
||||
const unsigned int LANGUAGE_PL = 8;
|
||||
const unsigned int LANGUAGE_RU = 16;
|
||||
const unsigned int LANGUAGE_CN = 32;
|
||||
const unsigned int LANGUAGE_CZ = 64;
|
||||
const unsigned int LANGUAGE_ES = 128;
|
||||
const unsigned int LANGUAGE_HU = 256;
|
||||
const unsigned int LANGUAGE_IT = 512;
|
||||
const unsigned int LANGUAGE_JP = 1024;
|
||||
const unsigned int LANGUAGE_TR = 2048;
|
||||
|
||||
struct languageStruct {const unsigned int languageId; const std::string languageCode; const std::string languageString;};
|
||||
const std::vector<languageStruct> LANGUAGES =
|
||||
{
|
||||
{ LANGUAGE_EN, "en", "English" },
|
||||
{ LANGUAGE_DE, "de", "German" },
|
||||
{ LANGUAGE_FR, "fr", "French" },
|
||||
{ LANGUAGE_PL, "pl", "Polish" },
|
||||
{ LANGUAGE_RU, "ru", "Russian" },
|
||||
{ LANGUAGE_CN, "cn", "Chinese" },
|
||||
{ LANGUAGE_CZ, "cz", "Czech" },
|
||||
{ LANGUAGE_ES, "es", "Spanish" },
|
||||
{ LANGUAGE_HU, "hu", "Hungarian" },
|
||||
{ LANGUAGE_IT, "it", "Italian" },
|
||||
{ LANGUAGE_JP, "jp", "Japanese" },
|
||||
{ LANGUAGE_TR, "tr", "Turkish" }
|
||||
};
|
||||
|
||||
// Installer constants
|
||||
const unsigned int INSTALLER_WINDOWS = 1;
|
||||
const unsigned int INSTALLER_MAC = 2;
|
||||
|
||||
struct installerStruct {const unsigned int installerId; const std::string installerCode; const std::string installerString;};
|
||||
const std::vector<installerStruct> INSTALLERS =
|
||||
{
|
||||
{ INSTALLER_WINDOWS, "win", "Windows" },
|
||||
{ INSTALLER_MAC, "mac", "Mac" }
|
||||
};
|
||||
};
|
||||
|
||||
#endif // GLOBALCONSTANTS_H_INCLUDED
|
@ -51,6 +51,7 @@
|
||||
<Unit filename="include/api.h" />
|
||||
<Unit filename="include/config.h" />
|
||||
<Unit filename="include/downloader.h" />
|
||||
<Unit filename="include/globalconstants.h" />
|
||||
<Unit filename="include/progressbar.h" />
|
||||
<Unit filename="include/util.h" />
|
||||
<Unit filename="main.cpp" />
|
||||
|
51
main.cpp
51
main.cpp
@ -7,6 +7,7 @@
|
||||
#include "downloader.h"
|
||||
#include "config.h"
|
||||
#include "util.h"
|
||||
#include "globalconstants.h"
|
||||
#include "version.h" // generated by Makefile
|
||||
|
||||
#include <fstream>
|
||||
@ -50,27 +51,25 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Create help text for --platform option
|
||||
std::string platform_text = "Select which installers are downloaded\n"
|
||||
+ std::to_string(INSTALLER_WINDOWS) + " = Windows\n"
|
||||
+ std::to_string(INSTALLER_MAC) + " = Mac\n"
|
||||
+ std::to_string(INSTALLER_WINDOWS | INSTALLER_MAC) + " = Both";
|
||||
std::string platform_text = "Select which installers are downloaded\n";
|
||||
unsigned int platform_sum = 0;
|
||||
for (unsigned int i = 0; i < GlobalConstants::INSTALLERS.size(); ++i)
|
||||
{
|
||||
platform_text += std::to_string(GlobalConstants::INSTALLERS[i].installerId) + " = " + GlobalConstants::INSTALLERS[i].installerString + "\n";
|
||||
platform_sum += GlobalConstants::LANGUAGES[i].languageId;
|
||||
}
|
||||
platform_text += std::to_string(platform_sum) + " = All";
|
||||
|
||||
// Create help text for --language option
|
||||
std::string language_text = "Select which language installers are downloaded\n"
|
||||
+ std::to_string(LANGUAGE_EN) + " = English\n"
|
||||
+ std::to_string(LANGUAGE_DE) + " = German\n"
|
||||
+ std::to_string(LANGUAGE_FR) + " = French\n"
|
||||
+ std::to_string(LANGUAGE_PL) + " = Polish\n"
|
||||
+ std::to_string(LANGUAGE_RU) + " = Russian\n"
|
||||
+ std::to_string(LANGUAGE_CN) + " = Chinese\n"
|
||||
+ std::to_string(LANGUAGE_CZ) + " = Czech\n"
|
||||
+ std::to_string(LANGUAGE_ES) + " = Spanish\n"
|
||||
+ std::to_string(LANGUAGE_HU) + " = Hungarian\n"
|
||||
+ std::to_string(LANGUAGE_IT) + " = Italian\n"
|
||||
+ std::to_string(LANGUAGE_JP) + " = Japanese\n"
|
||||
+ std::to_string(LANGUAGE_TR) + " = Turkish\n"
|
||||
+ "Add the values to download multiple languages\n"
|
||||
+ "All = " + std::to_string(LANGUAGE_EN | LANGUAGE_DE | LANGUAGE_FR | LANGUAGE_PL | LANGUAGE_RU | LANGUAGE_CN | LANGUAGE_CZ | LANGUAGE_ES | LANGUAGE_HU | LANGUAGE_IT | LANGUAGE_JP | LANGUAGE_TR) + "\n"
|
||||
+ "French + Polish = " + std::to_string(LANGUAGE_FR) + "+" + std::to_string(LANGUAGE_PL) + " = " + std::to_string(LANGUAGE_FR | LANGUAGE_PL);
|
||||
std::string language_text = "Select which language installers are downloaded\n";
|
||||
unsigned int language_sum = 0;
|
||||
for (unsigned int i = 0; i < GlobalConstants::LANGUAGES.size(); ++i)
|
||||
{
|
||||
language_text += std::to_string(GlobalConstants::LANGUAGES[i].languageId) + " = " + GlobalConstants::LANGUAGES[i].languageString + "\n";
|
||||
language_sum += GlobalConstants::LANGUAGES[i].languageId;
|
||||
}
|
||||
language_text += "Add the values to download multiple languages\nAll = " + std::to_string(language_sum) + "\n"
|
||||
+ "French + Polish = " + std::to_string(GlobalConstants::LANGUAGE_FR) + "+" + std::to_string(GlobalConstants::LANGUAGE_PL) + " = " + std::to_string(GlobalConstants::LANGUAGE_FR | GlobalConstants::LANGUAGE_PL);
|
||||
|
||||
bpo::variables_map vm;
|
||||
bpo::options_description desc("Options");
|
||||
@ -93,8 +92,8 @@ int main(int argc, char *argv[])
|
||||
("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")
|
||||
("update-check", bpo::value<bool>(&config.bUpdateCheck)->zero_tokens()->default_value(false), "Check for update notifications")
|
||||
("platform", bpo::value<unsigned int>(&config.iInstallerType)->default_value(INSTALLER_WINDOWS), platform_text.c_str())
|
||||
("language", bpo::value<unsigned int>(&config.iInstallerLanguage)->default_value(LANGUAGE_EN), language_text.c_str())
|
||||
("platform", bpo::value<unsigned int>(&config.iInstallerType)->default_value(GlobalConstants::INSTALLER_WINDOWS), platform_text.c_str())
|
||||
("language", bpo::value<unsigned int>(&config.iInstallerLanguage)->default_value(GlobalConstants::LANGUAGE_EN), language_text.c_str())
|
||||
("no-installers", bpo::value<bool>(&config.bNoInstallers)->zero_tokens()->default_value(false), "Don't download/list/repair installers")
|
||||
("no-extras", bpo::value<bool>(&config.bNoExtras)->zero_tokens()->default_value(false), "Don't download/list/repair extras")
|
||||
("no-cover", bpo::value<bool>(&config.bNoCover)->zero_tokens()->default_value(false), "Don't download cover images")
|
||||
@ -153,12 +152,18 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (config.iInstallerType < INSTALLER_WINDOWS || config.iInstallerType > (INSTALLER_WINDOWS | INSTALLER_MAC))
|
||||
if (config.iInstallerType < GlobalConstants::INSTALLER_WINDOWS || config.iInstallerType > platform_sum)
|
||||
{
|
||||
std::cout << "Invalid value for --platform" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (config.iInstallerType < GlobalConstants::LANGUAGE_EN || config.iInstallerType > language_sum)
|
||||
{
|
||||
std::cout << "Invalid value for --language" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!config.sXMLDirectory.empty())
|
||||
{
|
||||
// Make sure that xml directory doesn't have trailing slash
|
||||
|
89
src/api.cpp
89
src/api.cpp
@ -121,16 +121,16 @@ int API::login(const std::string& email, const std::string& password)
|
||||
std::string token, secret;
|
||||
|
||||
// Get temporary request token
|
||||
url = oauth_sign_url2(this->config.oauth_get_temp_token.c_str(), NULL, OA_HMAC, NULL, CONSUMER_KEY, CONSUMER_SECRET, NULL /* token */, NULL /* secret */);
|
||||
url = oauth_sign_url2(this->config.oauth_get_temp_token.c_str(), NULL, OA_HMAC, NULL, GlobalConstants::CONSUMER_KEY.c_str(), GlobalConstants::CONSUMER_SECRET.c_str(), NULL /* token */, NULL /* secret */);
|
||||
|
||||
std::string request_token_resp = this->getResponse(url);
|
||||
|
||||
char **rv = NULL;
|
||||
int rc = oauth_split_url_parameters(request_token_resp.c_str(), &rv);
|
||||
qsort(rv, rc, sizeof(char *), oauth_cmpstringp);
|
||||
if (rc == 3 && !strncmp(rv[1], "oauth_token=", OAUTH_TOKEN_LENGTH) && !strncmp(rv[2], "oauth_token_secret=", OAUTH_SECRET_LENGTH)) {
|
||||
token = rv[1]+OAUTH_TOKEN_LENGTH+1;
|
||||
secret = rv[2]+OAUTH_SECRET_LENGTH+1;
|
||||
if (rc == 3 && !strncmp(rv[1], "oauth_token=", GlobalConstants::OAUTH_TOKEN_LENGTH) && !strncmp(rv[2], "oauth_token_secret=", GlobalConstants::OAUTH_SECRET_LENGTH)) {
|
||||
token = rv[1]+GlobalConstants::OAUTH_TOKEN_LENGTH+1;
|
||||
secret = rv[2]+GlobalConstants::OAUTH_SECRET_LENGTH+1;
|
||||
rv = NULL;
|
||||
}
|
||||
else
|
||||
@ -140,14 +140,14 @@ int API::login(const std::string& email, const std::string& password)
|
||||
|
||||
// Authorize temporary token and get verifier
|
||||
url = this->config.oauth_authorize_temp_token + "?username=" + oauth_url_escape(email.c_str()) + "&password=" + oauth_url_escape(password.c_str());
|
||||
url = oauth_sign_url2(url.c_str(), NULL, OA_HMAC, NULL, CONSUMER_KEY, CONSUMER_SECRET, token.c_str(), secret.c_str());
|
||||
url = oauth_sign_url2(url.c_str(), NULL, OA_HMAC, NULL, GlobalConstants::CONSUMER_KEY.c_str(), GlobalConstants::CONSUMER_SECRET.c_str(), token.c_str(), secret.c_str());
|
||||
std::string authorize_resp = this->getResponse(url);
|
||||
|
||||
std::string verifier;
|
||||
rc = oauth_split_url_parameters(authorize_resp.c_str(), &rv);
|
||||
qsort(rv, rc, sizeof(char *), oauth_cmpstringp);
|
||||
if (rc == 2 && !strncmp(rv[1], "oauth_verifier=", OAUTH_VERIFIER_LENGTH)) {
|
||||
verifier = rv[1]+OAUTH_VERIFIER_LENGTH+1;
|
||||
if (rc == 2 && !strncmp(rv[1], "oauth_verifier=", GlobalConstants::OAUTH_VERIFIER_LENGTH)) {
|
||||
verifier = rv[1]+GlobalConstants::OAUTH_VERIFIER_LENGTH+1;
|
||||
rv = NULL;
|
||||
}
|
||||
else
|
||||
@ -157,14 +157,14 @@ int API::login(const std::string& email, const std::string& password)
|
||||
|
||||
// Get final token and secret
|
||||
url = this->config.oauth_get_token + "?oauth_verifier=" + verifier;
|
||||
url = oauth_sign_url2(url.c_str(), NULL, OA_HMAC, NULL, CONSUMER_KEY, CONSUMER_SECRET, token.c_str(), secret.c_str());
|
||||
url = oauth_sign_url2(url.c_str(), NULL, OA_HMAC, NULL, GlobalConstants::CONSUMER_KEY.c_str(), GlobalConstants::CONSUMER_SECRET.c_str(), token.c_str(), secret.c_str());
|
||||
std::string token_resp = this->getResponse(url);
|
||||
|
||||
rc = oauth_split_url_parameters(token_resp.c_str(), &rv);
|
||||
qsort(rv, rc, sizeof(char *), oauth_cmpstringp);
|
||||
if (rc == 2 && !strncmp(rv[0], "oauth_token=", OAUTH_TOKEN_LENGTH) && !strncmp(rv[1], "oauth_token_secret=", OAUTH_SECRET_LENGTH)) {
|
||||
this->config.oauth_token = rv[0]+OAUTH_TOKEN_LENGTH+1;
|
||||
this->config.oauth_secret = rv[1]+OAUTH_SECRET_LENGTH+1;
|
||||
if (rc == 2 && !strncmp(rv[0], "oauth_token=", GlobalConstants::OAUTH_TOKEN_LENGTH) && !strncmp(rv[1], "oauth_token_secret=", GlobalConstants::OAUTH_SECRET_LENGTH)) {
|
||||
this->config.oauth_token = rv[0]+GlobalConstants::OAUTH_TOKEN_LENGTH+1;
|
||||
this->config.oauth_secret = rv[1]+GlobalConstants::OAUTH_SECRET_LENGTH+1;
|
||||
free(rv);
|
||||
res = 1;
|
||||
}
|
||||
@ -260,7 +260,7 @@ std::string API::getResponseOAuth(const std::string& url)
|
||||
#ifdef DEBUG
|
||||
std::cerr << "DEBUG INFO (API::getResponseOAuth)" << std::endl << "URL: " << url << std::endl;
|
||||
#endif
|
||||
std::string url_oauth = oauth_sign_url2(url.c_str(), NULL, OA_HMAC, NULL, CONSUMER_KEY, CONSUMER_SECRET, this->config.oauth_token.c_str(), this->config.oauth_secret.c_str());
|
||||
std::string url_oauth = oauth_sign_url2(url.c_str(), NULL, OA_HMAC, NULL, GlobalConstants::CONSUMER_KEY.c_str(), GlobalConstants::CONSUMER_SECRET.c_str(), this->config.oauth_token.c_str(), this->config.oauth_secret.c_str());
|
||||
std::string response = this->getResponse(url_oauth);
|
||||
|
||||
return response;
|
||||
@ -289,60 +289,21 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
||||
|
||||
// Installer details
|
||||
std::vector<std::pair<Json::Value,unsigned int>> installers;
|
||||
if (type & INSTALLER_WINDOWS)
|
||||
for (unsigned int i = 0; i < GlobalConstants::INSTALLERS.size(); ++i)
|
||||
{
|
||||
if (lang & LANGUAGE_EN)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_win_en"],LANGUAGE_EN));
|
||||
if (lang & LANGUAGE_DE)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_win_de"],LANGUAGE_DE));
|
||||
if (lang & LANGUAGE_FR)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_win_fr"],LANGUAGE_FR));
|
||||
if (lang & LANGUAGE_PL)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_win_pl"],LANGUAGE_PL));
|
||||
if (lang & LANGUAGE_RU)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_win_ru"],LANGUAGE_RU));
|
||||
if (lang & LANGUAGE_CN)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_win_cn"],LANGUAGE_CN));
|
||||
if (lang & LANGUAGE_CZ)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_win_cz"],LANGUAGE_CZ));
|
||||
if (lang & LANGUAGE_ES)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_win_es"],LANGUAGE_ES));
|
||||
if (lang & LANGUAGE_HU)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_win_hu"],LANGUAGE_HU));
|
||||
if (lang & LANGUAGE_IT)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_win_it"],LANGUAGE_IT));
|
||||
if (lang & LANGUAGE_JP)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_win_jp"],LANGUAGE_JP));
|
||||
if (lang & LANGUAGE_TR)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_win_tr"],LANGUAGE_TR));
|
||||
}
|
||||
if (type & INSTALLER_MAC)
|
||||
{
|
||||
if (lang & LANGUAGE_EN)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_mac_en"],LANGUAGE_EN));
|
||||
if (lang & LANGUAGE_DE)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_mac_de"],LANGUAGE_DE));
|
||||
if (lang & LANGUAGE_FR)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_mac_fr"],LANGUAGE_FR));
|
||||
if (lang & LANGUAGE_PL)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_mac_pl"],LANGUAGE_PL));
|
||||
if (lang & LANGUAGE_RU)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_mac_ru"],LANGUAGE_RU));
|
||||
if (lang & LANGUAGE_CN)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_mac_cn"],LANGUAGE_CN));
|
||||
if (lang & LANGUAGE_CZ)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_mac_cz"],LANGUAGE_CZ));
|
||||
if (lang & LANGUAGE_ES)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_mac_es"],LANGUAGE_ES));
|
||||
if (lang & LANGUAGE_HU)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_mac_hu"],LANGUAGE_HU));
|
||||
if (lang & LANGUAGE_IT)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_mac_it"],LANGUAGE_IT));
|
||||
if (lang & LANGUAGE_JP)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_mac_jp"],LANGUAGE_JP));
|
||||
if (lang & LANGUAGE_TR)
|
||||
installers.push_back(std::make_pair(root["game"]["installer_mac_tr"],LANGUAGE_TR));
|
||||
if (type & GlobalConstants::INSTALLERS[i].installerId)
|
||||
{
|
||||
std::string installer = "installer_" + GlobalConstants::INSTALLERS[i].installerCode + "_";
|
||||
for (unsigned int j = 0; j < GlobalConstants::LANGUAGES.size(); ++j)
|
||||
{
|
||||
if (lang & GlobalConstants::LANGUAGES[j].languageId)
|
||||
{
|
||||
installers.push_back(std::make_pair(root["game"][installer+GlobalConstants::LANGUAGES[j].languageCode],GlobalConstants::LANGUAGES[j].languageId));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( unsigned int i = 0; i < installers.size(); ++i )
|
||||
{
|
||||
for ( unsigned int index = 0; index < installers[i].first.size(); ++index )
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "downloader.h"
|
||||
#include "util.h"
|
||||
#include "globalconstants.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@ -264,31 +265,17 @@ void Downloader::fixInstallerLanguagePath(gameDetails& game)
|
||||
{
|
||||
for (unsigned int i = 0; i < game.installers.size(); ++i)
|
||||
{
|
||||
if (game.installers[i].language != LANGUAGE_EN)
|
||||
if (game.installers[i].language != GlobalConstants::LANGUAGE_EN)
|
||||
{
|
||||
std::string lang;
|
||||
if (game.installers[i].language == LANGUAGE_DE)
|
||||
lang = "_de_";
|
||||
else if (game.installers[i].language == LANGUAGE_FR)
|
||||
lang = "_fr_";
|
||||
else if (game.installers[i].language == LANGUAGE_PL)
|
||||
lang = "_pl_";
|
||||
else if (game.installers[i].language == LANGUAGE_RU)
|
||||
lang = "_ru_";
|
||||
else if (game.installers[i].language == LANGUAGE_CN)
|
||||
lang = "_cn_";
|
||||
else if (game.installers[i].language == LANGUAGE_CZ)
|
||||
lang = "_cz_";
|
||||
else if (game.installers[i].language == LANGUAGE_ES)
|
||||
lang = "_es_";
|
||||
else if (game.installers[i].language == LANGUAGE_HU)
|
||||
lang = "_hu_";
|
||||
else if (game.installers[i].language == LANGUAGE_IT)
|
||||
lang = "_it_";
|
||||
else if (game.installers[i].language == LANGUAGE_JP)
|
||||
lang = "_jp_";
|
||||
else if (game.installers[i].language == LANGUAGE_TR)
|
||||
lang = "_tr_";
|
||||
for (unsigned int j = 0; j < GlobalConstants::LANGUAGES.size(); ++j)
|
||||
{
|
||||
if (game.installers[i].language == GlobalConstants::LANGUAGES[j].languageId)
|
||||
{
|
||||
lang = "_" + GlobalConstants::LANGUAGES[j].languageCode + "_";
|
||||
break;
|
||||
}
|
||||
}
|
||||
boost::match_results<std::string::const_iterator> what;
|
||||
boost::regex expression(lang, boost::regex::perl | boost::regex::icase);
|
||||
if (!boost::regex_search(game.installers[i].path, what, expression))
|
||||
|
Loading…
x
Reference in New Issue
Block a user