]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/panel.cxx
Fix two problems:
[flightgear.git] / src / Cockpit / panel.cxx
index 25c2c44e4532a1dbf742749e65015b4a2071e93f..bee42a477766ecd75ba3cf9e3eaccf26fa62c670 100644 (file)
@@ -269,7 +269,7 @@ FGPanel::unbind ()
  * Update the panel.
  */
 void
-FGPanel::update (int dt)
+FGPanel::update (double dt)
 {
                                // TODO: cache the nodes
     _visibility = fgGetBool("/sim/panel/visibility");
@@ -786,10 +786,15 @@ void
 FGLayeredInstrument::draw ()
 {
   if (test()) {
+    float z = 0.1f;
+    float z_inc = 0.01;
+    bool vc = fgGetBool("/sim/virtual-cockpit");
     for (int i = 0; i < (int)_layers.size(); i++) {
       glPushMatrix();
-      if(!fgGetBool("/sim/virtual-cockpit"))
-         glTranslatef(0.0, 0.0, (i / 100.0) + 0.1);
+      if(!vc) {
+        glTranslatef(0.0, 0.0, z);
+        z += z_inc;
+      }
       _layers[i]->draw();
       glPopMatrix();
     }
@@ -1007,7 +1012,29 @@ FGTextLayer::draw ()
     text_renderer.start3f(0, 0, 0);
 
     _now.stamp();
-    if (_now - _then > 100000) {
+    long diff = _now - _then;
+#if 0
+    // It would be nice to keep this #ifdef'd stuff for (04/18/2002 +
+    // a couple days) as I verify my solution to the panel text
+    // drawing problem is actually correct. -CLO
+    cout << "time diff = " << diff << endl;
+    if ( _now - _then < 0 ) {
+        cout << "Eeek, the past is now in the future!" << endl;
+        cout << "Now = " << _now.get_seconds() << " seconds "
+             << _now.get_usec() << "usecs" << endl;
+        cout << "Past = " << _then.get_seconds() << " seconds "
+             << _then.get_usec() << "usecs" << endl;
+        exit(-1);
+    }
+#endif
+    if (diff > 100000 || diff < 0 ) {
+      // ( diff < 0 ) is a sanity check and indicates our time stamp
+      // difference math probably overflowed.  We can handle a max
+      // difference of 35.8 minutes since the returned value is in
+      // usec.  So if the panel is left off longer than that we can
+      // over flow the math with it is turned back on.  This (diff <
+      // 0) catches that situation, get's us out of trouble, and
+      // back on track.
       recalc_value();
       _then = _now;
     }
@@ -1096,6 +1123,7 @@ const char *
 FGTextLayer::Chunk::getValue () const
 {
   if (test()) {
+    _buf[0] = '\0';
     switch (_type) {
     case TEXT:
       sprintf(_buf, _fmt.c_str(), _text.c_str());