@@ -347,9 +347,14 @@ void DataManager::setActiveAirports(const std::list<std::string> activeAirports)
347
347
}
348
348
349
349
void DataManager::queueFlightplanUpdate (EuroScopePlugIn::CFlightPlan flightplan) {
350
- if (false == flightplan.IsValid ()) return ;
350
+ if (false == flightplan.IsValid () || nullptr == flightplan.GetFlightPlanData ().GetPlanType () ||
351
+ nullptr == flightplan.GetFlightPlanData ().GetOrigin ())
352
+ return ;
353
+
354
+ auto pilot = this ->CFlightPlanToPilot (flightplan);
355
+
351
356
std::lock_guard guard (this ->m_euroscopeUpdatesLock );
352
- this ->m_euroscopeFlightplanUpdates .push_back ({std::chrono::utc_clock::now (), flightplan });
357
+ this ->m_euroscopeFlightplanUpdates .push_back ({std::chrono::utc_clock::now (), pilot });
353
358
}
354
359
355
360
void DataManager::consolidateWithBackend (std::map<std::string, std::array<types::Pilot, 3U >>& pilots) {
@@ -436,7 +441,7 @@ void DataManager::processEuroScopeUpdates(std::map<std::string, std::array<types
436
441
for (auto & update : flightplanUpdates) {
437
442
bool found = false ;
438
443
439
- auto pilot = DataManager::CFlightPlanToPilot ( update.data ) ;
444
+ const auto pilot = update.data ;
440
445
441
446
// find pilot in list
442
447
for (auto & pair : pilots) {
@@ -461,27 +466,20 @@ void DataManager::consolidateFlightplanUpdates(std::list<EuroscopeFlightplanUpda
461
466
std::list<DataManager::EuroscopeFlightplanUpdate> resultList;
462
467
463
468
for (const auto & currentUpdate : inputList) {
464
- auto & flightplan = currentUpdate.data ;
465
- if (false == flightplan.IsValid () || nullptr == flightplan.GetFlightPlanData ().GetPlanType ()) {
466
- continue ;
467
- }
468
- if (nullptr == flightplan.GetFlightPlanData ().GetOrigin ()) {
469
- continue ;
470
- }
469
+ auto pilot = currentUpdate.data ;
471
470
472
471
// only handle updates for active airports
473
472
{
474
473
std::lock_guard guard (this ->m_airportLock );
475
- bool flightDepartsFromActiveAirport =
476
- std::find (m_activeAirports.begin (), m_activeAirports.end (),
477
- std::string (flightplan.GetFlightPlanData ().GetOrigin ())) != m_activeAirports.end ();
474
+ bool flightDepartsFromActiveAirport = std::find (m_activeAirports.begin (), m_activeAirports.end (),
475
+ std::string (pilot.origin )) != m_activeAirports.end ();
478
476
if (false == flightDepartsFromActiveAirport) continue ;
479
477
}
480
478
481
479
// Check if the flight plan already exists in the result list
482
480
auto it = std::find_if (resultList.begin (), resultList.end (),
483
481
[¤tUpdate](const EuroscopeFlightplanUpdate& existingUpdate) {
484
- return existingUpdate.data .GetCallsign () == currentUpdate.data .GetCallsign () ;
482
+ return existingUpdate.data .callsign == currentUpdate.data .callsign ;
485
483
});
486
484
487
485
if (it != resultList.end ()) {
@@ -491,20 +489,18 @@ void DataManager::consolidateFlightplanUpdates(std::list<EuroscopeFlightplanUpda
491
489
// Update with the newer data
492
490
*it = currentUpdate;
493
491
Logger::instance ().log (Logger::LogSender::DataManager,
494
- " Updated: " + std::string (currentUpdate.data .GetCallsign ()),
495
- Logger::LogLevel::Info);
492
+ " Updated: " + std::string (currentUpdate.data .callsign ), Logger::LogLevel::Info);
496
493
} else {
497
494
// Existing data is already newer, no update needed
498
495
Logger::instance ().log (Logger::LogSender::DataManager,
499
- " Skipped old update for: " + std::string (currentUpdate.data .GetCallsign () ),
496
+ " Skipped old update for: " + std::string (currentUpdate.data .callsign ),
500
497
Logger::LogLevel::Info);
501
498
}
502
499
} else {
503
500
// Flight plan with the callsign doesn't exist, add it to the result list
504
501
resultList.push_back (currentUpdate);
505
502
Logger::instance ().log (Logger::LogSender::DataManager,
506
- " Update added: " + std::string (currentUpdate.data .GetCallsign ()),
507
- Logger::LogLevel::Info);
503
+ " Update added: " + std::string (currentUpdate.data .callsign ), Logger::LogLevel::Info);
508
504
}
509
505
}
510
506
0 commit comments