comparison api/Factories/Xml/WarFoundryXmlArmyParser.cs @ 155:df61d26c23fb

Re #178: "crash" when loading old .army file with equipment tags that are "old" * Try to tidy up the exception messages - ideally they'll end up translated and localised
author IBBoard <dev@ibboard.co.uk>
date Mon, 28 Sep 2009 19:48:37 +0000
parents 52e8c3cdde10
children d1068f4b6d1c
comparison
equal deleted inserted replaced
154:4a02c07278e7 155:df61d26c23fb
40 string systemID = elem.GetAttribute("system"); 40 string systemID = elem.GetAttribute("system");
41 GameSystem system = WarFoundryLoader.GetDefault().GetGameSystem(systemID); 41 GameSystem system = WarFoundryLoader.GetDefault().GetGameSystem(systemID);
42 42
43 if (system == null) 43 if (system == null)
44 { 44 {
45 throw new RequiredDataMissingException(file.Name, "gameSystem", systemID); 45 throw new RequiredDataMissingException(file.Name, "Game System", systemID);
46 } 46 }
47 47
48 string raceID = elem.GetAttribute("race"); 48 string raceID = elem.GetAttribute("race");
49 Race race = WarFoundryLoader.GetDefault().GetRace(system, raceID); 49 Race race = WarFoundryLoader.GetDefault().GetRace(system, raceID);
50 50
51 if (race == null) 51 if (race == null)
52 { 52 {
53 throw new RequiredDataMissingException(file.Name, "race", raceID); 53 throw new RequiredDataMissingException(file.Name, "Race", raceID);
54 } 54 }
55 55
56 int points = XmlTools.GetIntValueFromAttribute(elem, "maxPoints"); 56 int points = XmlTools.GetIntValueFromAttribute(elem, "maxPoints");
57 army = new Army(race, name, points, file); 57 army = new Army(race, name, points, file);
58 LoadUnits(); 58 LoadUnits();
71 string unitTypeId = unitElem.GetAttribute("unitType"); 71 string unitTypeId = unitElem.GetAttribute("unitType");
72 UnitType unitType = army.Race.GetUnitType(unitTypeId); 72 UnitType unitType = army.Race.GetUnitType(unitTypeId);
73 73
74 if (unitType == null) 74 if (unitType == null)
75 { 75 {
76 throw new RequiredDataMissingException(file.Name, "unitType", unitTypeId); 76 throw new RequiredDataMissingException(file.Name, "Unit Type", unitTypeId);
77 } 77 }
78 78
79 string name = unitElem.GetAttribute("unitName"); 79 string name = unitElem.GetAttribute("unitName");
80 int size = XmlTools.GetIntValueFromAttribute(unitElem, "size"); 80 int size = XmlTools.GetIntValueFromAttribute(unitElem, "size");
81 81
99 { 99 {
100 UnitEquipmentItem item = unit.UnitType.GetEquipmentItem(equipID); 100 UnitEquipmentItem item = unit.UnitType.GetEquipmentItem(equipID);
101 101
102 if (item == null) 102 if (item == null)
103 { 103 {
104 throw new RequiredDataMissingException(file.Name, "equipItem ID", equipID); 104 throw new RequiredDataMissingException(file.Name, "Equipment Item", equipID);
105 } 105 }
106 106
107 double amount = XmlTools.GetDoubleValueFromAttribute(elem, "amount"); 107 double amount = XmlTools.GetDoubleValueFromAttribute(elem, "amount");
108 string equipTypeString = elem.GetAttribute("amountType"); 108 string equipTypeString = elem.GetAttribute("amountType");
109 109