Make SimulationOptions.copyFrom prefer matches based on exact match of

the configuration id.
This commit is contained in:
kruland2607 2013-03-27 22:12:09 -05:00
parent 4cc3485fa0
commit ea3aeedf1b

View File

@ -404,21 +404,26 @@ public class SimulationOptions implements ChangeSource, Cloneable {
} else { } else {
if (src.rocket.hasMotors(src.motorID)) { if (src.rocket.hasMotors(src.motorID)) {
// Try to find a closely matching motor ID // First check for exact match:
MotorDescriptionSubstitutor formatter = Application.getInjector().getInstance(MotorDescriptionSubstitutor.class); 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 motorDesc = formatter.getMotorConfigurationDescription(src.rocket, src.motorID);
String matchID = null; String matchID = null;
for (String id : this.rocket.getFlightConfigurationIDs()) { for (String id : this.rocket.getFlightConfigurationIDs()) {
String motorDesc2 = formatter.getMotorConfigurationDescription(this.rocket, id); String motorDesc2 = formatter.getMotorConfigurationDescription(this.rocket, id);
if (motorDesc.equals(motorDesc2)) { if (motorDesc.equals(motorDesc2)) {
matchID = id; matchID = id;
break; break;
}
} }
}
this.motorID = matchID; this.motorID = matchID;
}
} else { } else {
this.motorID = null; this.motorID = null;
} }