]> git.mxchange.org Git - flightgear.git/commitdiff
Detect zero length fuselage in YASim/Airplane.cpp. Also, initialized _failureMsg...
authorCsaba Halasz <hcs@vostro.(none)>
Sun, 25 Oct 2009 15:38:31 +0000 (16:38 +0100)
committerTim Moore <timoore@redhat.com>
Tue, 22 Dec 2009 06:17:27 +0000 (07:17 +0100)
src/FDM/YASim/Airplane.cpp

index 1b3fbd4ba8ebfa47c4b2980f57ce8dbb8e6ccefe..483da426911dcdcd73addc1da6bb6991d6068551 100644 (file)
@@ -51,6 +51,8 @@ Airplane::Airplane()
     _liftRatio = 1;
     _cruiseAoA = 0;
     _tailIncidence = 0;
+
+    _failureMsg = 0;
 }
 
 Airplane::~Airplane()
@@ -507,6 +509,10 @@ float Airplane::compileFuselage(Fuselage* f)
     float fwd[3];
     Math::sub3(f->front, f->back, fwd);
     float len = Math::mag3(fwd);
+    if (len == 0) {
+        _failureMsg = "Zero length fuselage";
+       return 0;
+    }
     float wid = f->width;
     int segs = (int)Math::ceil(len/wid);
     float segWgt = len*wid/segs;
@@ -688,6 +694,10 @@ void Airplane::compile()
         _model.setGroundEffect(gepos, gespan, 0.15f);
     }
 
+    // solve function below resets failure message
+    // so check if we have any problems and abort here
+    if (_failureMsg) return;
+
     solveGear();
     if(_wing && _tail) solve();
     else