Source:
<code>private static List<Entity> fillTransport(AtBScenario scenario, Entity transport, UnitGeneratorParameters params, int skill, Campaign campaign) { List<Entity> transportedUnits = new ArrayList<>(); if(scenario.getTransportLinkages().containsKey(transport.getExternalIdAsString())) { return transportedUnits; } for(Transporter bay : transport.getTransports()) { if(bay instanceof TroopSpace) { double bayCapacity = ((TroopSpace) bay).getUnused(); UnitGeneratorParameters newParams = params.clone(); newParams.clearMovementModes(); newParams.setUnitType(UnitType.INFANTRY); newParams.setWeightClass(AtBDynamicScenarioFactory.UNIT_WEIGHT_UNSPECIFIED); if(bayCapacity <= IUnitGenerator.FOOT_PLATOON_INFANTRY_WEIGHT) { newParams.getMovementModes().add(EntityMovementMode.INF_LEG); newParams.setFilter(inf -> inf.getTons() <= IUnitGenerator.FOOT_PLATOON_INFANTRY_WEIGHT); } else { newParams.getMovementModes().addAll(IUnitGenerator.ALL_INFANTRY_MODES); newParams.setFilter(inf -> inf.getTons() <= bayCapacity); } MechSummary ms = campaign.getUnitGenerator().generate(newParams); if (ms == null) { continue; } Entity infantry = createEntityWithCrew(params.getFaction(), skill, campaign, ms); while(infantry.getWeight() > bayCapacity) { <START> ((Infantry) infantry).setSquadN(((Infantry) infantry).getSquadN() - 1); <END> infantry.autoSetInternal(); } infantry.setDeployRound(transport.getDeployRound()); scenario.addTransportRelationship(transport.getExternalIdAsString(), infantry.getExternalIdAsString()); transportedUnits.add(infantry); } } return transportedUnits; }</code><technical_language>happen amount of infantry for a bay? setSquadN allow 0</technical_language>

Target:
private static List<Entity> fillTransport(AtBScenario scenario, Entity transport, UnitGeneratorParameters params, int skill, Campaign campaign) { List<Entity> transportedUnits = new ArrayList<>(); if(scenario.getTransportLinkages().containsKey(transport.getExternalIdAsString())) { return transportedUnits; } for(Transporter bay : transport.getTransports()) { if(bay instanceof TroopSpace) { double bayCapacity = ((TroopSpace) bay).getUnused(); UnitGeneratorParameters newParams = params.clone(); newParams.clearMovementModes(); newParams.setUnitType(UnitType.INFANTRY); newParams.setWeightClass(AtBDynamicScenarioFactory.UNIT_WEIGHT_UNSPECIFIED); if(bayCapacity <= IUnitGenerator.FOOT_PLATOON_INFANTRY_WEIGHT) { newParams.getMovementModes().add(EntityMovementMode.INF_LEG); newParams.setFilter(inf -> inf.getTons() <= IUnitGenerator.FOOT_PLATOON_INFANTRY_WEIGHT); } else { newParams.getMovementModes().addAll(IUnitGenerator.ALL_INFANTRY_MODES); newParams.setFilter(inf -> inf.getTons() <= bayCapacity); } MechSummary ms = campaign.getUnitGenerator().generate(newParams); if (ms == null) { continue; } Entity infantry = createEntityWithCrew(params.getFaction(), skill, campaign, ms); while(infantry.getWeight() > bayCapacity) { ((Infantry) infantry).setSquadN(((Infantry) infantry).getSquadN() - 1); infantry.autoSetInternal(); } if(((Infantry) infantry).getSquadN() == 0) { continue; } infantry.setDeployRound(transport.getDeployRound()); scenario.addTransportRelationship(transport.getExternalIdAsString(), infantry.getExternalIdAsString()); transportedUnits.add(infantry); } } return transportedUnits; }