diff --git a/sswlib/src/main/java/components/BipedLoadout.java b/sswlib/src/main/java/components/BipedLoadout.java index 43e4a90b..b4aafed3 100644 --- a/sswlib/src/main/java/components/BipedLoadout.java +++ b/sswlib/src/main/java/components/BipedLoadout.java @@ -267,7 +267,7 @@ public void AddToQueue( abPlaceable p ) { } } else { if( p == Queue.get( i ) ) { return; } - if( p.LookupName().equals( ((abPlaceable) Queue.get( i )).LookupName() ) ) { + if( p.equals(Queue.get( i )) ) { // create a new equipment collection for these items. EquipmentCollection e = new EquipmentCollection( this ); e.Add( p ); @@ -286,23 +286,17 @@ public void AddToQueue( abPlaceable p ) { // check to see if this is a core component if( ! p.CoreComponent() ) { // add it to the non core list - if( ! NonCore.contains( p ) ) { - NonCore.add( p ); - } + NonCore.add( p ); // add it to the equipment list if appropriate if( ! ( p instanceof Ammunition ) ) { - if( ! Equipment.contains( p ) ) { - Equipment.add( p ); - } + Equipment.add( p ); } // add it to the TC list if appropriate. if( p instanceof ifWeapon ) { - if( ! TCList.contains( p ) ) { - if( ((ifWeapon) p).IsTCCapable() ) { - TCList.add( p ); - } + if( ((ifWeapon) p).IsTCCapable() ) { + TCList.add( p ); } } diff --git a/sswlib/src/main/java/components/EquipmentCollection.java b/sswlib/src/main/java/components/EquipmentCollection.java index 6d55ecec..edfc7ed5 100644 --- a/sswlib/src/main/java/components/EquipmentCollection.java +++ b/sswlib/src/main/java/components/EquipmentCollection.java @@ -45,7 +45,7 @@ public abPlaceable GetType() { } public boolean SameType( abPlaceable p ) { - if( ((abPlaceable) equips.get( 0 )).LookupName().equals( p.LookupName() ) ) { + if( p.equals(equips.get( 0 ))) { return true; } else { return false; @@ -59,9 +59,7 @@ public boolean Add( abPlaceable p ) { return true; } else { if( SameType( p ) ) { - if( ! equips.contains( p ) ) { - equips.add( p ); - } + equips.add( p ); return true; } else { return false; diff --git a/sswlib/src/main/java/components/QuadLoadout.java b/sswlib/src/main/java/components/QuadLoadout.java index a085423b..43805d1c 100644 --- a/sswlib/src/main/java/components/QuadLoadout.java +++ b/sswlib/src/main/java/components/QuadLoadout.java @@ -267,7 +267,7 @@ public void AddToQueue( abPlaceable p ) { } } else { if( p == Queue.get( i ) ) { return; } - if( p.LookupName().equals( ((abPlaceable) Queue.get( i )).LookupName() ) ) { + if( p.equals(Queue.get( i )) ) { // create a new equipment collection for these items. EquipmentCollection e = new EquipmentCollection( this ); e.Add( p ); @@ -286,23 +286,17 @@ public void AddToQueue( abPlaceable p ) { // check to see if this is a core component if( ! p.CoreComponent() ) { // add it to the non core list - if( ! NonCore.contains( p ) ) { - NonCore.add( p ); - } + NonCore.add( p ); // add it to the equipment list if appropriate if( ! ( p instanceof Ammunition ) ) { - if( ! Equipment.contains( p ) ) { - Equipment.add( p ); - } + Equipment.add( p ); } // add it to the TC list if appropriate. if( p instanceof ifWeapon ) { - if( ! TCList.contains( p ) ) { - if( ((ifWeapon) p).IsTCCapable() ) { - TCList.add( p ); - } + if( ((ifWeapon) p).IsTCCapable() ) { + TCList.add( p ); } } diff --git a/sswlib/src/main/java/components/TripodLoadout.java b/sswlib/src/main/java/components/TripodLoadout.java index 9cf75c75..b5af181e 100644 --- a/sswlib/src/main/java/components/TripodLoadout.java +++ b/sswlib/src/main/java/components/TripodLoadout.java @@ -270,7 +270,7 @@ public void AddToQueue( abPlaceable p ) { } } else { if( p == Queue.get( i ) ) { return; } - if( p.LookupName().equals( ((abPlaceable) Queue.get( i )).LookupName() ) ) { + if( p.equals(Queue.get( i )) ) { // create a new equipment collection for these items. EquipmentCollection e = new EquipmentCollection( this ); e.Add( p ); @@ -289,23 +289,17 @@ public void AddToQueue( abPlaceable p ) { // check to see if this is a core component if( ! p.CoreComponent() ) { // add it to the non core list - if( ! NonCore.contains( p ) ) { - NonCore.add( p ); - } + NonCore.add( p ); // add it to the equipment list if appropriate if( ! ( p instanceof Ammunition ) ) { - if( ! Equipment.contains( p ) ) { - Equipment.add( p ); - } + Equipment.add( p ); } // add it to the TC list if appropriate. if( p instanceof ifWeapon ) { - if( ! TCList.contains( p ) ) { - if( ((ifWeapon) p).IsTCCapable() ) { - TCList.add( p ); - } + if( ((ifWeapon) p).IsTCCapable() ) { + TCList.add( p ); } } diff --git a/sswlib/src/main/java/components/abPlaceable.java b/sswlib/src/main/java/components/abPlaceable.java index 3fa715aa..fa74a2e9 100644 --- a/sswlib/src/main/java/components/abPlaceable.java +++ b/sswlib/src/main/java/components/abPlaceable.java @@ -467,6 +467,18 @@ public boolean IsCritable() { public int compareTo(abPlaceable o ) { return ActualName().compareTo(o.ActualName()); } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof abPlaceable)) + return false; + + if (((abPlaceable) obj).ActualName() == ActualName()) { + return true; + } + + return false; + } @Override public String toString() {