Use proper type for piece index

This commit is contained in:
Chocobo1 2020-03-06 01:47:28 +08:00
parent ca01b049a6
commit 290d198977
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C

View File

@ -207,9 +207,15 @@ qlonglong PeerInfo::totalDownload() const
QBitArray PeerInfo::pieces() const
{
#if (LIBTORRENT_VERSION_NUM < 10200)
using PieceIndex = int;
#else
using PieceIndex = lt::piece_index_t;
#endif
QBitArray result(m_nativeInfo.pieces.size());
for (int i = 0; i < result.size(); ++i) {
if (m_nativeInfo.pieces[i])
if (m_nativeInfo.pieces[PieceIndex {i}])
result.setBit(i, true);
}
return result;