} else {
return 0;
}
- time_t now = time(NULL) + fgGetLong("/sim/time/warp");
+ time_t now = globals->get_time_params()->get_cur_time();
time_t arrivalTime = fp->getArrivalTime();
time_t ete = tracklength / ((speed * SG_NM_TO_METER) / 3600.0);
#include <simgear/constants.h>
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
+#include <simgear/timing/sg_time.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
const string& acType,
const string& airline)
{
- time_t now = time(NULL) + fgGetLong("/sim/time/warp");
+ time_t now = globals->get_time_params()->get_cur_time();
time_t timeDiff = now-start;
leg = 1;
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/props/props.hxx>
#include <simgear/props/props_io.hxx>
+#include <simgear/timing/sg_time.hxx>
#include <Airports/airport.hxx>
#include <Airports/runways.hxx>
double turnDistance = (2 * M_PI * initialTurnRadius) * (side / 360.0);
time_t remaining =
(turnDistance + distance) / ((vDescent * SG_NM_TO_METER) / 3600.0);
- time_t now = time(NULL) + fgGetLong("/sim/time/warp");
+ time_t now = globals->get_time_params()->get_cur_time();
+
//if (ac->getTrafficRef()->getCallSign() == fgGetString("/ai/track-callsign")) {
// cerr << " Arrival time estimation: turn angle " << side << ". Turn distance " << turnDistance << ". Linear distance " << distance << ". Time to go " << remaining << endl;
// //exit(1);
#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/structure/exception.hxx>
#include <simgear/timing/timestamp.hxx>
+#include <simgear/timing/sg_time.hxx>
#include <Airports/airport.hxx>
#include <Airports/dynamics.hxx>
} else {
current->setHoldPosition(true);
int state = current->getState();
- time_t now = time(NULL) + fgGetLong("/sim/time/warp");
+ time_t now = globals->get_time_params()->get_cur_time();
+
if ((now - lastTransmission) > 15) {
available = true;
}
} else {
return;
}
- time_t now = time(NULL) + fgGetLong("/sim/time/warp");
+
+ time_t now = globals->get_time_params()->get_cur_time();
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
SG_LOG(SG_GENERAL, SG_ALERT,
"AI error: Trying to access non-existing aircraft in FGGroundNetwork::checkHoldPosition at " << SG_ORIGIN);
FGScenery * local_scenery = globals->get_scenery();
// double elevation_meters = 0.0;
// double elevation_feet = 0.0;
- time_t now = time(NULL) + fgGetLong("/sim/time/warp");
+ time_t now = globals->get_time_params()->get_cur_time();
+
//for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) {
//double dx = 0;
void FGGroundController::update(double dt)
{
- time_t now = time(NULL) + fgGetLong("/sim/time/warp");
+ time_t now = globals->get_time_params()->get_cur_time();
FGGroundNetwork* network = dynamics->getGroundNetwork();
network->unblockAllSegments(now);
int priority = 1;
#include <simgear/scene/material/matlib.hxx>
#include <simgear/scene/material/mat.hxx>
#include <simgear/scene/util/OsgMath.hxx>
+#include <simgear/timing/sg_time.hxx>
+
#include <Scenery/scenery.hxx>
#include "trafficcontrol.hxx"
estimatedArrivalTimes.push_back(newEta);
sort(estimatedArrivalTimes.begin(), estimatedArrivalTimes.end());
// do some housekeeping : remove any timestamps that are past
- time_t now = time(NULL) + fgGetLong("/sim/time/warp");
+
+ time_t now = globals->get_time_params()->get_cur_time();
+
TimeVectorIterator i = estimatedArrivalTimes.begin();
while (i != estimatedArrivalTimes.end()) {
if ((*i) < now) {
bool FGTrafficRecord::isActive(int margin) const
{
- time_t now = time(NULL) + fgGetLong("/sim/time/warp");
+ time_t now = globals->get_time_params()->get_cur_time();
time_t deptime = aircraft->getTrafficRef()->getDepartureTime();
return ((now + margin) > deptime);
}
// The user controlled aircraft should have crased here, because it doesn't have a traffic reference.
// NOTE: if we create a traffic schedule for the user aircraft, we can use this to plan a flight.
time_t startTime = i->getAircraft()->getTrafficRef()->getDepartureTime();
- time_t now = time(NULL) + fgGetLong("/sim/time/warp");
+ time_t now = globals->get_time_params()->get_cur_time();
+
//cerr << i->getAircraft()->getTrafficRef()->getCallSign()
// << " is scheduled to depart in " << startTime-now << " seconds. Available = " << available
// << " at parking " << getGateName(i->getAircraft()) << endl;
//for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) {
double dx = 0;
- time_t now = time(NULL) + fgGetLong("/sim/time/warp");
+ time_t now = globals->get_time_params()->get_cur_time();
+
for (TrafficVectorIterator i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
if (i->isActive(300)) {
// Handle start point
#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/xml/easyxml.hxx>
+#include <simgear/timing/sg_time.hxx>
#include <AIModel/AIFlightPlan.hxx>
#include <AIModel/AIManager.hxx>
const string &req,
time_t min, time_t max)
{
- time_t now = time(NULL) + fgGetLong("/sim/time/warp");
+ time_t now = globals->get_time_params()->get_cur_time();
FGTrafficManager *tmgr = (FGTrafficManager *) globals->get_subsystem("traffic-manager");
FGScheduledFlightVecIterator fltBegin, fltEnd;
#include <simgear/props/props.hxx>
#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/structure/exception.hxx>
+#include <simgear/timing/sg_time.hxx>
#include <simgear/xml/easyxml.hxx>
#include <simgear/threads/SGThread.hxx>
finishInit();
}
- time_t now = time(NULL) + fgGetLong("/sim/time/warp");
+
if (scheduledAircraft.empty()) {
return;
}
SGVec3d userCart = globals->get_aircraft_position_cart();
-
+
if (currAircraft == scheduledAircraft.end()) {
currAircraft = scheduledAircraft.begin();
}
+ time_t now = globals->get_time_params()->get_cur_time();
+
//cerr << "Processing << " << (*currAircraft)->getRegistration() << " with score " << (*currAircraft)->getScore() << endl;
if ((*currAircraft)->update(now, userCart)) {
// schedule is done - process another aircraft in next iteration