# HG changeset patch # User IBBoard # Date 1254253846 0 # Node ID eb9a6d91a6db36364896e87e6d0e9e347fa93d49 # Parent 6ff68daab5dce63c3826b54699d4b4fe48f24a0b Fixes #190: Mutex groups aren't honoured when adding equipment * Make "get additional equipment" method check mutex groups Also: * Line ending cleanup diff -r 6ff68daab5dc -r eb9a6d91a6db api/Factories/Xml/WarFoundryXmlRaceFactory.cs --- a/api/Factories/Xml/WarFoundryXmlRaceFactory.cs Tue Sep 29 19:33:03 2009 +0000 +++ b/api/Factories/Xml/WarFoundryXmlRaceFactory.cs Tue Sep 29 19:50:46 2009 +0000 @@ -123,20 +123,20 @@ } private void LoadCoreValuesForUnitType(XmlElement elem, UnitType type) - { - try - { - type.MaxNumber = XmlTools.GetIntValueFromAttribute(elem, "maxNum"); - type.MinNumber = XmlTools.GetIntValueFromAttribute(elem, "minNum"); - type.MaxSize = XmlTools.GetIntValueFromAttribute(elem, "maxSize"); - type.MinSize = XmlTools.GetIntValueFromAttribute(elem, "minSize"); - type.BaseSize = XmlTools.GetIntValueFromAttribute(elem, "baseSize"); - type.CostPerTrooper = XmlTools.GetDoubleValueFromAttribute(elem, "points"); - type.BaseUnitCost = XmlTools.GetDoubleValueFromAttribute(elem, "unitPoints"); - } - catch (FormatException ex) - { - throw new InvalidDataException(ex.Message, ex); + { + try + { + type.MaxNumber = XmlTools.GetIntValueFromAttribute(elem, "maxNum"); + type.MinNumber = XmlTools.GetIntValueFromAttribute(elem, "minNum"); + type.MaxSize = XmlTools.GetIntValueFromAttribute(elem, "maxSize"); + type.MinSize = XmlTools.GetIntValueFromAttribute(elem, "minSize"); + type.BaseSize = XmlTools.GetIntValueFromAttribute(elem, "baseSize"); + type.CostPerTrooper = XmlTools.GetDoubleValueFromAttribute(elem, "points"); + type.BaseUnitCost = XmlTools.GetDoubleValueFromAttribute(elem, "unitPoints"); + } + catch (FormatException ex) + { + throw new InvalidDataException(ex.Message, ex); } string mainCatID = elem.GetAttribute("cat"); diff -r 6ff68daab5dc -r eb9a6d91a6db api/Objects/Unit.cs --- a/api/Objects/Unit.cs Tue Sep 29 19:33:03 2009 +0000 +++ b/api/Objects/Unit.cs Tue Sep 29 19:50:46 2009 +0000 @@ -220,13 +220,33 @@ } } - public UnitEquipmentItem[] GetAllowedOptionalEquipment() + public UnitEquipmentItem[] GetAllowedAdditionalEquipment() { List list = new List(); + List existingMutexGroups = new List(); + + foreach (UnitEquipmentItem item in GetEquipment()) + { + foreach (string mutex in item.MutexGroups) + { + existingMutexGroups.Add(mutex); + } + } foreach (UnitEquipmentItem item in UnitType.GetEquipmentItems()) { - if (!item.IsRequired) + bool mutexMatch = false; + + foreach (string mutex in item.MutexGroups) + { + if (existingMutexGroups.Contains(mutex)) + { + mutexMatch = true; + break; + } + } + + if (!mutexMatch) { list.Add(item); }