mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 11:49:17 +01:00
Use duplicate handler for patches
This commit is contained in:
parent
8f5ef9a7a6
commit
8435fb2566
34
src/api.cpp
34
src/api.cpp
@ -391,6 +391,23 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
||||
{
|
||||
Json::Value patch = patchnode[index];
|
||||
|
||||
// Check for duplicate patches in different languages and add languageId of duplicate patch to the original patch
|
||||
if (useDuplicateHandler)
|
||||
{
|
||||
bool bDuplicate = false;
|
||||
for (unsigned int j = 0; j < game.patches.size(); ++j)
|
||||
{
|
||||
if (game.patches[j].path == patch["link"].asString())
|
||||
{
|
||||
game.patches[j].language |= GlobalConstants::LANGUAGES[i].languageId; // Add language code to patch
|
||||
bDuplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bDuplicate)
|
||||
continue;
|
||||
}
|
||||
|
||||
game.patches.push_back(
|
||||
gameFile( false, /* patches don't have "updated" flag */
|
||||
patch["id"].isInt() ? std::to_string(patch["id"].asInt()) : patch["id"].asString(),
|
||||
@ -404,6 +421,23 @@ gameDetails API::getGameDetails(const std::string& game_name, const unsigned int
|
||||
}
|
||||
else // Patch is a single file
|
||||
{
|
||||
// Check for duplicate patches in different languages and add languageId of duplicate patch to the original patch
|
||||
if (useDuplicateHandler)
|
||||
{
|
||||
bool bDuplicate = false;
|
||||
for (unsigned int j = 0; j < game.patches.size(); ++j)
|
||||
{
|
||||
if (game.patches[j].path == patchnode["link"].asString())
|
||||
{
|
||||
game.patches[j].language |= GlobalConstants::LANGUAGES[i].languageId; // Add language code to patch
|
||||
bDuplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bDuplicate)
|
||||
continue;
|
||||
}
|
||||
|
||||
game.patches.push_back(
|
||||
gameFile( false, /* patches don't have "updated" flag */
|
||||
patchnode["id"].isInt() ? std::to_string(patchnode["id"].asInt()) : patchnode["id"].asString(),
|
||||
|
@ -312,10 +312,18 @@ void Downloader::listGames()
|
||||
std::cout << "patches: " << std::endl;
|
||||
for (unsigned int j = 0; j < games[i].patches.size(); ++j)
|
||||
{
|
||||
std::string languages;
|
||||
for (unsigned int k = 0; k < GlobalConstants::LANGUAGES.size(); k++) // Check which languages the installer supports
|
||||
{
|
||||
if (games[i].installers[j].language & GlobalConstants::LANGUAGES[k].languageId)
|
||||
languages += (languages.empty() ? "" : ", ")+GlobalConstants::LANGUAGES[k].languageString;
|
||||
}
|
||||
|
||||
std::cout << "\tid: " << games[i].patches[j].id << std::endl
|
||||
<< "\tname: " << games[i].patches[j].name << std::endl
|
||||
<< "\tpath: " << games[i].patches[j].path << std::endl
|
||||
<< "\tsize: " << games[i].patches[j].size << std::endl
|
||||
<< "\tlanguage: " << languages << std::endl
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user