Merge pull request #744 from teyrana/742-load-crash
Resolves #742 - Crash on rocket-load
This commit is contained in:
commit
56135aafd4
@ -577,34 +577,33 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou
|
||||
* @return the previous SymmetricComponent, or null.
|
||||
*/
|
||||
public final SymmetricComponent getPreviousSymmetricComponent() {
|
||||
if(null == this.parent) {
|
||||
if((null == this.parent) || (null == this.parent.getParent())){
|
||||
return null;
|
||||
}
|
||||
|
||||
final ComponentAssembly assembly = this.getAssembly();
|
||||
// might be: (a) Rocket -- for Centerline/Axial stages
|
||||
// (b) BodyTube -- for Parallel Stages & PodSets
|
||||
final RocketComponent assemblyParent = assembly.getParent();
|
||||
final RocketComponent grandParent = this.parent.getParent();
|
||||
|
||||
// note: this is not guaranteed to _contain_ a stage... but that we're _searching_ for one.
|
||||
int assemblyIndex = assemblyParent.getChildPosition(assembly); // position of stage w/in parent
|
||||
int symmetricIndex = this.parent.getChildPosition(this)-1; // guess at index of previous stage
|
||||
int searchParentIndex = grandParent.getChildPosition(this.parent); // position of stage w/in parent
|
||||
int searchSiblingIndex = this.parent.getChildPosition(this)-1; // guess at index of previous stage
|
||||
|
||||
while( 0 <= assemblyIndex ) {
|
||||
final RocketComponent searchAssembly = assemblyParent.getChild(assemblyIndex);
|
||||
while( 0 <= searchParentIndex ) {
|
||||
final RocketComponent searchParent = grandParent.getChild(searchParentIndex);
|
||||
|
||||
if(searchAssembly instanceof ComponentAssembly){
|
||||
while (0 <= symmetricIndex) {
|
||||
final RocketComponent previousSymmetric = searchAssembly.getChild(symmetricIndex);
|
||||
|
||||
if (previousSymmetric instanceof SymmetricComponent) {
|
||||
return (SymmetricComponent) previousSymmetric;
|
||||
if(searchParent instanceof ComponentAssembly){
|
||||
while (0 <= searchSiblingIndex) {
|
||||
final RocketComponent searchSibling = searchParent.getChild(searchSiblingIndex);
|
||||
if (searchSibling instanceof SymmetricComponent) {
|
||||
return (SymmetricComponent) searchSibling;
|
||||
}
|
||||
--symmetricIndex;
|
||||
--searchSiblingIndex;
|
||||
}
|
||||
}
|
||||
--assemblyIndex;
|
||||
symmetricIndex = searchAssembly.getChildCount() - 1;
|
||||
--searchParentIndex;
|
||||
if( 0 <= searchParentIndex){
|
||||
searchSiblingIndex = grandParent.getChild(searchParentIndex).getChildCount() - 1;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -615,34 +614,33 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou
|
||||
* @return the next SymmetricComponent, or null.
|
||||
*/
|
||||
public final SymmetricComponent getNextSymmetricComponent() {
|
||||
if(null == this.parent) {
|
||||
if((null == this.parent) || (null == this.parent.getParent())){
|
||||
return null;
|
||||
}
|
||||
|
||||
final ComponentAssembly assembly = this.getAssembly();
|
||||
// might be: (a) Rocket -- for centerline stages
|
||||
// (b) BodyTube -- for Parallel Stages
|
||||
final RocketComponent assemblyParent = assembly.getParent();
|
||||
final RocketComponent grandParent = this.parent.getParent();
|
||||
|
||||
// note: this is not guaranteed to _contain_ a stage... but that we're _searching_ for one.
|
||||
int assemblyIndex = assemblyParent.getChildPosition(assembly);
|
||||
int symmetricIndex = this.parent.getChildPosition(this) + 1;
|
||||
int searchParentIndex = grandParent.getChildPosition(this.parent);
|
||||
int searchSiblingIndex = this.parent.getChildPosition(this) + 1;
|
||||
|
||||
while(assemblyIndex < assemblyParent.getChildCount()) {
|
||||
final RocketComponent searchAssembly = assemblyParent.getChild(assemblyIndex);
|
||||
while(searchParentIndex < grandParent.getChildCount()) {
|
||||
final RocketComponent searchParent = grandParent.getChild(searchParentIndex);
|
||||
|
||||
if(searchAssembly instanceof ComponentAssembly){
|
||||
while (symmetricIndex < searchAssembly.getChildCount()) {
|
||||
final RocketComponent nextSymmetric = searchAssembly.getChild(symmetricIndex);
|
||||
if(searchParent instanceof ComponentAssembly){
|
||||
while (searchSiblingIndex < searchParent.getChildCount()) {
|
||||
final RocketComponent searchSibling = searchParent.getChild(searchSiblingIndex);
|
||||
|
||||
if (nextSymmetric instanceof SymmetricComponent) {
|
||||
return (SymmetricComponent) nextSymmetric;
|
||||
if (searchSibling instanceof SymmetricComponent) {
|
||||
return (SymmetricComponent) searchSibling;
|
||||
}
|
||||
++symmetricIndex;
|
||||
++searchSiblingIndex;
|
||||
}
|
||||
}
|
||||
++assemblyIndex;
|
||||
symmetricIndex = searchAssembly.getChildCount() - 1;
|
||||
++searchParentIndex;
|
||||
searchSiblingIndex = 0;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ public class RocketTest extends BaseTestCase {
|
||||
body.setOuterRadiusAutomatic(true);
|
||||
assertEquals(" radius match: ", expRadius, body.getOuterRadius(), EPSILON);
|
||||
}
|
||||
{ // test auto-radius within a stage: body tube -> trailing transition
|
||||
{ // test auto-radius within a stage: tail cone -> body tube
|
||||
final BodyTube body = (BodyTube) booster.getChild(0);
|
||||
assertEquals(" radius match: ", expRadius, body.getOuterRadius(), EPSILON);
|
||||
final Transition tailCone = (Transition)booster.getChild(1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user