From 7c50eb92993b95824b3fda6239233db9480f3327 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 26 Jul 2018 07:24:05 -0400 Subject: [PATCH] fix some silly goal sort logics --- src/DownloadManager.h | 2 +- src/Profile.cpp | 13 +++++++------ src/Profile.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/DownloadManager.h b/src/DownloadManager.h index 2970d2ffe6..e59cb0c56a 100644 --- a/src/DownloadManager.h +++ b/src/DownloadManager.h @@ -78,7 +78,7 @@ class DownloadablePack { class Packlist { public: int sortmode = 1; // 1=name 2=diff 3=size, init to name because that's the default- mina - int asc = true; // default sort + bool asc = true; // default sort vector packs; // Lua diff --git a/src/Profile.cpp b/src/Profile.cpp index 0a6ede3188..cbc99d4784 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -1600,18 +1600,19 @@ class LunaProfile : public Luna static int SetFromAll(T* p, lua_State *L) { p->FillGoalTable(); p->filtermode = 1; + p->asc = true; return 1; } static int SortByDate(T* p, lua_State* L) { if (p->sortmode == 1) if (p->asc) { - auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->timeassigned > b->timeassigned; }; // custom operators? + auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->timeassigned < b->timeassigned; }; // custom operators? sort(p->goaltable.begin(), p->goaltable.end(), comp); p->asc = false; return 1; } - auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->timeassigned < b->timeassigned; }; + auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->timeassigned > b->timeassigned; }; sort(p->goaltable.begin(), p->goaltable.end(), comp); p->sortmode = 1; p->asc = true; @@ -1621,12 +1622,12 @@ class LunaProfile : public Luna static int SortByRate(T* p, lua_State* L) { if (p->sortmode == 2) if (p->asc) { - auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->rate > b->rate; }; // custom operators? + auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->rate < b->rate; }; // custom operators? sort(p->goaltable.begin(), p->goaltable.end(), comp); p->asc = false; return 1; } - auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->rate < b->rate; }; + auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->rate > b->rate; }; sort(p->goaltable.begin(), p->goaltable.end(), comp); p->sortmode = 2; p->asc = true; @@ -1668,13 +1669,13 @@ class LunaProfile : public Luna static int SortByDiff(T* p, lua_State* L) { if (p->sortmode == 5) if (p->asc) { - auto comp = [](ScoreGoal* a, ScoreGoal* b) { return SONGMAN->GetStepsByChartkey(a->chartkey)->GetMSD(a->rate, 0) > + auto comp = [](ScoreGoal* a, ScoreGoal* b) { return SONGMAN->GetStepsByChartkey(a->chartkey)->GetMSD(a->rate, 0) < SONGMAN->GetStepsByChartkey(b->chartkey)->GetMSD(b->rate, 0); }; sort(p->goaltable.begin(), p->goaltable.end(), comp); p->asc = false; return 3; } - auto comp = [](ScoreGoal* a, ScoreGoal* b) { return SONGMAN->GetStepsByChartkey(a->chartkey)->GetMSD(a->rate, 0) < + auto comp = [](ScoreGoal* a, ScoreGoal* b) { return SONGMAN->GetStepsByChartkey(a->chartkey)->GetMSD(a->rate, 0) > SONGMAN->GetStepsByChartkey(b->chartkey)->GetMSD(b->rate, 0); }; sort(p->goaltable.begin(), p->goaltable.end(), comp); p->sortmode = 5; diff --git a/src/Profile.h b/src/Profile.h index 0a7526b54e..edb0b4a802 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -277,7 +277,7 @@ class Profile vector goaltable; int sortmode = 1; // 1=date 2=rate 3=name 4=priority 5=diff, init to name because that's the default- mina int filtermode = 1; // 1=all, 2=completed, 3=uncompleted - int asc = false; + bool asc = false; bool HasGoal(const string& ck) { return goalmap.count(ck) == 1; } ScoreGoal& GetLowestGoalForRate(const string& ck, float rate);