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 {
if (src.rocket.hasMotors(src.motorID)) {
// Try to find a closely matching motor ID
MotorDescriptionSubstitutor formatter = Application.getInjector().getInstance(MotorDescriptionSubstitutor.class);
// 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;
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;
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;
}