changeset 138:c11c0da01bbc

Fixes #147: "Replace Weapon" button doesn't always enable (regression) r167 introduced the bug by triggering an "add item to unit type" call before the mutex group was set * Added optional mutex group parameter to constructor * Remove setter on mutex group
author IBBoard <dev@ibboard.co.uk>
date Sun, 13 Sep 2009 18:00:52 +0000
parents f58051572ec7
children 70808ff799e6
files api/Factories/Xml/WarFoundryXmlRaceFactory.cs api/Objects/UnitEquipmentItem.cs
diffstat 2 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/api/Factories/Xml/WarFoundryXmlRaceFactory.cs	Sun Sep 13 17:18:41 2009 +0000
+++ b/api/Factories/Xml/WarFoundryXmlRaceFactory.cs	Sun Sep 13 18:00:52 2009 +0000
@@ -154,8 +154,8 @@
 				
 				if (equipItem!=null)
 				{
-					UnitEquipmentItem unitEquipItem = new UnitEquipmentItem(equipItem, type);
-					unitEquipItem.MutexGroup = equip.GetAttribute("exclusivityGroup");					
+					string mutexGroup = equip.GetAttribute("exclusivityGroup");
+					UnitEquipmentItem unitEquipItem = new UnitEquipmentItem(equipItem, type, mutexGroup);
 					unitEquipItem.RoundNumberUp = equip.GetAttribute("roundDirection").Equals("up");
 					
 					
--- a/api/Objects/UnitEquipmentItem.cs	Sun Sep 13 17:18:41 2009 +0000
+++ b/api/Objects/UnitEquipmentItem.cs	Sun Sep 13 18:00:52 2009 +0000
@@ -25,10 +25,16 @@
 		private string mutexGroup;
 		private UnitType unitType;
 
-		public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor)
+		public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor) : this(equipmentItem, equipmentFor, "")
+		{
+			//Do nothing extra
+		}
+		
+		public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor, string mutexGroup)
 		{
 			item = equipmentItem;
 			unitType = equipmentFor;
+			this.mutexGroup = mutexGroup;
 			unitType.AddEquipmentItem(this);
 		}
 		
@@ -102,7 +108,6 @@
 		public string MutexGroup
 		{
 			get { return mutexGroup; }
-			set { mutexGroup = (value == null ? "" : value.Trim()); }
 		}
 
 		public UnitType EquipmentForUnit