From be1df4819a45262dbd94f50be0e2538dbb6b637b Mon Sep 17 00:00:00 2001 From: mfranz Date: Fri, 3 Jun 2005 08:39:50 +0000 Subject: [PATCH] I had hoped that gmtime's lack of thread-safety wouldn't bite us. It does. Fix jumping clock hands. --- src/ATC/AIMgr.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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; -- 2.39.5