From a4f7daf47a37c37dd25d14e4506a803a59dbc595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 31 May 2015 20:42:54 +0200 Subject: [PATCH] avoid a division through zero --- OpenRA.Mods.D2k/Traits/Buildings/DamagedWithoutFoundation.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.D2k/Traits/Buildings/DamagedWithoutFoundation.cs b/OpenRA.Mods.D2k/Traits/Buildings/DamagedWithoutFoundation.cs index 1b07446779..be04c314b9 100644 --- a/OpenRA.Mods.D2k/Traits/Buildings/DamagedWithoutFoundation.cs +++ b/OpenRA.Mods.D2k/Traits/Buildings/DamagedWithoutFoundation.cs @@ -52,7 +52,10 @@ namespace OpenRA.Mods.D2k.Traits safeTiles++; } - damageThreshold = (info.DamageThreshold * health.MaxHP + (100 - info.DamageThreshold) * safeTiles * health.MaxHP / totalTiles) / 100; + if (totalTiles > 0) + damageThreshold = (info.DamageThreshold * health.MaxHP + (100 - info.DamageThreshold) * safeTiles * health.MaxHP / totalTiles) / 100; + else + damageThreshold = health.HP; // Actors start with maximum damage applied var delta = health.HP - damageThreshold;