]> git.mxchange.org Git - flightgear.git/blobdiff - src/Environment/environment_ctrl.cxx
Merge commit 'refs/merge-requests/1551' of git://gitorious.org/fg/flightgear into...
[flightgear.git] / src / Environment / environment_ctrl.cxx
index ea9c9b628d9bb490985b0955d480ea0abf5c7bbc..74f1d82ea9275f15de2e80d4a2be999ed826e47f 100644 (file)
@@ -25,6 +25,7 @@
 #endif
 
 #include <algorithm>
+#include <cstring>
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/structure/commands.hxx>
@@ -132,7 +133,9 @@ void
 FGInterpolateEnvironmentCtrl::init ()
 {
        read_table( boundary_n, _boundary_table);
-       read_table( aloft_n, _aloft_table);
+       // pass in a pointer to the environment of the last bondary layer as
+       // a starting point
+       read_table( aloft_n, _aloft_table, &(*(_boundary_table.end()-1))->environment);
 }
 
 void
@@ -142,7 +145,7 @@ FGInterpolateEnvironmentCtrl::reinit ()
 }
 
 void
-FGInterpolateEnvironmentCtrl::read_table (const SGPropertyNode * node, vector<bucket *> &table)
+FGInterpolateEnvironmentCtrl::read_table (const SGPropertyNode * node, vector<bucket *> &table, FGEnvironment * parent )
 {
        double last_altitude_ft = 0.0;
        double sort_required = false;
@@ -163,8 +166,11 @@ FGInterpolateEnvironmentCtrl::read_table (const SGPropertyNode * node, vector<bu
                                b = new bucket;
                                table.push_back(b);
                        }
+                       if (i == 0 && parent != NULL )
+                               b->environment.copy( *parent );
                        if (i > 0)
                                b->environment.copy(table[i-1]->environment);
+                       
                        b->environment.read(child);
                        b->altitude_ft = b->environment.get_elevation_ft();