changeset 88:110a7b0bcab5

Re #50: Complete core loading from XML * Fix attribute loading for UnitEquipmentItem to read from correct XmlElement * Stop infinite recursion when getting number of a given weapon
author IBBoard <dev@ibboard.co.uk>
date Sat, 01 Aug 2009 20:03:54 +0000
parents 9fba3b4ccdcd
children cb3759c3ea19
files api/Factories/Xml/WarFoundryXmlRaceFactory.cs api/Objects/Unit.cs
diffstat 2 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/api/Factories/Xml/WarFoundryXmlRaceFactory.cs	Sat Aug 01 19:45:24 2009 +0000
+++ b/api/Factories/Xml/WarFoundryXmlRaceFactory.cs	Sat Aug 01 20:03:54 2009 +0000
@@ -163,7 +163,7 @@
 					
 					try
 					{
-						unitEquipItem.IsRequired = bool.Parse(elem.GetAttribute("required"));
+						unitEquipItem.IsRequired = bool.Parse(equip.GetAttribute("required"));
 					}
 					catch(FormatException e)
 					{
@@ -171,8 +171,8 @@
 					}
 					
 					try
-					{
-						unitEquipItem.MinNumber = int.Parse(elem.GetAttribute("minNum"));
+					{
+						unitEquipItem.MinNumber = int.Parse(equip.GetAttribute("minNum"));
 					}
 					catch (FormatException e)
 					{
@@ -180,8 +180,8 @@
 					}
 					
 					try
-					{
-						unitEquipItem.MaxNumber = int.Parse(elem.GetAttribute("maxNum"));
+					{
+						unitEquipItem.MaxNumber = int.Parse(equip.GetAttribute("maxNum"));
 					}
 					catch (FormatException e)
 					{
@@ -189,8 +189,8 @@
 					}
 					
 					try
-					{
-						unitEquipItem.MinPercentage = double.Parse(elem.GetAttribute("minPercentage"));
+					{
+						unitEquipItem.MinPercentage = double.Parse(equip.GetAttribute("minPercentage"));
 					}
 					catch (FormatException e)
 					{
@@ -198,8 +198,8 @@
 					}
 					
 					try
-					{
-						unitEquipItem.MaxPercentage = double.Parse(elem.GetAttribute("maxPercentage"));
+					{
+						unitEquipItem.MaxPercentage = double.Parse(equip.GetAttribute("maxPercentage"));
 					}
 					catch (FormatException e)
 					{
@@ -207,8 +207,8 @@
 					}
 					
 					try
-					{
-						unitEquipItem.CostMultiplier = double.Parse(elem.GetAttribute("costMultiplier"));
+					{
+						unitEquipItem.CostMultiplier = double.Parse(equip.GetAttribute("costMultiplier"));
 					}
 					catch (FormatException e)
 					{
@@ -217,7 +217,7 @@
 					
 					try
 					{
-						unitEquipItem.CostRoundType = (RoundType) Enum.Parse(typeof(RoundType), elem.GetAttribute("costRounding"));
+						unitEquipItem.CostRoundType = (RoundType) Enum.Parse(typeof(RoundType), equip.GetAttribute("costRounding"));
 					}
 					catch (ArgumentException e)
 					{
--- a/api/Objects/Unit.cs	Sat Aug 01 19:45:24 2009 +0000
+++ b/api/Objects/Unit.cs	Sat Aug 01 20:03:54 2009 +0000
@@ -253,7 +253,7 @@
 
 		public double GetEquipmentAmount(UnitEquipmentItem item)
 		{
-			return GetEquipmentAmount(item.ID);
+			return DictionaryUtils.GetValue(equipment, item);
 		}
 
 		public double GetEquipmentAmount(string equipID)