Ignore:
Timestamp:
Jun 9, 2008, 11:58:31 PM (14 years ago)
Author:
charles
Message:

(libT) make tr_torrentAmountFinished() look at the same pieces as tr_torrentAvailability() for consistency's sake as requested by BentMyWookie?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/completion.c

    r6102 r6108  
    306306{
    307307    int i;
    308     const int isComplete = tr_cpGetStatus ( cp ) == TR_CP_COMPLETE;
    309     const int tabSpan = cp->tor->blockCount / tabCount;
    310     tr_block_index_t block_i = 0;
    311     for( i=0; i<tabCount; ++i ) {
    312         if( isComplete )
    313             tab[i] = 1.0f;
    314         else {
    315             int loop, have;
    316             for( loop=have=0; loop<tabSpan; ++loop )
    317                 if( tr_cpBlockIsComplete( cp, block_i++ ) )
    318                     ++have;
    319             tab[i] = (float)have / tabSpan;
    320         }
     308    const tr_torrent * tor = cp->tor;
     309    const float interval = tor->info.pieceCount / (float)tabCount;
     310    const int isComplete = tr_cpGetStatus ( tor->completion ) == TR_CP_COMPLETE;
     311
     312    for( i=0; i<tabCount; ++i )
     313    {
     314        const tr_piece_index_t piece = i * interval;
     315
     316        if( tor == NULL )
     317            tab[i] = 0;
     318        else if( isComplete || tr_cpPieceIsComplete( cp, piece ) )
     319            tab[i] = -1;
     320        else
     321            tab[i] = (float)cp->completeBlocks[piece] / tr_torPieceCountBlocks( tor, piece );
    321322    }
    322323}
Note: See TracChangeset for help on using the changeset viewer.