Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix - SSW - Multiple Equipment Entries #301

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions sswlib/src/main/java/components/BipedLoadout.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 );
}
}

Expand Down
6 changes: 2 additions & 4 deletions sswlib/src/main/java/components/EquipmentCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
16 changes: 5 additions & 11 deletions sswlib/src/main/java/components/QuadLoadout.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 );
}
}

Expand Down
16 changes: 5 additions & 11 deletions sswlib/src/main/java/components/TripodLoadout.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 );
}
}

Expand Down
12 changes: 12 additions & 0 deletions sswlib/src/main/java/components/abPlaceable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down