# HG changeset patch # User IBBoard # Date 1333221522 -3600 # Node ID 750eed630c41a7ec26a43c4195b8c1179bbab437 # Parent bdfa314789ccad9f6a025e8ac955de189800d7fc Fixes #395: Requirements can incorrectly allow based on common divisor * Round the "limited/required" normalised count down to get correct values diff -r bdfa314789cc -r 750eed630c41 API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs --- a/API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs Sat Mar 31 15:23:49 2012 +0100 +++ b/API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs Sat Mar 31 20:18:42 2012 +0100 @@ -58,7 +58,8 @@ private bool IsValidByRequirement(UnitCountRequirementData limit, int allowedTypeCount, int limitedTypeCount) { - double normalisedLimited = limitedTypeCount / (limit.Count * 1.0); + //Round down limited units to get only whole amounts + double normalisedLimited = Math.Floor(limitedTypeCount / (limit.Count * 1.0)); double normalisedAllowed = allowedTypeCount / (limit.AllowsCount * 1.0); return normalisedLimited >= 1 && normalisedAllowed <= normalisedLimited; }