From: mfranz Date: Fri, 3 Jun 2005 08:39:50 +0000 (+0000) Subject: I had hoped that gmtime's lack of thread-safety wouldn't bite us. It does. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=be1df4819a45262dbd94f50be0e2538dbb6b637b;p=flightgear.git I had hoped that gmtime's lack of thread-safety wouldn't bite us. It does. Fix jumping clock hands. --- diff --git a/src/ATC/AIMgr.cxx b/src/ATC/AIMgr.cxx index c3682718f..629d5d97b 100644 --- a/src/ATC/AIMgr.cxx +++ b/src/ATC/AIMgr.cxx @@ -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;