Skip to content

Commit

Permalink
fix loadout mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
jixxed committed Aug 12, 2024
1 parent 12625bc commit ba718e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ public Slot(final Slot slot) {
}
//some ships have their last slotnumbers offset due to military slots
public int getNamedIndex() {
return namedIndex != null ? namedIndex : index + 1;
return hasNamedIndex() ? namedIndex : index + 1;
}
//some ships have their last slotnumbers offset due to military slots
public boolean hasNamedIndex() {
return namedIndex != null;
}

public boolean isOccupied() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,11 @@ private static Slot getHardpointSlot(List<ImageSlot> hardpointSlots, String slot
final int slotNumber = Integer.parseInt(slotName.substring(slotName.length() - 1));
try {
return getHardpointSlots(hardpointSlots, slotName).stream()
.filter(Slot::hasNamedIndex)
.filter(slot -> slot.getNamedIndex() == slotNumber)
.findFirst()
.orElseThrow(IllegalArgumentException::new);
} catch (IllegalArgumentException ex) {
.orElseGet(() -> getHardpointSlots(hardpointSlots, slotName).get(slotNumber - 1));
} catch (IllegalStateException ex) {
hardpointSlots.stream().map(slot -> slot.toString()).forEach(log::debug);
throw ex;
}
Expand Down

0 comments on commit ba718e8

Please sign in to comment.