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 diff
     1.1 --- a/api/Factories/Xml/WarFoundryXmlRaceFactory.cs	Sun Sep 13 17:18:41 2009 +0000
     1.2 +++ b/api/Factories/Xml/WarFoundryXmlRaceFactory.cs	Sun Sep 13 18:00:52 2009 +0000
     1.3 @@ -154,8 +154,8 @@
     1.4  				
     1.5  				if (equipItem!=null)
     1.6  				{
     1.7 -					UnitEquipmentItem unitEquipItem = new UnitEquipmentItem(equipItem, type);
     1.8 -					unitEquipItem.MutexGroup = equip.GetAttribute("exclusivityGroup");					
     1.9 +					string mutexGroup = equip.GetAttribute("exclusivityGroup");
    1.10 +					UnitEquipmentItem unitEquipItem = new UnitEquipmentItem(equipItem, type, mutexGroup);
    1.11  					unitEquipItem.RoundNumberUp = equip.GetAttribute("roundDirection").Equals("up");
    1.12  					
    1.13  					
     2.1 --- a/api/Objects/UnitEquipmentItem.cs	Sun Sep 13 17:18:41 2009 +0000
     2.2 +++ b/api/Objects/UnitEquipmentItem.cs	Sun Sep 13 18:00:52 2009 +0000
     2.3 @@ -25,10 +25,16 @@
     2.4  		private string mutexGroup;
     2.5  		private UnitType unitType;
     2.6  
     2.7 -		public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor)
     2.8 +		public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor) : this(equipmentItem, equipmentFor, "")
     2.9 +		{
    2.10 +			//Do nothing extra
    2.11 +		}
    2.12 +		
    2.13 +		public UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipmentFor, string mutexGroup)
    2.14  		{
    2.15  			item = equipmentItem;
    2.16  			unitType = equipmentFor;
    2.17 +			this.mutexGroup = mutexGroup;
    2.18  			unitType.AddEquipmentItem(this);
    2.19  		}
    2.20  		
    2.21 @@ -102,7 +108,6 @@
    2.22  		public string MutexGroup
    2.23  		{
    2.24  			get { return mutexGroup; }
    2.25 -			set { mutexGroup = (value == null ? "" : value.Trim()); }
    2.26  		}
    2.27  
    2.28  		public UnitType EquipmentForUnit