X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FTraffic%2FSchedule.cxx;h=3b8e7636db1946dca5d873df945a2236272323ff;hb=474789269b7656509f62339c17e62a55b6157d43;hp=8c0030de1f7a1163ead67111f5d0eadeadfce69c;hpb=4c7fb6c91bbf17119407748d4d49d627748ad037;p=flightgear.git diff --git a/src/Traffic/Schedule.cxx b/src/Traffic/Schedule.cxx index 8c0030de1..3b8e7636d 100644 --- a/src/Traffic/Schedule.cxx +++ b/src/Traffic/Schedule.cxx @@ -115,8 +115,11 @@ FGAISchedule::FGAISchedule(string model, i++) flights.push_back(new FGScheduledFlight((*(*i))));*/ AIManagerRef = 0; - //score = scre; + score = 0; firstRun = true; + runCount = 0; + hits = 0; + initialized = false; } FGAISchedule::FGAISchedule(const FGAISchedule &other) @@ -136,13 +139,17 @@ FGAISchedule::FGAISchedule(const FGAISchedule &other) radius = other.radius; groundOffset = other.groundOffset; flightType = other.flightType; - //score = other.score; + score = other.score; distanceToUser = other.distanceToUser; currentDestination = other.currentDestination; firstRun = other.firstRun; + runCount = other.runCount; + hits = other.hits; + initialized = other.initialized; } + FGAISchedule::~FGAISchedule() { /* for (FGScheduledFlightVecIterator flt = flights.begin(); flt != flights.end(); flt++) @@ -289,7 +296,6 @@ bool FGAISchedule::update(time_t now, const SGVec3d& userCart) if (distanceToUser >= TRAFFICTOAIDISTTOSTART) { return true; // out of visual range, for the moment. } - return createAIAircraft(flight, speed, deptime); } @@ -356,6 +362,16 @@ void FGAISchedule::scheduleFlights() } currentDestination = flight->getArrivalAirport()->getId(); + if (!initialized) { + string departurePort = flight->getDepartureAirport()->getId(); + //cerr << "Scheduled " << registration << " " << score << " for Flight " + // << flight-> getCallSign() << " from " << departurePort << " to " << currentDestination << endl; + if (fgGetString("/sim/presets/airport-id") == departurePort) { + hits++; + } + //runCount++; + initialized = true; + } time_t arr, dep; dep = flight->getDepartureTime(); @@ -482,12 +498,26 @@ double FGAISchedule::getSpeed() SG_CLAMP_RANGE(speed, 300.0, 500.0); return speed; } -/* + +void FGAISchedule::setScore () +{ + if (runCount) { + score = ((double) hits / (double) runCount); + } else { + if (homePort == fgGetString("/sim/presets/airport-id")) { + score = 0.1; + } else { + score = 0.0; + } + } + runCount++; +} + bool compareSchedules(FGAISchedule*a, FGAISchedule*b) { - //return (*a) < (*b); + return (*a) < (*b); } -*/ + // void FGAISchedule::setClosestDistanceToUser() // {