]> git.mxchange.org Git - flightgear.git/commitdiff
I had hoped that gmtime's lack of thread-safety wouldn't bite us. It does.
authormfranz <mfranz>
Fri, 3 Jun 2005 08:39:50 +0000 (08:39 +0000)
committermfranz <mfranz>
Fri, 3 Jun 2005 08:39:50 +0000 (08:39 +0000)
Fix jumping clock hands.

src/ATC/AIMgr.cxx

index c3682718fa20ff9eecfa04da0d74d98d356c1062..629d5d97b09f1d4db7c36233c7c64d5a93d011ec 100644 (file)
@@ -353,8 +353,13 @@ void FGAIMgr::GenerateSimpleAirportTraffic(string ident, double min_dist) {
        bool cessna = true;
        
        // Get the time and only operate VFR in the (approximate) daytime.
-       time_t now = globals->get_time_params()->get_cur_time() + time_t(aptpos.lon() * 240.0);
-       int loc_time = gmtime(&now)->tm_hour;
+       struct tm *t = globals->get_time_params()->getGmt();
+       int loc_time = t->tm_hour + int(aptpos.lon() / (360.0 / 24.0));
+       while (loc_time < 0)
+               loc_time += 24;
+       while (loc_time >= 24)
+               loc_time -= 24;
+
        //cout << "loc_time = " << loc_time << '\n';
        if(loc_time < 7 || loc_time > 19) return;