Changeset 6108


Ignore:
Timestamp:
Jun 9, 2008, 11:58:31 PM (13 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?

Location:
trunk/libtransmission
Files:
3 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}
  • trunk/libtransmission/peer-mgr.c

    r6103 r6108  
    13011301    memset( tab, 0, tabCount );
    13021302
    1303     for( i=0; i<tabCount; ++i )
     1303    for( i=0; tor && i<tabCount; ++i )
    13041304    {
    13051305        const int piece = i * interval;
    13061306
    1307         if( tor == NULL )
    1308             tab[i] = 0;
    1309         else if( isComplete || tr_cpPieceIsComplete( tor->completion, piece ) )
     1307        if( isComplete || tr_cpPieceIsComplete( tor->completion, piece ) )
    13101308            tab[i] = -1;
    13111309        else if( peerCount ) {
  • trunk/libtransmission/rpc-server.c

    r6106 r6108  
    239239 */
    240240
    241 #define  DELIM_CHARS " ," /* Separators for lists */
     241#define  DELIM_CHARS "," /* Separators for lists */
    242242
    243243#define FOR_EACH_WORD_IN_LIST(s,len)                                    \
Note: See TracChangeset for help on using the changeset viewer.