diff --git a/macosx/Torrent.h b/macosx/Torrent.h index 59fa4767f..e94e7cc49 100644 --- a/macosx/Torrent.h +++ b/macosx/Torrent.h @@ -101,6 +101,7 @@ - (float) ratioLimit; - (void) setRatioLimit: (float) limit; - (float) actualStopRatio; //returns INVALID if will not stop +- (float) progressStopRatio; - (int) checkUpload; - (void) setCheckUpload: (int) setting; diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 7119b0186..37e002e63 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -522,8 +522,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 if ([self isSeeding]) { - [info setObject: [NSNumber numberWithFloat: [self ratio]] forKey: @"Ratio"]; - [info setObject: [NSNumber numberWithFloat: [self actualStopRatio]] forKey: @"StopRatio"]; + [info setObject: [NSNumber numberWithFloat: [self progressStopRatio]] forKey: @"ProgressStopRatio"]; } if (![fDefaults boolForKey: @"SmallView"]) @@ -652,6 +651,17 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 return INVALID; } +- (float) progressStopRatio +{ + float stopRatio, ratio; + if ((stopRatio = [self actualStopRatio]) == INVALID || (ratio = [self ratio]) > stopRatio) + return 1.0; + else if (stopRatio > 0 && ratio > 0) + return ratio / stopRatio; + else + return 0; +} + - (int) checkUpload { return fCheckUpload; @@ -1409,17 +1419,9 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 - (NSNumber *) progressSortKey { - #warning make separate method? float progress; if ((progress = [self progress]) >= 1.0) - { - float stopRatio, ratio; - if ((stopRatio = [self actualStopRatio]) == INVALID) - progress = 3.0; - else if (stopRatio > 0 && (ratio = [self ratio]) >= 0 && ratio <= stopRatio) - progress += ratio / stopRatio; - else; - } + progress += [self progressStopRatio]; return [NSNumber numberWithFloat: progress]; } diff --git a/macosx/TorrentCell.m b/macosx/TorrentCell.m index 673f41454..525114489 100644 --- a/macosx/TorrentCell.m +++ b/macosx/TorrentCell.m @@ -83,15 +83,7 @@ if ([[info objectForKey: @"Seeding"] boolValue]) { - float stopRatio, ratio; - if ((stopRatio = [[info objectForKey: @"StopRatio"] floatValue]) != INVALID - && (ratio = [[info objectForKey: @"Ratio"] floatValue]) < stopRatio - && stopRatio != 0) - { - if (ratio < 0) - ratio = 0; - completeBounds.size.width = width * ratio / stopRatio; - } + completeBounds.size.width = width * [[info objectForKey: @"ProgressStopRatio"] floatValue]; if (completeBounds.size.width < barBounds.size.width) [fLightGreenGradient fillRect: barBounds angle: -90];