From d8f68668b15aef7e8020630b7b804f2705a60563 Mon Sep 17 00:00:00 2001
From: Sam <samuelkeiffer@gmail.com>
Date: Sun, 4 Jul 2021 22:00:13 -0500
Subject: [PATCH] Addressed potential for divide by zero.

---
 common/systems/src/buff.rs | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/common/systems/src/buff.rs b/common/systems/src/buff.rs
index 3edb60eb8b..b22a9b15e1 100644
--- a/common/systems/src/buff.rs
+++ b/common/systems/src/buff.rs
@@ -278,9 +278,15 @@ impl<'a> System<'a> for Sys {
 
                                     let potential_fraction = *achieved_fraction + health_tick;
 
-                                    // Potential progress towards target fraction
-                                    let progress =
-                                        (1.0 - potential_fraction) / (1.0 - *target_fraction);
+                                    // Potential progress towards target fraction, if
+                                    // target_fraction ~ 1.0 then set progress to 1.0 to avoid
+                                    // divide by zero
+                                    let progress = if (1.0 - *target_fraction).abs() > f32::EPSILON
+                                    {
+                                        (1.0 - potential_fraction) / (1.0 - *target_fraction)
+                                    } else {
+                                        1.0
+                                    };
 
                                     // Change achieved_fraction depending on what other buffs have
                                     // occurred