changeset 70:780f3926abad

Re #50 - Complete core loading of WarFoundry XML files * Rename a "create" method to a "get" * Remove duplicate "add unit" call
author IBBoard <dev@ibboard.co.uk>
date Sat, 25 Apr 2009 19:29:51 +0000
parents 91cf8efbea0b
children 0303ac938fc5
files api/Factories/Xml/WarFoundryXmlRaceFactory.cs
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/api/Factories/Xml/WarFoundryXmlRaceFactory.cs	Sat Apr 25 19:26:12 2009 +0000
+++ b/api/Factories/Xml/WarFoundryXmlRaceFactory.cs	Sat Apr 25 19:29:51 2009 +0000
@@ -76,7 +76,7 @@
 			
 			foreach (XmlElement node in WarFoundryXmlFactoryUtils.SelectNodes(extraData, "/race:race/race:units/race:unit"))
 			{
-				CreateUnitTypeFromElement(node, race);
+				GetUnitTypeForElement(node, race);
 			}
 			
 			race.SetAsFullyLoaded();
@@ -92,10 +92,10 @@
 
 		private UnitType GetUnitTypeFromDocument(XmlDocument doc, string id, Race parentRace)
 		{
-			return CreateUnitTypeFromElement(WarFoundryXmlFactoryUtils.SelectSingleElement(doc, "/race:race/race:units/race:unit[id="+id+"]"), parentRace);
+			return GetUnitTypeForElement(WarFoundryXmlFactoryUtils.SelectSingleElement(doc, "/race:race/race:units/race:unit[id="+id+"]"), parentRace);
 		}
 						
-		private UnitType CreateUnitTypeFromElement(XmlElement elem, Race parentRace)
+		private UnitType GetUnitTypeForElement(XmlElement elem, Race parentRace)
 		{
 			string id = elem.GetAttribute("id");
 			UnitType type = parentRace.GetUnitType(id);
@@ -103,7 +103,6 @@
 			if (type==null)
 			{
 				type = CreateUnitTypeFromElement(elem, id, parentRace);
-				parentRace.AddUnitType(type);
 			}
 			
 			return type;