diff options
-rw-r--r-- | c/defs.h | 10 | ||||
-rw-r--r-- | c/episodelistview.c | 10 |
2 files changed, 16 insertions, 4 deletions
@@ -28,6 +28,16 @@ HWND DlvCreate(); void DlvShowEpisode(int); inline int +Cmp(int a, int b) +{ + if (a == b) + return 0; + if (a > b) + return 1; + return -1; +} + +inline int Dpi(int i) { extern int IDPI; diff --git a/c/episodelistview.c b/c/episodelistview.c index bd5a28c..21a8e3d 100644 --- a/c/episodelistview.c +++ b/c/episodelistview.c @@ -193,9 +193,10 @@ ElvSort(LPARAM iItem1, LPARAM iItem2, LPARAM iSort) lvi1.iItem = iItem1; lvi2.iItem = iItem2; if (!ListView_GetItem(HElv, &lvi1)) return 0; if (!ListView_GetItem(HElv, &lvi2)) return 0; + iOrder = Cmp(iSort, 0); switch (abs(iSort)) { case 1: /* Sort by episode number. */ - iOrder = lvi1.lParam > lvi2.lParam? 1: -1; + return iOrder*Cmp(lvi1.lParam, lvi2.lParam); break; case 2: /* Sort by rating. */ { @@ -211,7 +212,9 @@ ElvSort(LPARAM iItem1, LPARAM iItem2, LPARAM iSort) PI(t2,lvi2.lParam) goto f; P("episode_data","episode_rating",2,t2) goto f; GI(t2+1,&iRating2); - f: iOrder = iRating1 > iRating2? 1: -1; + f: if (iRating1 == iRating2) + return Cmp(lvi1.lParam, lvi2.lParam); + return iOrder*Cmp(iRating1, iRating2); break; } case 3: /* Sort by title. */ @@ -230,13 +233,12 @@ ElvSort(LPARAM iItem1, LPARAM iItem2, LPARAM iSort) cch1 = strlen(sz1); cch2 = strlen(sz2); cch = cch1 > cch2? cch2: cch1; - iOrder = _strnicmp(sz1, sz2, cch); + return iOrder*_strnicmp(sz1, sz2, cch); break; } default: return 0; } - return iSort > 0? iOrder: iOrder*-1; } /* Update episode list. */ |