From 83e7276fa9345bb5ccfcc21ffbd3f07877c183c3 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 4 Mar 2018 17:03:11 +0000 Subject: [PATCH] Defend against divide by 0. --- src/util/maths.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/maths.c b/src/util/maths.c index 686e523..5f36565 100644 --- a/src/util/maths.c +++ b/src/util/maths.c @@ -43,7 +43,7 @@ double randF(void) 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)