# HG changeset patch # User IBBoard # Date 1333203829 -3600 # Node ID bdfa314789ccad9f6a025e8ac955de189800d7fc # Parent 7b9ff7b1df24568f11bde99b6bdc890902aad275 Re #395: Requirements can incorrectly allow based on common divisor * Rebuild validation check to use normalised values diff -r 7b9ff7b1df24 -r bdfa314789cc API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs --- a/API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs Sat Mar 24 20:33:11 2012 +0000 +++ b/API/Objects/Requirement/RequiresNUnitsForMObjectsRequirement.cs Sat Mar 31 15:23:49 2012 +0100 @@ -58,8 +58,9 @@ private bool IsValidByRequirement(UnitCountRequirementData limit, int allowedTypeCount, int limitedTypeCount) { - double allowedRatio = (limit.AllowsCount / (limit.Count * 1.0)); - return allowedRatio * limitedTypeCount >= allowedTypeCount; + double normalisedLimited = limitedTypeCount / (limit.Count * 1.0); + double normalisedAllowed = allowedTypeCount / (limit.AllowsCount * 1.0); + return normalisedLimited >= 1 && normalisedAllowed <= normalisedLimited; } public override Validation AllowsAdding(IWarFoundryObject wfObject, Army toArmy)