piece availability should not be considered if no peers have it

This commit is contained in:
Mitchell Livingston 2007-02-14 02:02:44 +00:00
parent e2ba015b25
commit 7d569e7981
1 changed files with 6 additions and 3 deletions

View File

@ -1341,8 +1341,6 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
index = (int)indexValue; index = (int)indexValue;
} }
free(piecesAvailablity);
//determine percentage finished and available //determine percentage finished and available
int have, avail; int have, avail;
if ([self progress] >= 1.0) if ([self progress] >= 1.0)
@ -1362,7 +1360,10 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
float available = 0; float available = 0;
for (i = 0; i < pieceCount; i++) for (i = 0; i < pieceCount; i++)
available += 1.0 - piecesFinished[i]; {
if (piecesAvailablity[i] > 0)
available += 1.0 - piecesFinished[i];
}
have = rintf((float)MAX_PIECES * [self progress]); have = rintf((float)MAX_PIECES * [self progress]);
avail = rintf((float)MAX_PIECES * available / (float)pieceCount); avail = rintf((float)MAX_PIECES * available / (float)pieceCount);
@ -1372,6 +1373,8 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
free(piecesFinished); free(piecesFinished);
} }
free(piecesAvailablity);
//first two lines: dark blue to show progression, green to show available //first two lines: dark blue to show progression, green to show available
p = (uint32_t *)bitmapData; p = (uint32_t *)bitmapData;
for (i = 0; i < have; i++) for (i = 0; i < have; i++)