From 695e34dca0ce549b6fa6b622da5580f86e972d25 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sun, 12 Jan 2025 22:20:31 -0600 Subject: [PATCH] Log prohibited unit skips and prevent invalid part additions Added a log message to improve traceability when skipping prohibited units. Also ensured parts not in the existing parts list are excluded to prevent accidental additions to the pool. These changes enhance debugging and maintain data integrity. --- .../mekhq/campaign/mission/resupplyAndCaches/Resupply.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java index 4e98dab774..3fdc1ef5f4 100644 --- a/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java +++ b/MekHQ/src/mekhq/campaign/mission/resupplyAndCaches/Resupply.java @@ -537,6 +537,7 @@ private Map collectParts() { } if (isProhibitedUnitType(entity, false)) { + logger.info("skipping " + unit.getName() + " as it is prohibited."); continue; } @@ -711,8 +712,12 @@ private void applyWarehouseWeightModifiers(Map partsList) { continue; } - PartDetails partDetails = new PartDetails(part, weight); + // This prevents us accidentally adding new items to the pool + if (!partsList.containsKey(getPartKey(part))) { + continue; + } + PartDetails partDetails = new PartDetails(part, weight); partsList.merge(getPartKey(part), partDetails, (oldValue, newValue) -> { oldValue.setWeight(oldValue.getWeight() - newValue.getWeight()); return oldValue;