mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
fix divide-by-zero error in GuiDownloader time remaining estimation when last 10 items have either downloaded too quickly or have errored out
This commit is contained in:
@@ -218,8 +218,7 @@ public abstract class GuiDownloader extends DefaultBoundedRangeModel implements
|
|||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
protected final int getAverageTimePerObject() {
|
protected final int getAverageTimePerObject() {
|
||||||
int aTime = 0;
|
int numNonzero = 10;
|
||||||
int nz = 10;
|
|
||||||
|
|
||||||
if (this.tptr > 9) {
|
if (this.tptr > 9) {
|
||||||
this.tptr = 0;
|
this.tptr = 0;
|
||||||
@@ -232,14 +231,12 @@ public abstract class GuiDownloader extends DefaultBoundedRangeModel implements
|
|||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
tTime += this.times[i];
|
tTime += this.times[i];
|
||||||
if (this.times[i] == 0) {
|
if (this.times[i] == 0) {
|
||||||
nz--;
|
numNonzero--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
aTime = tTime / nz;
|
|
||||||
|
|
||||||
this.tptr++;
|
this.tptr++;
|
||||||
|
return tTime / Math.max(1, numNonzero);
|
||||||
return aTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -253,21 +250,9 @@ public abstract class GuiDownloader extends DefaultBoundedRangeModel implements
|
|||||||
private void update(final int card) {
|
private void update(final int card) {
|
||||||
this.card = card;
|
this.card = card;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* TODO: Write javadoc for this type.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
final class Worker implements Runnable {
|
final class Worker implements Runnable {
|
||||||
private final int card;
|
private final int card;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* TODO: Write javadoc for Constructor.
|
|
||||||
*
|
|
||||||
* @param card
|
|
||||||
* int
|
|
||||||
*/
|
|
||||||
Worker(final int card) {
|
Worker(final int card) {
|
||||||
this.card = card;
|
this.card = card;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user