From 7b75a78e38a3772995f4217c4bcb8cc94c09f37a Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Mon, 19 Oct 2020 12:53:17 +0200 Subject: [PATCH] Fix free-of-charge repairing still costing credits --- OpenRA.Mods.Common/Activities/Resupply.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Activities/Resupply.cs b/OpenRA.Mods.Common/Activities/Resupply.cs index 03689e0002..60d510e32f 100644 --- a/OpenRA.Mods.Common/Activities/Resupply.cs +++ b/OpenRA.Mods.Common/Activities/Resupply.cs @@ -272,7 +272,8 @@ namespace OpenRA.Mods.Common.Activities var hpToRepair = repairable != null && repairable.Info.HpPerStep > 0 ? repairable.Info.HpPerStep : repairsUnits.Info.HpPerStep; // Cast to long to avoid overflow when multiplying by the health - var cost = Math.Max(1, (int)(((long)hpToRepair * unitCost * repairsUnits.Info.ValuePercentage) / (health.MaxHP * 100L))); + var value = (long)unitCost * repairsUnits.Info.ValuePercentage; + var cost = value == 0 ? 0 : Math.Max(1, (int)(hpToRepair * value / (health.MaxHP * 100L))); if (!played) {