Skip to content

Commit

Permalink
Log prohibited unit skips and prevent invalid part additions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
IllianiCBT committed Jan 13, 2025
1 parent f4b7479 commit 695e34d
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ private Map<String, PartDetails> collectParts() {
}

if (isProhibitedUnitType(entity, false)) {
logger.info("skipping " + unit.getName() + " as it is prohibited.");
continue;
}

Expand Down Expand Up @@ -711,8 +712,12 @@ private void applyWarehouseWeightModifiers(Map<String, PartDetails> 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;
Expand Down

0 comments on commit 695e34d

Please sign in to comment.