From 7f8ccd92f67e84873c91668a06fa47cdb4ea1448 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 18 Jul 2018 02:14:42 -0300 Subject: [PATCH] Make a bundle in c++ use pointers --- src/DownloadManager.cpp | 16 ++++++++-------- src/DownloadManager.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/DownloadManager.cpp b/src/DownloadManager.cpp index 9da3244577..ab48a454f0 100644 --- a/src/DownloadManager.cpp +++ b/src/DownloadManager.cpp @@ -976,8 +976,8 @@ void DownloadManager::RequestChartLeaderBoard(string chartkey) SendRequest("/charts/"+chartkey+"/leaderboards", vector>(), done, true); } -vector DownloadManager::GetCoreBundle(string whichoneyo) { - vector bundle; +vector DownloadManager::GetCoreBundle(string whichoneyo) { + vector bundle; auto done = [this, &bundle](HTTPRequest& req, CURLMsg *) { try { json j= json::parse(req.result); @@ -990,7 +990,7 @@ vector DownloadManager::GetCoreBundle(string whichoneyo) { auto dlPack = find_if(dlPacks.begin(), dlPacks.end(), [&name](DownloadablePack x) { return x.name == name; }); if(dlPack != dlPacks.end()) - bundle.emplace_back(*dlPack); + bundle.emplace_back(dlPack); } } catch (exception e) { } @@ -1001,8 +1001,8 @@ vector DownloadManager::GetCoreBundle(string whichoneyo) { void DownloadManager::DownloadCoreBundle(string whichoneyo) { auto bundle = GetCoreBundle(whichoneyo); - sort(bundle.begin(), bundle.end(), [](DownloadablePack x1, DownloadablePack x2) {return x1.size < x2.size; }); - std::deque* list = new std::deque(); + sort(bundle.begin(), bundle.end(), [](DownloadablePack* x1, DownloadablePack* x2) {return x1->size < x2->size; }); + std::deque* list = new std::deque(); std::move( begin(bundle), end(bundle), @@ -1018,14 +1018,14 @@ void DownloadManager::DownloadCoreBundle(string whichoneyo) { if (it != list->end()) { auto pack = *it; list->pop_front(); - auto newDl = DLMAN->DownloadAndInstallPack(pack.url); + auto newDl = DLMAN->DownloadAndInstallPack(pack->url); newDl->Done = dl->Done; } else { delete list; } }; - auto dl = DLMAN->DownloadAndInstallPack(pack.url); + auto dl = DLMAN->DownloadAndInstallPack(pack->url); dl->Done = down; } @@ -1589,7 +1589,7 @@ class LunaDownloadManager : public Luna auto bundle = DLMAN->GetCoreBundle(SArg(1)); lua_createtable(L, bundle.size(), 0); for (int i = 0; i < bundle.size(); ++i) { - bundle[i].PushSelf(L); + bundle[i]->PushSelf(L); lua_rawseti(L, -2, i + 1); } return 1; diff --git a/src/DownloadManager.h b/src/DownloadManager.h index 7481a99db0..0eb4553c4e 100644 --- a/src/DownloadManager.h +++ b/src/DownloadManager.h @@ -200,7 +200,7 @@ class DownloadManager // most recent single score upload result -mina RString mostrecentresult = ""; void DownloadCoreBundle(string whichoneyo); - vector GetCoreBundle(string whichoneyo); + vector GetCoreBundle(string whichoneyo); // Lua void PushSelf(lua_State *L);