diff --git a/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java b/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java index 904b87053..51f78e511 100644 --- a/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java +++ b/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java @@ -338,11 +338,11 @@ public class ThrustCurveMotor implements Motor, Comparable, Se int timeIndex = 0; - while( timeIndex < time.length-2 && startTime > time[timeIndex+1] ) { + while( timeIndex < time.length-1 && startTime > time[timeIndex+1] ) { timeIndex++; } - if ( timeIndex == time.length ) { + if ( timeIndex == time.length-1 ) { return 0.0; } diff --git a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java index 2ec435327..70f645ab1 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java @@ -63,6 +63,7 @@ public class FlightConfiguration implements FlightConfigurableParameter stages = new HashMap(); final protected HashMap motors = new HashMap(); + final private Collection activeMotors = new ArrayList(); private int boundsModID = -1; private BoundingBox cachedBounds = new BoundingBox(); @@ -109,23 +110,23 @@ public class FlightConfiguration implements FlightConfigurableParameter getActiveMotors() { - Collection activeMotors = new ArrayList(); - for( MotorConfiguration config : this.motors.values() ){ - if( isComponentActive( config.getMount() )){ - activeMotors.add( config ); - } - } return activeMotors; } private void updateMotors() { - this.motors.clear(); + motors.clear(); for ( RocketComponent comp : getActiveComponents() ){ if (( comp instanceof MotorMount )&&( ((MotorMount)comp).isMotorMount())){ @@ -519,10 +515,16 @@ public class FlightConfiguration implements FlightConfigurableParameter activeMotorList = status.getMotors(); + Collection activeMotorList = status.getActiveMotors(); for (MotorClusterState currentMotorState : activeMotorList ) { thrust += currentMotorState.getAverageThrust( status.getSimulationTime(), currentTime ); //thrust += currentMotorState.getThrust( currentTime );