[bugfix] .ork files load motors correctly (again).
This commit is contained in:
parent
a43fbe79bc
commit
1a036904c0
@ -12,6 +12,7 @@ import net.sf.openrocket.file.simplesax.ElementHandler;
|
|||||||
import net.sf.openrocket.file.simplesax.PlainTextHandler;
|
import net.sf.openrocket.file.simplesax.PlainTextHandler;
|
||||||
import net.sf.openrocket.motor.Motor;
|
import net.sf.openrocket.motor.Motor;
|
||||||
import net.sf.openrocket.motor.MotorInstance;
|
import net.sf.openrocket.motor.MotorInstance;
|
||||||
|
import net.sf.openrocket.motor.MotorInstanceId;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationID;
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationID;
|
||||||
import net.sf.openrocket.rocketcomponent.IgnitionEvent;
|
import net.sf.openrocket.rocketcomponent.IgnitionEvent;
|
||||||
import net.sf.openrocket.rocketcomponent.MotorMount;
|
import net.sf.openrocket.rocketcomponent.MotorMount;
|
||||||
@ -64,7 +65,7 @@ class MotorMountHandler extends AbstractElementHandler {
|
|||||||
// System.err.println("closing MotorMount element: "+ element);
|
// System.err.println("closing MotorMount element: "+ element);
|
||||||
|
|
||||||
if (element.equals("motor")) {
|
if (element.equals("motor")) {
|
||||||
// yes, this is confirmed to be the FLIGHT config id, instead of the motor inastance id.
|
// yes, this is confirmed to be the FLIGHT config id, instead of the motor instance id.
|
||||||
FlightConfigurationID fcid = new FlightConfigurationID(attributes.get("configid"));
|
FlightConfigurationID fcid = new FlightConfigurationID(attributes.get("configid"));
|
||||||
if (!fcid.isValid()) {
|
if (!fcid.isValid()) {
|
||||||
warnings.add(Warning.fromString("Illegal motor specification, ignoring."));
|
warnings.add(Warning.fromString("Illegal motor specification, ignoring."));
|
||||||
@ -72,35 +73,16 @@ class MotorMountHandler extends AbstractElementHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Motor motor = motorHandler.getMotor(warnings);
|
Motor motor = motorHandler.getMotor(warnings);
|
||||||
|
|
||||||
MotorInstance motorInstance = motor.getNewInstance();
|
MotorInstance motorInstance = motor.getNewInstance();
|
||||||
|
RocketComponent rc = (RocketComponent)mount;
|
||||||
|
motorInstance.setID( new MotorInstanceId(rc.getID(), 1));
|
||||||
motorInstance.setEjectionDelay(motorHandler.getDelay(warnings));
|
motorInstance.setEjectionDelay(motorHandler.getDelay(warnings));
|
||||||
mount.setMotorInstance(fcid, motorInstance);
|
mount.setMotorInstance(fcid, motorInstance);
|
||||||
|
|
||||||
Rocket rkt = ((RocketComponent)mount).getRocket();
|
Rocket rkt = ((RocketComponent)mount).getRocket();
|
||||||
rkt.createFlightConfiguration(fcid);
|
rkt.createFlightConfiguration(fcid);
|
||||||
|
|
||||||
// // vvvvvvv DEBUG vvvvvvv
|
|
||||||
// if( mount instanceof BodyTube ){
|
|
||||||
// System.err.println(" processing <"+element+"> element with mount: "+((RocketComponent)mount).getName()+" with content: "+content);
|
|
||||||
// MotorInstance justSet = mount.getMotorInstance(fcid);
|
|
||||||
// String shortKey = fcid.key.substring(0,8);
|
|
||||||
// String motorKey = justSet.getMotorID().toString().substring(0,8);
|
|
||||||
// String contains;
|
|
||||||
// if( justSet.isEmpty()){
|
|
||||||
// contains = "empty";
|
|
||||||
// }else{
|
|
||||||
// contains = justSet.getMotor().getDesignation();
|
|
||||||
// }
|
|
||||||
// System.err.println(" set( key:"+ shortKey + " to Motor: "+motorKey+ " containing: "+contains);
|
|
||||||
//
|
|
||||||
// // exhaustive part...
|
|
||||||
//
|
|
||||||
// ((BodyTube)mount).printMotorDebug( fcid );
|
|
||||||
//
|
|
||||||
// rkt.getConfigurationSet().printDebug();
|
|
||||||
// }
|
|
||||||
// // ^^^^^^^ DEBUG ^^^^^^^^
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,12 @@ public class MotorInstance implements FlightConfigurableParameter<MotorInstance>
|
|||||||
private final List<StateChangeListener> listeners = new ArrayList<StateChangeListener>();
|
private final List<StateChangeListener> listeners = new ArrayList<StateChangeListener>();
|
||||||
|
|
||||||
/** Immutable configuration with no motor and zero delay. */
|
/** Immutable configuration with no motor and zero delay. */
|
||||||
public static final MotorInstance EMPTY_INSTANCE = new MotorInstance();
|
public static final MotorInstance EMPTY_INSTANCE = new MotorInstance(){
|
||||||
|
@Override
|
||||||
|
public boolean equals( Object other ){
|
||||||
|
return (this==other);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
protected MotorInstance() {
|
protected MotorInstance() {
|
||||||
this.id = MotorInstanceId.EMPTY_ID;
|
this.id = MotorInstanceId.EMPTY_ID;
|
||||||
|
@ -1042,10 +1042,6 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
this.position = Coordinate.ZERO;
|
this.position = Coordinate.ZERO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// debug vv
|
|
||||||
else if( this instanceof RingComponent ){
|
|
||||||
log.error("Attempting to set offset of a parent-less class :"+this.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.offset = newOffset;
|
this.offset = newOffset;
|
||||||
// best-effort approximation. this should be corrected later on in the initialization process.
|
// best-effort approximation. this should be corrected later on in the initialization process.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user