comparison api/Factories/Xml/WarFoundryXmlRaceFactory.cs @ 219:f609bcf7035b

Fixes #222: decimal comma/point not handled correctly (again?) in costMultiplier * Replace two "type.Parse" calls with XmlTools calls All decimals in WarFoundry should use the decimal point (or "period" to Americans) rather than the decimal comma because that's what XML uses in its default type definitions
author IBBoard <dev@ibboard.co.uk>
date Sat, 28 Nov 2009 16:40:27 +0000
parents 89e26d51afc2
children 78f7456f6419
comparison
equal deleted inserted replaced
218:a1a6b527cd70 219:f609bcf7035b
285 285
286 unitEquipItem.RoundNumberUp = equip.GetAttribute("roundDirection").Equals("up"); 286 unitEquipItem.RoundNumberUp = equip.GetAttribute("roundDirection").Equals("up");
287 287
288 try 288 try
289 { 289 {
290 unitEquipItem.IsRequired = bool.Parse(equip.GetAttribute("required")); 290 unitEquipItem.IsRequired = XmlTools.GetBoolValueFromAttribute(equip, "required");
291 } 291 }
292 catch(FormatException e) 292 catch(FormatException e)
293 { 293 {
294 throw new InvalidFileException("Attribute 'required' of unit equipment item " + id + " for " + type.Name + " was not a valid boolean", e); 294 throw new InvalidFileException("Attribute 'required' of unit equipment item " + id + " for " + type.Name + " was not a valid boolean", e);
295 } 295 }
296 296
297 try 297 try
298 { 298 {
299 unitEquipItem.CostMultiplier = double.Parse(equip.GetAttribute("costMultiplier")); 299 unitEquipItem.CostMultiplier = XmlTools.GetDoubleValueFromAttribute(equip, "costMultiplier");
300 } 300 }
301 catch (FormatException e) 301 catch (FormatException e)
302 { 302 {
303 throw new InvalidFileException("Attribute 'costMultiplier' of unit equipment item " + id + " for " + type.Name + " was not a valid decimal number", e); 303 throw new InvalidFileException("Attribute 'costMultiplier' of unit equipment item " + id + " for " + type.Name + " was not a valid decimal number", e);
304 } 304 }