diff --git a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java index f9bb927ca..bffa62ca5 100644 --- a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java +++ b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java @@ -251,25 +251,8 @@ public class BasicEventSimulationEngine implements SimulationEngine { log.trace("HandleEvents: current branch = " + currentStatus.getFlightData().getBranchName()); for (event = nextEvent(); event != null; event = nextEvent()) { - log.trace("EventQueue = " + currentStatus.getEventQueue().toString()); - - // Ignore events for components that are no longer attached to the rocket - if (event.getSource() != null && event.getSource().getParent() != null && - !currentStatus.getConfiguration().isComponentActive(event.getSource())) { - continue; - } - - // Call simulation listeners, allow aborting event handling - if (!SimulationListenerHelper.fireHandleFlightEvent(currentStatus, event)) { - continue; - } - - if (event.getType() == FlightEvent.Type.RECOVERY_DEVICE_DEPLOYMENT) { - RecoveryDevice device = (RecoveryDevice) event.getSource(); - if (!SimulationListenerHelper.fireRecoveryDeviceDeployment(currentStatus, device)) { - continue; - } - } + log.trace("Obtained event from queue: " + event.toString()); + log.trace("Remaining EventQueue = " + currentStatus.getEventQueue().toString()); // Check for motor ignition events, add ignition events to queue for (MotorClusterState state : currentStatus.getActiveMotors() ){ @@ -291,6 +274,25 @@ public class BasicEventSimulationEngine implements SimulationEngine { } } + // Ignore events for components that are no longer attached to the rocket + if (event.getSource() != null && event.getSource().getParent() != null && + !currentStatus.getConfiguration().isComponentActive(event.getSource())) { + log.trace("Ignoring event from unattached componenent"); + continue; + } + + // Call simulation listeners, allow aborting event handling + if (!SimulationListenerHelper.fireHandleFlightEvent(currentStatus, event)) { + continue; + } + + if (event.getType() == FlightEvent.Type.RECOVERY_DEVICE_DEPLOYMENT) { + RecoveryDevice device = (RecoveryDevice) event.getSource(); + if (!SimulationListenerHelper.fireRecoveryDeviceDeployment(currentStatus, device)) { + continue; + } + } + // Check for stage separation event for (AxialStage stage : currentStatus.getConfiguration().getActiveStages()) {