Fix IllegalStateException when export/print

Correct the logic for detecting if a motor has an invalid
FlightConfigurationId and throw an IllegalStateException only in the
case that it has an error.

Additionally, fix the lookup for the stageMass. The wrong value was
passed to the MassCalculator.getCGAnalysis(..) which resulted in
a NullPointerException.

Fixes #531

Signed-off-by: Billy Olsen <billy.olsen@gmail.com>
This commit is contained in:
Billy Olsen 2020-03-14 20:01:54 -07:00
parent dee887479d
commit 6dae530acc

View File

@ -328,7 +328,7 @@ public class DesignReport {
MassCalculator massCalc = new MassCalculator();
if( !motorId.hasError() ){
if( motorId.hasError() ){
throw new IllegalStateException("Attempted to add motor data with an invalid fcid");
}
rocket.createFlightConfiguration(motorId);
@ -349,7 +349,7 @@ public class DesignReport {
config.clearAllStages();
config.setOnlyStage(stage);
stage++;
stageMass = massCalc.getCGAnalysis( config).get(stage).weight;
stageMass = massCalc.getCGAnalysis(config).get(c).weight;
// Calculate total thrust-to-weight from only lowest stage motors
totalTTW = 0;
topBorder = true;