# HG changeset patch # User IBBoard # Date 1251023529 0 # Node ID 0cdc0b07fe119850f30b7f49c44ebde017cc0687 # Parent d39de20f2ba1443c07559c747c7180ac67f5f03d Re #54: Add army loading * Add unit to army once it is loaded diff -r d39de20f2ba1 -r 0cdc0b07fe11 api/Factories/Xml/WarFoundryXmlArmyParser.cs --- a/api/Factories/Xml/WarFoundryXmlArmyParser.cs Sun Aug 23 10:28:03 2009 +0000 +++ b/api/Factories/Xml/WarFoundryXmlArmyParser.cs Sun Aug 23 10:32:09 2009 +0000 @@ -65,9 +65,8 @@ foreach (XmlElement unitElem in WarFoundryXmlFactoryUtils.SelectNodes(elem, "/army:army/army:units/army:unit")) { string id = unitElem.GetAttribute("id"); - Unit unit = DictionaryUtils.GetValue(units, id); - if (unit == null) + if (!units.ContainsKey(id)) { string unitTypeId = unitElem.GetAttribute("unitType"); UnitType unitType = army.Race.GetUnitType(unitTypeId); @@ -77,8 +76,11 @@ throw new RequiredDataMissingException(file.Name, "unitType", unitTypeId); } - unit = new Unit(unitType, army.GetCategory(unitType.MainCategory)); + Unit unit = new Unit(unitType, army.GetCategory(unitType.MainCategory)); + army.AddUnit(unit); units.Add(id, unit); + + //LoadUnitEquipment( } } }