X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FTraffic%2FSchedFlight.cxx;h=5575f6ee090f924b0f5aace94b140bced3cb5c17;hb=b3d59ed5636cc416f83db0fd5f2698759af944fb;hp=731ee6b8fefe3be576f5b6f602dcd9f1486831f3;hpb=943b1b8e7923aa93d1e9bb1961d520d98a4ed9a6;p=flightgear.git diff --git a/src/Traffic/SchedFlight.cxx b/src/Traffic/SchedFlight.cxx index 731ee6b8f..5575f6ee0 100644 --- a/src/Traffic/SchedFlight.cxx +++ b/src/Traffic/SchedFlight.cxx @@ -33,7 +33,6 @@ * * TODO: * - Check the code for known portability issues - * - Find an alternative for the depricated Point3D class * *****************************************************************************/ @@ -50,11 +49,7 @@ #include #include -#include - #include -#include -#include #include #include #include @@ -79,21 +74,25 @@ FGScheduledFlight::FGScheduledFlight() { + initialized = false; + available = true; } FGScheduledFlight::FGScheduledFlight(const FGScheduledFlight &other) { - callsign = other.callsign; - fltRules = other.fltRules; - departurePort = other.departurePort; - depId = other.depId; - arrId = other.arrId; - departureTime = other.departureTime; - cruiseAltitude = other.cruiseAltitude; - arrivalPort = other.arrivalPort; - arrivalTime = other.arrivalTime; - repeatPeriod = other.repeatPeriod; - initialized = other.initialized; + callsign = other.callsign; + fltRules = other.fltRules; + departurePort = other.departurePort; + depId = other.depId; + arrId = other.arrId; + departureTime = other.departureTime; + cruiseAltitude = other.cruiseAltitude; + arrivalPort = other.arrivalPort; + arrivalTime = other.arrivalTime; + repeatPeriod = other.repeatPeriod; + initialized = other.initialized; + requiredAircraft = other.requiredAircraft; + available = other.available; } FGScheduledFlight::FGScheduledFlight(const string& cs, @@ -103,7 +102,8 @@ FGScheduledFlight::FGScheduledFlight(const string& cs, int cruiseAlt, const string& deptime, const string& arrtime, - const string& rep) + const string& rep, + const string& reqAC) { callsign = cs; fltRules = fr; @@ -115,6 +115,7 @@ FGScheduledFlight::FGScheduledFlight(const string& cs, //departureTime = processTimeString(deptime); //arrivalTime = processTimeString(arrtime); cruiseAltitude = cruiseAlt; + requiredAircraft = reqAC; // Process the repeat period string if (rep.find("WEEK",0) != string::npos) @@ -127,19 +128,22 @@ FGScheduledFlight::FGScheduledFlight(const string& cs, } else { - cerr << "Unknown repeat period" << endl; - exit(1); + repeatPeriod = 365*24*60*60; + SG_LOG( SG_GENERAL, SG_ALERT, "Unknown repeat period in flight plan " + "of flight '" << cs << "': " << rep ); } // What we still need to do is preprocess the departure and // arrival times. departureTime = processTimeString(deptime); arrivalTime = processTimeString(arrtime); + //departureTime += rand() % 300; // Make sure departure times are not limited to 5 minute increments. if (departureTime > arrivalTime) { departureTime -= repeatPeriod; } initialized = false; + available = true; } @@ -262,16 +266,16 @@ FGAirport * FGScheduledFlight::getArrivalAirport () bool FGScheduledFlight::initializeAirports() { //cerr << "Initializing using : " << depId << " " << arrId << endl; - departurePort = globals->get_airports()->search(depId); + departurePort = FGAirport::findByIdent(depId); if(departurePort == NULL) { - cerr << "Could not find " << depId << endl; + SG_LOG( SG_GENERAL, SG_WARN, "Traffic manager could not find departure airport : " << depId); return false; } - arrivalPort = globals->get_airports()->search(arrId); + arrivalPort = FGAirport::findByIdent(arrId); if(arrivalPort == NULL) { - cerr << "Could not find " << arrId << endl; + SG_LOG( SG_GENERAL, SG_WARN, "Traffic manager could not find arrival airport : " << arrId); return false; } @@ -280,3 +284,9 @@ bool FGScheduledFlight::initializeAirports() initialized = true; return true; } + + +bool compareScheduledFlights(FGScheduledFlight *a, FGScheduledFlight *b) +{ + return (*a) < (*b); +};