[fix] Rockets now correctly copy their FlightConfigurations
This commit is contained in:
parent
1eb329b850
commit
41c06572a7
@ -72,6 +72,15 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
|
|
||||||
private int modID = 0;
|
private int modID = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Default configuration with the specified <code>Rocket</code>.
|
||||||
|
*
|
||||||
|
* @param rocket the rocket
|
||||||
|
*/
|
||||||
|
public FlightConfiguration(final Rocket rocket) {
|
||||||
|
this(rocket, FlightConfigurationId.DEFAULT_VALUE_FCID);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new configuration with the specified <code>Rocket</code>.
|
* Create a new configuration with the specified <code>Rocket</code>.
|
||||||
*
|
*
|
||||||
|
@ -79,7 +79,7 @@ public class Rocket extends ComponentAssembly {
|
|||||||
functionalModID = modID;
|
functionalModID = modID;
|
||||||
|
|
||||||
// must be after the hashmaps :P
|
// must be after the hashmaps :P
|
||||||
FlightConfiguration defaultConfig = new FlightConfiguration(this, FlightConfigurationId.DEFAULT_VALUE_FCID);
|
final FlightConfiguration defaultConfig = new FlightConfiguration(this, FlightConfigurationId.DEFAULT_VALUE_FCID);
|
||||||
configSet = new FlightConfigurableParameterSet<>( defaultConfig );
|
configSet = new FlightConfigurableParameterSet<>( defaultConfig );
|
||||||
this.selectedConfiguration = defaultConfig;
|
this.selectedConfiguration = defaultConfig;
|
||||||
}
|
}
|
||||||
@ -330,15 +330,26 @@ public class Rocket extends ComponentAssembly {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Rocket copyWithOriginalID() {
|
public Rocket copyWithOriginalID() {
|
||||||
Rocket copy = (Rocket) super.copyWithOriginalID();
|
final Rocket copyRocket = (Rocket) super.copyWithOriginalID();
|
||||||
|
|
||||||
// Rocket copy is cloned, so non-trivial members must be cloned as well:
|
// Rocket copy is cloned, so non-trivial members must be cloned as well:
|
||||||
copy.stageMap = new HashMap<Integer, AxialStage>();
|
copyRocket.stageMap = new HashMap<>();
|
||||||
copy.configSet = new FlightConfigurableParameterSet<FlightConfiguration>( this.configSet );
|
for( Map.Entry<Integer,AxialStage> entry : this.stageMap.entrySet()){
|
||||||
copy.selectedConfiguration = copy.configSet.get( this.getSelectedConfiguration().getId());
|
final AxialStage stage = (AxialStage)copyRocket.findComponent(entry.getValue().getID());
|
||||||
copy.listenerList = new HashSet<EventListener>();
|
copyRocket.stageMap.put(entry.getKey(), stage);
|
||||||
|
}
|
||||||
|
|
||||||
return copy;
|
// these flight configurations need to reference the _new_ Rocket copy
|
||||||
|
// the default value needs to be explicitly set, because it has different semantics
|
||||||
|
copyRocket.configSet = new FlightConfigurableParameterSet<>(new FlightConfiguration(copyRocket));
|
||||||
|
for (FlightConfigurationId key : this.configSet.getIds()) {
|
||||||
|
copyRocket.configSet.set(key, new FlightConfiguration(copyRocket, key));
|
||||||
|
}
|
||||||
|
|
||||||
|
copyRocket.selectedConfiguration = copyRocket.configSet.get( this.getSelectedConfiguration().getId());
|
||||||
|
copyRocket.listenerList = new HashSet<>();
|
||||||
|
|
||||||
|
return copyRocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFlightConfigurationCount() {
|
public int getFlightConfigurationCount() {
|
||||||
@ -376,7 +387,12 @@ public class Rocket extends ComponentAssembly {
|
|||||||
this.functionalModID = r.functionalModID;
|
this.functionalModID = r.functionalModID;
|
||||||
this.refType = r.refType;
|
this.refType = r.refType;
|
||||||
this.customReferenceLength = r.customReferenceLength;
|
this.customReferenceLength = r.customReferenceLength;
|
||||||
this.configSet = new FlightConfigurableParameterSet<FlightConfiguration>( r.configSet );
|
|
||||||
|
// these flight configurations need to reference the _this_ Rocket:
|
||||||
|
this.configSet.setDefault(new FlightConfiguration(this));
|
||||||
|
for (FlightConfigurationId key : r.configSet.map.keySet()) {
|
||||||
|
this.configSet.set(key, new FlightConfiguration(this, key));
|
||||||
|
}
|
||||||
|
|
||||||
this.perfectFinish = r.perfectFinish;
|
this.perfectFinish = r.perfectFinish;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user