From 0221bb957d73f29dbf6127e950d224b302ae76e7 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sat, 29 Nov 2014 17:31:11 +0100 Subject: [PATCH] Avoid division by zero in LivingEntity. --- src/de/teamteamteam/spacescooter/entity/LivingEntity.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/de/teamteamteam/spacescooter/entity/LivingEntity.java b/src/de/teamteamteam/spacescooter/entity/LivingEntity.java index 356db1d..0611b82 100644 --- a/src/de/teamteamteam/spacescooter/entity/LivingEntity.java +++ b/src/de/teamteamteam/spacescooter/entity/LivingEntity.java @@ -155,6 +155,7 @@ public abstract class LivingEntity extends CollidableEntity implements Hittable * Returns an int in [0,100], divide by 100 for double percentage. */ public int getHealthPercentage() { + if(this.maximumHealthPoints == 0) return 0; return (this.healthPoints * 100) / this.maximumHealthPoints; } @@ -188,6 +189,7 @@ public abstract class LivingEntity extends CollidableEntity implements Hittable * Returns an int in [0,100], divide by 100 for double percentage. */ public int getShieldPercentage() { + if(this.maximumShieldPoints == 0) return 0; return (this.shieldPoints * 100) / this.maximumShieldPoints; }