Defend against divide by 0.
This commit is contained in:
parent
924978c2a0
commit
83e7276fa9
|
@ -43,7 +43,7 @@ double randF(void)
|
||||||
|
|
||||||
int getPercent(float current, float total)
|
int getPercent(float current, float total)
|
||||||
{
|
{
|
||||||
return (current / total) * 100;
|
return total > 0 ? (current / total) * 100 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float limit(float i, float a, float b)
|
float limit(float i, float a, float b)
|
||||||
|
|
Loading…
Reference in New Issue