From 1b0ffd778178301d0f17e8b596162f44a3be6e0c Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 25 May 2019 14:55:27 +0800 Subject: [PATCH] Fix wrong logic The error is caused by silly copy-paste error. Fixup 09ff735007e7aa650c7045d2546d95366b8147a4. --- src/base/bittorrent/trackerentry.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/base/bittorrent/trackerentry.cpp b/src/base/bittorrent/trackerentry.cpp index c32227ab5..9946f3ae7 100644 --- a/src/base/bittorrent/trackerentry.cpp +++ b/src/base/bittorrent/trackerentry.cpp @@ -116,11 +116,10 @@ int TrackerEntry::numSeeds() const #if (LIBTORRENT_VERSION_NUM < 10200) return nativeEntry().scrape_complete; #else - int max = -1; - return nativeEntry().endpoints.empty() ? -1 : nativeEntry().endpoints[0].scrape_incomplete; + int value = -1; for (const lt::announce_endpoint &endpoint : nativeEntry().endpoints) - max = std::max(max, endpoint.scrape_complete); - return max; + value = std::max(value, endpoint.scrape_complete); + return value; #endif } @@ -129,11 +128,10 @@ int TrackerEntry::numLeeches() const #if (LIBTORRENT_VERSION_NUM < 10200) return nativeEntry().scrape_incomplete; #else - int max = -1; - return nativeEntry().endpoints.empty() ? -1 : nativeEntry().endpoints[0].scrape_incomplete; + int value = -1; for (const lt::announce_endpoint &endpoint : nativeEntry().endpoints) - max = std::max(max, endpoint.scrape_incomplete); - return max; + value = std::max(value, endpoint.scrape_incomplete); + return value; #endif } @@ -142,11 +140,10 @@ int TrackerEntry::numDownloaded() const #if (LIBTORRENT_VERSION_NUM < 10200) return nativeEntry().scrape_downloaded; #else - int max = -1; - return nativeEntry().endpoints.empty() ? -1 : nativeEntry().endpoints[0].scrape_incomplete; + int value = -1; for (const lt::announce_endpoint &endpoint : nativeEntry().endpoints) - max = std::max(max, endpoint.scrape_downloaded); - return max; + value = std::max(value, endpoint.scrape_downloaded); + return value; #endif }