From ea3aeedf1bdc97edcbab36acd01bea6439519686 Mon Sep 17 00:00:00 2001 From: kruland2607 Date: Wed, 27 Mar 2013 22:12:09 -0500 Subject: [PATCH] Make SimulationOptions.copyFrom prefer matches based on exact match of the configuration id. --- .../simulation/SimulationOptions.java | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/core/src/net/sf/openrocket/simulation/SimulationOptions.java b/core/src/net/sf/openrocket/simulation/SimulationOptions.java index 8a5ca622c..c77ef1fa1 100644 --- a/core/src/net/sf/openrocket/simulation/SimulationOptions.java +++ b/core/src/net/sf/openrocket/simulation/SimulationOptions.java @@ -404,21 +404,26 @@ public class SimulationOptions implements ChangeSource, Cloneable { } else { if (src.rocket.hasMotors(src.motorID)) { - // Try to find a closely matching motor ID - MotorDescriptionSubstitutor formatter = Application.getInjector().getInstance(MotorDescriptionSubstitutor.class); - - String motorDesc = formatter.getMotorConfigurationDescription(src.rocket, src.motorID); - String matchID = null; - - for (String id : this.rocket.getFlightConfigurationIDs()) { - String motorDesc2 = formatter.getMotorConfigurationDescription(this.rocket, id); - if (motorDesc.equals(motorDesc2)) { - matchID = id; - break; + // First check for exact match: + if (this.rocket.isFlightConfigurationID(src.motorID)) { + this.motorID = src.motorID; + } else { + // Try to find a closely matching motor ID + MotorDescriptionSubstitutor formatter = Application.getInjector().getInstance(MotorDescriptionSubstitutor.class); + + String motorDesc = formatter.getMotorConfigurationDescription(src.rocket, src.motorID); + String matchID = null; + + for (String id : this.rocket.getFlightConfigurationIDs()) { + String motorDesc2 = formatter.getMotorConfigurationDescription(this.rocket, id); + if (motorDesc.equals(motorDesc2)) { + matchID = id; + break; + } } + + this.motorID = matchID; } - - this.motorID = matchID; } else { this.motorID = null; }