Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ cmake-build-*/
/dist/
CMakeUserPresets.json
/third_party/externals
/src/plugins/simulator/msfs2024/simulatormsfs2024.cpp_
/src/plugins/simulator/msfs2024/simulatormsfs2024.h_
2 changes: 0 additions & 2 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ add_library(core SHARED
fsd/pong.h
fsd/rehost.cpp
fsd/rehost.h
fsd/revbclientparts.cpp
fsd/revbclientparts.h
fsd/serializer.cpp
fsd/serializer.h
fsd/servererror.cpp
Expand Down
8 changes: 8 additions & 0 deletions src/core/aircraftmatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,14 @@ namespace swift::core
const QString &livery)
{
Q_UNUSED(livery)
// TODO TZ remove after testing
CLogMessage(this).info(u"CAircraftMatcher::onIcaoCodesReceived CHECK:"
u"callsign %1 "
u"aircraftIcao %2 "
u"airlineIcao %3 "
u"livery %4 ")
<< callsign << aircraftIcao << airlineIcao << livery;

Q_ASSERT_X(sApp && sApp->hasWebDataServices(), Q_FUNC_INFO, "Missing web data services");
if (m_modelSet.isEmpty()) { return; } // ignore empty sets to not create silly stats
if (sessionId.isEmpty()) { return; }
Expand Down
145 changes: 68 additions & 77 deletions src/core/airspacemonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ namespace swift::core
connect(m_fsdClient, &CFSDClient::serverResponseReceived, this, &CAirspaceMonitor::onServerReplyReceived);
connect(m_fsdClient, &CFSDClient::aircraftConfigReceived, this, &CAirspaceMonitor::onAircraftConfigReceived);
connect(m_fsdClient, &CFSDClient::connectionStatusChanged, this, &CAirspaceMonitor::onConnectionStatusChanged);
connect(m_fsdClient, &CFSDClient::revbAircraftConfigReceived, this,
&CAirspaceMonitor::onRevBAircraftConfigReceived);

Q_ASSERT_X(sApp && sApp->hasWebDataServices(), Q_FUNC_INFO, "Missing data reader");

Expand Down Expand Up @@ -546,9 +544,21 @@ namespace swift::core

void CAirspaceMonitor::sendReadyForModelMatching(const CCallsign &callsign, MatchingReadinessFlag rf)
{

if (!this->isConnectedAndNotShuttingDown()) { return; }
Q_ASSERT_X(!callsign.isEmpty(), Q_FUNC_INFO, "missing callsign");

// TODO TZ remove when testing is done
// CLogMessage(this).info(u"CAirspaceMonitor::sendReadyForModelMatching "
// u"callsign %1 Flag %2 ")
// << callsign << rf;

CStatusMessageList reverseLookupMessages;
CCallsign::addLogDetailsToList(&reverseLookupMessages, callsign,
QStringLiteral("CAirspaceMonitor::sendReadyForModelMatching Flag: %1").arg(rf),
CAirspaceMonitor::getLogCategories());
// TODO remove

// set flag and init ts
Readiness &readiness = this->addMatchingReadinessFlag(callsign, rf);

Expand Down Expand Up @@ -668,6 +678,14 @@ namespace swift::core

// normally we should never get here
CLogMessage(this).info(u"Verified '%1' again, has ICAO codes, ready for matching!") << callsign;

// TODO TZ remove when testing is done
CStatusMessageList reverseLookupMessages;
CCallsign::addLogDetailsToList(&reverseLookupMessages, callsign,
QStringLiteral("CAirspaceMonitor::verifyReceivedIcaoData"),
CAirspaceMonitor::getLogCategories());
// end TZ remove

this->sendReadyForModelMatching(callsign, Verified);
}

Expand Down Expand Up @@ -769,10 +787,23 @@ namespace swift::core
}
}

// for request
// #SBBER750:DAL483:FSIPIR:0:BER:A320:::::L2J:PMDG 737-800 AIRBERLIN (D-ABKM)
// and also for information
// #SBFSC751 : BER636 : FSIPI : 0 ::EC35:: :: : H2T : AIRBUS H135 NORSK LUFTAMBULANSE
void CAirspaceMonitor::onCustomFSInnPacketReceived(const CCallsign &callsign, const QString &airlineIcaoDesignator,
const QString &aircraftIcaoDesignator,
const QString &combinedAircraftType, const QString &modelString)
{
// TODO TZ remove when testing is done
CLogMessage(this).info(u"CAirspaceMonitor::onCustomFSInnPacketReceived CHECK:"
u"callsign %1 "
u"airlineIcaoDesignator %2 "
u"aircraftIcaoDesignator %3 "
u"combinedAircraftType %4 "
u"modelString %5 ")
<< callsign << airlineIcaoDesignator << aircraftIcaoDesignator << combinedAircraftType << modelString;

// it can happen this is called before any queries
// ES sends FsInn packets for callsigns such as ACCGER1, which are hard to distinguish
// 1) checking if they are already in the list checks again ATC position which is safe
Expand Down Expand Up @@ -818,7 +849,7 @@ namespace swift::core
usedModelString.clear();
CCallsign::addLogDetailsToList(
pReverseLookupMessages, callsign,
QStringLiteral("FsInn modelstring '%1' ignored because of setuo").arg(modelString));
QStringLiteral("FsInn modelstring '%1' ignored because of setup").arg(modelString));
}
else if (!CAircraftMatcher::isKnownModelString(modelString, callsign, pReverseLookupMessages))
{
Expand All @@ -834,18 +865,28 @@ namespace swift::core
// in order not to override swift livery string data, we ignore those
if (!usedModelString.isEmpty())
{
this->addOrUpdateAircraftInRange(callsign, aircraftIcaoDesignator, airlineIcaoDesignator, QString(),
usedModelString, CAircraftModel::TypeFSInnData,
pReverseLookupMessages);
const CSimulatedAircraft aircraft = this->addOrUpdateAircraftInRange(
callsign, aircraftIcaoDesignator, airlineIcaoDesignator, QString(), usedModelString,
CAircraftModel::TypeFSInnData, pReverseLookupMessages);
this->addReverseLookupMessages(callsign, reverseLookupMessages);
}
this->sendReadyForModelMatching(callsign, ReceivedFsInnPacket); // from FSInn
}
}

// #SBDAL483:BER636:PI:GEN:EQUIPMENT=B738:AIRLINE=DAL:LIVERY=swift_l1855a1787m13853
void CAirspaceMonitor::onIcaoCodesReceived(const CCallsign &callsign, const QString &aircraftIcaoDesignator,
const QString &airlineIcaoDesignator, const QString &livery)
{
// TODO TZ remove logmessage when testing is done
CLogMessage(this).info(u"CAirspaceMonitor::onIcaoCodesReceived CHECK:"
u"callsign %1 "
u"aircraftIcaoDesignator %2 "
u"airlineIcaoDesignator %3 "
u"livery %4 ")
<< callsign << aircraftIcaoDesignator << airlineIcaoDesignator << livery;
// End TODO TZ

Q_ASSERT_X(CThreadUtils::isInThisThread(this), Q_FUNC_INFO, "not in main thread");
if (!this->isConnectedAndNotShuttingDown()) { return; }
if (CBuildConfig::isLocalDeveloperDebugBuild())
Expand All @@ -865,13 +906,18 @@ namespace swift::core
CAirspaceMonitor::getLogCategories());

const CClient client = this->getClientOrDefaultForCallsign(callsign);
this->addOrUpdateAircraftInRange(callsign, aircraftIcaoDesignator, airlineIcaoDesignator, livery,
client.getQueriedModelString(), CAircraftModel::TypeQueriedFromNetwork,
pReverseLookupMessages);
this->addReverseLookupMessages(callsign, reverseLookupMessages);
this->sendReadyForModelMatching(callsign, ReceivedIcaoCodes); // ICAO codes received
const CSimulatedAircraft aircraft = this->addOrUpdateAircraftInRange(
callsign, aircraftIcaoDesignator, airlineIcaoDesignator, livery, client.getQueriedModelString(),
CAircraftModel::TypeQueriedFromNetwork, pReverseLookupMessages);

// we do not change manually assigned models
if (aircraft.getModel().getModelType() != CAircraftModel::TypeManuallySet)
{
this->addReverseLookupMessages(callsign, reverseLookupMessages);
this->sendReadyForModelMatching(callsign, ReceivedIcaoCodes); // ICAO codes received

emit this->requestedNewAircraft(callsign, aircraftIcaoDesignator, airlineIcaoDesignator, livery);
emit this->requestedNewAircraft(callsign, aircraftIcaoDesignator, airlineIcaoDesignator, livery);
}
}

CAircraftModel CAirspaceMonitor::reverseLookupModelWithFlightplanData(
Expand Down Expand Up @@ -1178,9 +1224,17 @@ namespace swift::core
const CSimulatedAircraft aircraft = this->getAircraftInRangeForCallsign(callsign);
if (aircraft.hasValidCallsign())
{
// only if we do not have a DB model yet
if (!aircraft.getModel().hasValidDbKey())
// we do not change manually assigned models (msfs2024)
if (!aircraft.getModel().hasValidDbKey() && aircraft.getModelType() != CAircraftModel::TypeManuallySet)
{

CLogMessage(this).warning(u"CAirspaceMonitor::reverseLookupModelWithFlightplanData "
u"aircraft.getModelType %1 "
u"callsign %2 "
u"aircraftIcao %3 "
u"incomming modelType %4 ")
<< aircraft.getModelType() << callsign.toQString() << aircraftIcao << modelType;

CAircraftModel model = this->reverseLookupModelWithFlightplanData(callsign, aircraftIcao, airlineIcao,
livery, modelString, modelType, log);
model.updateMissingParts(aircraft.getModel());
Expand Down Expand Up @@ -1439,69 +1493,6 @@ namespace swift::core
this->updateAircraftInRange(callsign, vm);
}

void CAirspaceMonitor::onRevBAircraftConfigReceived(const CCallsign &callsign, const QString &config,
qint64 currentOffsetMs)
{

Q_ASSERT(CThreadUtils::isInThisThread(this));
SWIFT_AUDIT_X(!callsign.isEmpty(), Q_FUNC_INFO, "Need callsign");
if (callsign.isEmpty()) { return; }

unsigned long pp = 0;
bool ok {};
pp = config.toULong(&ok, 10);

bool gear = (pp & 1U);
bool landLight = (pp & 2U);
bool navLight = (pp & 4U);
bool strobeLight = (pp & 8U);
bool beaconLight = (pp & 16U);
bool taxiLight = (pp & 32U);
bool engine1Running = (pp & 64U);
bool engine2Running = (pp & 128U);
bool engine3Running = (pp & 256U);
bool engine4Running = (pp & 512U);

// CLogMessage(this).info(u"taxiLight %1 landLight %2 beaconLight %3 strobeLight %4 gear %5") << taxiLight <<
// landLight << beaconLight << strobeLight << gear; CLogMessage(this).info(u"engine1Running %1 engine2Running %2
// engine3Running %3 engine4Running %4") << engine1Running << engine2Running << engine3Running <<
// engine4Running;

CAircraftParts aircraftparts;
aircraftparts.setGearDown(gear);

CAircraftLights lights;
lights.setStrobeOn(strobeLight);
lights.setLandingOn(landLight);
lights.setTaxiOn(taxiLight);
lights.setBeaconOn(beaconLight);
lights.setNavOn(navLight);
aircraftparts.setLights(lights);

CAircraftEngineList engines;
engines.initEngines(4, false);
engines.setEngineOn(1, engine1Running);
engines.setEngineOn(2, engine2Running);
engines.setEngineOn(3, engine3Running);
engines.setEngineOn(4, engine4Running);
aircraftparts.setEngines(engines);

// make sure in any case right time and correct details
aircraftparts.setCurrentUtcTime();
aircraftparts.setTimeOffsetMs(currentOffsetMs);
aircraftparts.setPartsDetails(CAircraftParts::FSDAircraftParts);

// store parts
this->storeAircraftParts(callsign, aircraftparts, true);

// update client capability
CClient client = this->getClientOrDefaultForCallsign(callsign);
client.setUserCallsign(callsign); // make valid by setting a callsign
if (client.hasCapability(CClient::FsdWithAircraftConfig)) { return; }
client.addCapability(CClient::FsdWithAircraftConfig);
this->setOtherClient(client);
}

void CAirspaceMonitor::onAircraftConfigReceived(const CCallsign &callsign, const QJsonObject &jsonObject,
qint64 currentOffsetMs)
{
Expand Down
2 changes: 0 additions & 2 deletions src/core/airspacemonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,6 @@ namespace swift::core
const QString &aircraftIcao, const QString &airlineIcao);
void onConnectionStatusChanged(swift::misc::network::CConnectionStatus oldStatus,
swift::misc::network::CConnectionStatus newStatus);
void onRevBAircraftConfigReceived(const swift::misc::aviation::CCallsign &callsign, const QString &config,
qint64 currentOffsetMs);
};
} // namespace swift::core

Expand Down
1 change: 1 addition & 0 deletions src/core/context/contextnetworkimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,7 @@ namespace swift::core::context
if (c)
{
const CSimulatedAircraft aircraft(this->getAircraftInRangeForCallsign(callsign));

Q_ASSERT_X(!aircraft.getCallsign().isEmpty(), Q_FUNC_INFO, "missing callsign");
emit this->changedRemoteAircraftModel(aircraft, originator); // update aircraft model
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/db/databaseutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ namespace swift::core::db
dbModelModified.updateMissingParts(model);
dbModelModified.setDistributorOrder(distributorOrder);
dbModelModified.setSimulator(dbModel.getSimulator()); // DB simulator settings have priority
dbModelModified.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024
return dbModelModified;
}

Expand All @@ -88,6 +89,7 @@ namespace swift::core::db
{
if (modified) { *modified = true; }
consolidatedModel.setLivery(dbLivery);
consolidatedModel.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024
}
}
if (!consolidatedModel.getAircraftIcaoCode().hasValidDbKey() && consolidatedModel.hasAircraftDesignator())
Expand All @@ -99,6 +101,7 @@ namespace swift::core::db
{
if (modified) { *modified = true; }
consolidatedModel.setAircraftIcaoCode(dbIcao);
consolidatedModel.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024
}
}

Expand All @@ -108,6 +111,7 @@ namespace swift::core::db
{
if (modified) { *modified = true; }
consolidatedModel.setDistributor(dbDistributor);
consolidatedModel.setModelLivery(model.getModelLivery()); // keep local livery settings msfs2024
}
consolidatedModel.updateLocalFileNames(model);
consolidatedModel.setDistributorOrder(distributorOrder);
Expand Down
33 changes: 1 addition & 32 deletions src/core/fsd/fsdclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "core/fsd/planeinformationfsinn.h"
#include "core/fsd/pong.h"
#include "core/fsd/rehost.h"
#include "core/fsd/revbclientparts.h"
#include "core/fsd/serializer.h"
#include "core/fsd/servererror.h"
#include "core/fsd/textmessage.h"
Expand Down Expand Up @@ -1078,16 +1077,6 @@ namespace swift::core::fsd

// Euroscope
m_messageTypeMapping["SIMDATA"] = MessageType::EuroscopeSimData;

// IVAO only
// Ref: https://github.com/DemonRem/X-IvAP/blob/1b0a14880532a0f5c8fe84be44e462c6892a5596/src/XIvAp/FSDprotocol.h
m_messageTypeMapping["!R"] = MessageType::RegistrationInfo;
m_messageTypeMapping["-MD"] = MessageType::RevBClientParts;
m_messageTypeMapping["-PD"] = MessageType::RevBPilotDescription; // not handled, to avoid error messages

// IVAO parts
// https://discordapp.com/channels/539048679160676382/695961646992195644/707915838845485187
// https://github.com/swift-project/pilotclient/wiki/Knowledgebase-Simulation:-IVAO-parts
}

void CFSDClient::handleAtcDataUpdate(const QStringList &tokens)
Expand Down Expand Up @@ -1620,23 +1609,6 @@ namespace swift::core::fsd
if (serverError.isFatalError()) { disconnectFromServer(); }
}

void CFSDClient::handleRevBClientPartsPacket(const QStringList &tokens)
{
CLogMessage(this).debug(u"handleRevBClientPartsPacket");

const RevBClientParts RevBClientParts = RevBClientParts::fromTokens(tokens);
const CCallsign callsign(RevBClientParts.sender(), CCallsign::Aircraft);

const bool inRange = isAircraftInRange(callsign);

if (!inRange) { return; } // sort out all broadcasts we DO NOT NEED
if (!getSetupForServer().receiveAircraftParts()) { return; }

const qint64 offsetTimeMs = currentOffsetTime(callsign);
emit revbAircraftConfigReceived(RevBClientParts.sender(), RevBClientParts.m_partsval1, offsetTimeMs);
CLogMessage(this).debug(u"Set Config at %1 ") << offsetTimeMs;
}

void CFSDClient::handleRehost(const QStringList &tokens)
{
const Rehost rehost = Rehost::fromTokens(tokens);
Expand Down Expand Up @@ -2283,9 +2255,7 @@ namespace swift::core::fsd
case MessageType::AddPilot:
case MessageType::ServerHeartbeat:
case MessageType::ProController:
case MessageType::ClientIdentification:
case MessageType::RegistrationInfo:
case MessageType::RevBPilotDescription: break;
case MessageType::ClientIdentification: break;

// handled ones
case MessageType::AtcDataUpdate: handleAtcDataUpdate(tokens); break;
Expand All @@ -2308,7 +2278,6 @@ namespace swift::core::fsd
case MessageType::ServerError: handleServerError(tokens); break;
case MessageType::TextMessage: handleTextMessage(tokens); break;
case MessageType::PilotClientCom: handleCustomPilotPacket(tokens); break;
case MessageType::RevBClientParts: handleRevBClientPartsPacket(tokens); break;
case MessageType::VisualPilotDataUpdate:
case MessageType::VisualPilotDataPeriodic:
case MessageType::VisualPilotDataStopped: handleVisualPilotDataUpdate(tokens, messageType); break;
Expand Down
3 changes: 1 addition & 2 deletions src/core/fsd/fsdclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ namespace swift::core::fsd
void planeInformationFsinnReceived(const swift::misc::aviation::CCallsign &callsign,
const QString &airlineIcaoDesignator, const QString &aircraftDesignator,
const QString &combinedAircraftType, const QString &modelString);
void revbAircraftConfigReceived(const QString &sender, const QString &config, qint64 currentOffsetTimeMs);

void muteRequestReceived(bool mute);

//! @}
Expand Down Expand Up @@ -474,7 +474,6 @@ namespace swift::core::fsd
#ifdef SWIFT_VATSIM_SUPPORT
void handleFsdIdentification(const QStringList &tokens);
#endif
void handleRevBClientPartsPacket(const QStringList &tokens);
void handleRehost(const QStringList &tokens);
void handleMute(const QStringList &tokens);

Expand Down
Loading