@@ -753,14 +753,50 @@ void countUnitsByType() {
753753 * @since 50.10
754754 */
755755 void calculateAdditionalBayRequirementsFromPassengers (int passengerCapacity ) {
756- int passengerCount = allPersonnel . size ();
756+ int passengerCount = getPassengerCount ();
757757 int additionalPassengerNeeds = max (0 , passengerCount - passengerCapacity );
758758 additionalPassengerBaysRequired = (int ) ceil (additionalPassengerNeeds / PASSENGERS_PER_BAY );
759759 additionalPassengerBaysCost = round (additionalPassengerBaysRequired * PASSENGERS_COST );
760760 totalCost = totalCost .plus (additionalPassengerBaysCost );
761761 totalAdditionalBaysRequired += additionalPassengerBaysRequired ;
762762 }
763763
764+ /**
765+ * Calculates and returns the total number of passengers. A person is considered a passenger if:
766+ *
767+ * <ul>
768+ * <li>They are not associated with any unit.</li>
769+ * <li>Their associated unit does not have an associated entity.</li>
770+ * <li>The entity associated with their unit is not a WarShip, JumpShip, or DropShip.</li>
771+ * </ul>
772+ *
773+ * @return The total count of passengers based on the conditions specified.
774+ */
775+ private int getPassengerCount () {
776+ int passengerCount = 0 ;
777+ for (Person person : allPersonnel ) {
778+ Unit unit = person .getUnit ();
779+ if (unit == null ) {
780+ passengerCount ++;
781+ continue ;
782+ }
783+
784+ Entity entity = unit .getEntity ();
785+ if (entity == null ) {
786+ passengerCount ++;
787+ continue ;
788+ }
789+
790+ // We exclude Space Stations here, as CamOps pg 35 states that only crew of the below unit types are
791+ // excluded from passenger counts
792+ if (!entity .isSmallCraft () && !entity .isWarShip () && !entity .isJumpShip () && !entity .isDropShip ()) {
793+ passengerCount ++;
794+ }
795+ }
796+
797+ return passengerCount ;
798+ }
799+
764800 /**
765801 * Executes a financial transaction for performing a jump between two planetary systems, debiting the specified
766802 * journey cost from the provided finances. Generates and includes a report of the transaction outcome.
0 commit comments