Fixed bug that prevents adding stages to a rocket

This commit is contained in:
Sampo Niskanen 2010-09-05 12:34:03 +00:00
parent f535b8caf0
commit b9a0800ca5
4 changed files with 56 additions and 55 deletions

View File

@ -1,3 +1,7 @@
2010-09-05 Sampo Niskanen
* [BUG] Fixed bug that prevents adding stages to a rocket
2010-09-04 Sampo Niskanen 2010-09-04 Sampo Niskanen
* Added launch rod velocity to FlightData * Added launch rod velocity to FlightData

View File

@ -3,19 +3,13 @@ package net.sf.openrocket.aerodynamics;
import java.util.Map; import java.util.Map;
import net.sf.openrocket.rocketcomponent.Configuration; import net.sf.openrocket.rocketcomponent.Configuration;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Coordinate;
/** /**
* A class that is the base of all aerodynamical calculations. * An abstract aerodynamic calculator implementation, that offers basic implementation
* <p> * of some methods and methods for cache validation and purging.
* A rocket must be assigned to this class before any operations are allowed.
* This can be done using the constructor or using the
* {@link #setRocket(Rocket)} method. The default is a
* <code>null</code> configuration, in which case the calculation
* methods throw {@link NullPointerException}.
* *
* @author Sampo Niskanen <sampo.niskanen@iki.fi> * @author Sampo Niskanen <sampo.niskanen@iki.fi>
*/ */
@ -33,7 +27,7 @@ public abstract class AbstractAerodynamicCalculator implements AerodynamicCalcul
/** The aerodynamic modification ID of the latest rocket */ /** The aerodynamic modification ID of the latest rocket */
private int rocketAeroModID = -1; private int rocketAeroModID = -1;
private int stageCount = -1;
@ -89,8 +83,10 @@ public abstract class AbstractAerodynamicCalculator implements AerodynamicCalcul
* @param configuration the configuration of the current call * @param configuration the configuration of the current call
*/ */
protected final void checkCache(Configuration configuration) { protected final void checkCache(Configuration configuration) {
if (rocketAeroModID != configuration.getRocket().getAerodynamicModID()) { if (rocketAeroModID != configuration.getRocket().getAerodynamicModID() ||
stageCount != configuration.getStageCount()) {
rocketAeroModID = configuration.getRocket().getAerodynamicModID(); rocketAeroModID = configuration.getRocket().getAerodynamicModID();
stageCount = configuration.getStageCount();
voidAerodynamicCache(); voidAerodynamicCache();
} }
} }

View File

@ -10,6 +10,7 @@ import net.sf.openrocket.rocketcomponent.Configuration;
public abstract class AbstractMassCalculator implements MassCalculator { public abstract class AbstractMassCalculator implements MassCalculator {
private int rocketMassModID = -1; private int rocketMassModID = -1;
private int stageCount = -1;
/** /**
@ -24,8 +25,10 @@ public abstract class AbstractMassCalculator implements MassCalculator {
* @param configuration the configuration of the current call * @param configuration the configuration of the current call
*/ */
protected final void checkCache(Configuration configuration) { protected final void checkCache(Configuration configuration) {
if (rocketMassModID != configuration.getRocket().getMassModID()) { if (rocketMassModID != configuration.getRocket().getMassModID() ||
stageCount != configuration.getStageCount()) {
rocketMassModID = configuration.getRocket().getMassModID(); rocketMassModID = configuration.getRocket().getMassModID();
stageCount = configuration.getStageCount();
voidMassCache(); voidMassCache();
} }
} }

View File

@ -47,7 +47,6 @@ public class Configuration implements Cloneable, ChangeSource, ComponentChangeLi
private int modID = 0; private int modID = 0;
private int modIDadd = 0;
/** /**
@ -189,7 +188,6 @@ public class Configuration implements Cloneable, ChangeSource, ComponentChangeLi
/** /**
* Removes the listener connection to the rocket and listeners of this object. * Removes the listener connection to the rocket and listeners of this object.
* This configuration may not be used after a call to this method! * This configuration may not be used after a call to this method!