From 49266cb9e4a9ac1fd1e043db154e93a0f471e249 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 17 Oct 2019 12:09:25 +0800 Subject: [PATCH] Replace boost::int64_t by std::int64_t --- src/base/bittorrent/torrenthandle.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index 5ad0565ab..497c31322 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -1071,7 +1071,11 @@ qulonglong TorrentHandle::eta() const QVector TorrentHandle::filesProgress() const { +#if (LIBTORRENT_VERSION_NUM < 10200) std::vector fp; +#else + std::vector fp; +#endif m_nativeHandle.file_progress(fp, lt::torrent_handle::piece_granularity); const int count = static_cast(fp.size()); @@ -1267,15 +1271,25 @@ int TorrentHandle::maxSeedingTime() const qreal TorrentHandle::realRatio() const { +#if (LIBTORRENT_VERSION_NUM < 10200) const boost::int64_t upload = m_nativeStatus.all_time_upload; // special case for a seeder who lost its stats, also assume nobody will import a 99% done torrent - const boost::int64_t download = (m_nativeStatus.all_time_download < m_nativeStatus.total_done * 0.01) ? m_nativeStatus.total_done : m_nativeStatus.all_time_download; + const boost::int64_t download = (m_nativeStatus.all_time_download < (m_nativeStatus.total_done * 0.01)) + ? m_nativeStatus.total_done + : m_nativeStatus.all_time_download; +#else + const int64_t upload = m_nativeStatus.all_time_upload; + // special case for a seeder who lost its stats, also assume nobody will import a 99% done torrent + const int64_t download = (m_nativeStatus.all_time_download < (m_nativeStatus.total_done * 0.01)) + ? m_nativeStatus.total_done + : m_nativeStatus.all_time_download; +#endif if (download == 0) - return (upload == 0) ? 0.0 : MAX_RATIO; + return (upload == 0) ? 0 : MAX_RATIO; const qreal ratio = upload / static_cast(download); - Q_ASSERT(ratio >= 0.0); + Q_ASSERT(ratio >= 0); return (ratio > MAX_RATIO) ? MAX_RATIO : ratio; }