mirror of
https://github.com/transmission/transmission
synced 2025-03-01 01:05:36 +00:00
(libT) make tr_torrentAmountFinished() look at the same pieces as tr_torrentAvailability() for consistency's sake as requested by BentMyWookie
This commit is contained in:
parent
550a183d16
commit
adbbf82302
3 changed files with 17 additions and 18 deletions
|
@ -305,18 +305,19 @@ void
|
|||
tr_cpGetAmountDone( const tr_completion * cp, float * tab, int tabCount )
|
||||
{
|
||||
int i;
|
||||
const int isComplete = tr_cpGetStatus ( cp ) == TR_CP_COMPLETE;
|
||||
const int tabSpan = cp->tor->blockCount / tabCount;
|
||||
tr_block_index_t block_i = 0;
|
||||
for( i=0; i<tabCount; ++i ) {
|
||||
if( isComplete )
|
||||
tab[i] = 1.0f;
|
||||
else {
|
||||
int loop, have;
|
||||
for( loop=have=0; loop<tabSpan; ++loop )
|
||||
if( tr_cpBlockIsComplete( cp, block_i++ ) )
|
||||
++have;
|
||||
tab[i] = (float)have / tabSpan;
|
||||
}
|
||||
const tr_torrent * tor = cp->tor;
|
||||
const float interval = tor->info.pieceCount / (float)tabCount;
|
||||
const int isComplete = tr_cpGetStatus ( tor->completion ) == TR_CP_COMPLETE;
|
||||
|
||||
for( i=0; i<tabCount; ++i )
|
||||
{
|
||||
const tr_piece_index_t piece = i * interval;
|
||||
|
||||
if( tor == NULL )
|
||||
tab[i] = 0;
|
||||
else if( isComplete || tr_cpPieceIsComplete( cp, piece ) )
|
||||
tab[i] = -1;
|
||||
else
|
||||
tab[i] = (float)cp->completeBlocks[piece] / tr_torPieceCountBlocks( tor, piece );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1300,13 +1300,11 @@ tr_peerMgrTorrentAvailability( const tr_peerMgr * manager,
|
|||
|
||||
memset( tab, 0, tabCount );
|
||||
|
||||
for( i=0; i<tabCount; ++i )
|
||||
for( i=0; tor && i<tabCount; ++i )
|
||||
{
|
||||
const int piece = i * interval;
|
||||
|
||||
if( tor == NULL )
|
||||
tab[i] = 0;
|
||||
else if( isComplete || tr_cpPieceIsComplete( tor->completion, piece ) )
|
||||
if( isComplete || tr_cpPieceIsComplete( tor->completion, piece ) )
|
||||
tab[i] = -1;
|
||||
else if( peerCount ) {
|
||||
int j;
|
||||
|
|
|
@ -238,7 +238,7 @@ tr_rpcGetPort( const tr_rpc_server * server )
|
|||
* this stuff is worth it, you can buy me a beer in return.
|
||||
*/
|
||||
|
||||
#define DELIM_CHARS " ," /* Separators for lists */
|
||||
#define DELIM_CHARS "," /* Separators for lists */
|
||||
|
||||
#define FOR_EACH_WORD_IN_LIST(s,len) \
|
||||
for (; s != NULL && (len = strcspn(s, DELIM_CHARS)) != 0; \
|
||||
|
|
Loading…
Reference in a new issue