comparison api/Factories/Xml/WarFoundryXmlRaceFactory.cs @ 222:2f9ad5385707

Re #228: Crash with missing abilityID * Fix build failure because of duplicate variable name - not sure why VS.net didn't complain before first commit
author IBBoard <dev@ibboard.co.uk>
date Sun, 13 Dec 2009 19:49:50 +0000
parents 78f7456f6419
children f097888efcfe
comparison
equal deleted inserted replaced
221:78f7456f6419 222:2f9ad5385707
325 return GetLimitFromElement(limitElem); 325 return GetLimitFromElement(limitElem);
326 } 326 }
327 327
328 private void LoadAbilitiesForUnitType(XmlElement elem, UnitType type) 328 private void LoadAbilitiesForUnitType(XmlElement elem, UnitType type)
329 { 329 {
330 foreach (XmlElement ability in WarFoundryXmlFactoryUtils.SelectNodes(elem, "race:unitAbilities/race:unitAbility")) 330 foreach (XmlElement abilityElem in WarFoundryXmlFactoryUtils.SelectNodes(elem, "race:unitAbilities/race:unitAbility"))
331 { 331 {
332 string id = ability.GetAttribute("abilityID"); 332 string id = abilityElem.GetAttribute("abilityID");
333 Ability ability = type.Race.GetAbility(id); 333 Ability ability = type.Race.GetAbility(id);
334 334
335 if (ability == null) 335 if (ability == null)
336 { 336 {
337 throw new InvalidFileException("Ability for "+type.Name+ " with ID "+id+ " did not exist in race definition"); 337 throw new InvalidFileException("Ability for "+type.Name+ " with ID "+id+ " did not exist in race definition");
338 } 338 }
339 339
340 bool required = XmlTools.GetBoolValueFromAttribute(ability, "required"); 340 bool required = XmlTools.GetBoolValueFromAttribute(abilityElem, "required");
341 type.AddAbility(ability, required); 341 type.AddAbility(ability, required);
342 } 342 }
343 } 343 }
344 344
345 private void LoadContainedUnitsForUnitType(XmlElement elem, UnitType type) 345 private void LoadContainedUnitsForUnitType(XmlElement elem, UnitType type)