# HG changeset patch # User IBBoard # Date 1260214812 0 # Node ID 78f7456f6419bb491a03876c1f18d2b0e0113a17 # Parent 7441a62c5a061074037b9933f9b5d41e39eaf677 Re #228: Crash with missing abilityID * Quick fix to check if an ability ID doesn't match an ability and throw a standard error if it isn't found TODO: * Need to check why it isn't handled by the attribute type (IDREF) * Need to test it works! Problem shouldn't occur for because it is just a block of text and isn't referenced anywhere diff -r 7441a62c5a06 -r 78f7456f6419 api/Factories/Xml/WarFoundryXmlRaceFactory.cs --- a/api/Factories/Xml/WarFoundryXmlRaceFactory.cs Mon Dec 07 19:34:51 2009 +0000 +++ b/api/Factories/Xml/WarFoundryXmlRaceFactory.cs Mon Dec 07 19:40:12 2009 +0000 @@ -330,8 +330,15 @@ foreach (XmlElement ability in WarFoundryXmlFactoryUtils.SelectNodes(elem, "race:unitAbilities/race:unitAbility")) { string id = ability.GetAttribute("abilityID"); + Ability ability = type.Race.GetAbility(id); + + if (ability == null) + { + throw new InvalidFileException("Ability for "+type.Name+ " with ID "+id+ " did not exist in race definition"); + } + bool required = XmlTools.GetBoolValueFromAttribute(ability, "required"); - type.AddAbility(type.Race.GetAbility(id), required); + type.AddAbility(ability, required); } }