Skip to content

Commit

Permalink
Merge pull request #6015 from psikomonkie/issue-5784-fix-omni-replace…
Browse files Browse the repository at this point in the history
…ment-woes

Issue 5784: Better handling for missing parts when replacing parts via "Pod Space"
  • Loading branch information
HammerGS authored Feb 11, 2025
2 parents fb42408 + 91aa10e commit 575bd28
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions MekHQ/src/mekhq/campaign/parts/PodSpace.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017 - The MegaMek Team. All Rights Reserved.
* Copyright (C) 2017-2025 - The MegaMek Team. All Rights Reserved.
*
* This file is part of MekHQ.
*
Expand Down Expand Up @@ -103,7 +103,8 @@ public void remove(boolean salvage) {
//Iterate through all pod-mounted equipment in space and remove them.
for (int pid : childPartIds) {
final Part part = campaign.getWarehouse().getPart(pid);
if (part != null) {
// Don't remove missing parts! We'll need to fix them.
if (part != null && !(part instanceof MissingPart)) {
part.remove(salvage);
MekHQ.triggerEvent(new PartChangedEvent(part));
}
Expand Down Expand Up @@ -142,8 +143,13 @@ public MissingPart getMissingPart() {

@Override
public @Nullable String checkFixable() {
if (isSalvaging() || location < 0) {
return null;
if ((isSalvaging() && !childPartIds.isEmpty()) || location < 0) {
for (int partId : childPartIds) {
// If all remaining parts are already missing, we don't need to keep salvaging
if (!(campaign.getWarehouse().getPart(partId) instanceof MissingPart)) {
return null;
}
}
}
// The part is only fixable if the location is not destroyed.
// be sure to check location and second location
Expand Down

0 comments on commit 575bd28

Please sign in to comment.