mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
refs #146 , added methods to update from data file reader (e.g.) updateFromVatsimDataFileAircraft
* updateFromVatsimDataFileStation * updateFromVatsimDataFileAircraft * Changed to 1 line comments //! where applicable
This commit is contained in:
@@ -4,8 +4,11 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "avaircraftlist.h"
|
||||
#include "nwuser.h"
|
||||
#include "predicates.h"
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -55,5 +58,30 @@ namespace BlackMisc
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Merge with aircraft
|
||||
*/
|
||||
int CAircraftList::updateFromVatsimDataFileAircraft(CAircraft &aircraftToBeUpdated) const
|
||||
{
|
||||
if (this->isEmpty()) return 0;
|
||||
if (aircraftToBeUpdated.hasValidRealName() && aircraftToBeUpdated.hasValidId()) return 0;
|
||||
|
||||
int c = 0;
|
||||
for (auto i = this->begin(); i != this->end(); ++i)
|
||||
{
|
||||
CAircraft currentDataFileAircraft = *i;
|
||||
if (currentDataFileAircraft.getCallsign() != aircraftToBeUpdated.getCallsign()) continue;
|
||||
|
||||
CUser user = aircraftToBeUpdated.getPilot();
|
||||
if (!aircraftToBeUpdated.hasValidRealName()) user.setRealName(currentDataFileAircraft.getPilotRealname());
|
||||
if (!aircraftToBeUpdated.hasValidId()) user.setId(currentDataFileAircraft.getPilotId());
|
||||
aircraftToBeUpdated.setPilot(user);
|
||||
c++;
|
||||
}
|
||||
|
||||
// normally 1 expected, as I should find
|
||||
// only one online station for this booking
|
||||
return c;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user