diff --git a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java index 32b1b18ac..e7a42cc74 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java @@ -172,9 +172,29 @@ public class FlightConfiguration implements FlightConfigurableParameter getAllComponents() { + Queue toProcess = new ArrayDeque(); + toProcess.offer(this.rocket); + + ArrayList toReturn = new ArrayList<>(); + + while (!toProcess.isEmpty()) { + RocketComponent comp = toProcess.poll(); + + toReturn.add(comp); + for (RocketComponent child : comp.getChildren()) { + if (!(child instanceof AxialStage)) { + toProcess.offer(child); + } + } + } + + return toReturn; + } // this method is deprecated because it ignores instancing of parent components (e.g. Strapons or pods ) - // if you're calling this method, you're probably not getting the numbers you expect. + // depending on your context, this may or may not be what you want. + // recomend migrating to either: `getAllComponents` or `getActiveInstances` @Deprecated public Collection getActiveComponents() { Queue toProcess = new ArrayDeque(this.getActiveStages());