mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 22:15:34 +08:00
refs #409 Refactor matching implementation in MSFS drivers
CAircraftMapper used to be designed around FSX only. CAircraftMatcher instead is more generic for different MSFS versions. Therefore it is replaced with the latter. This change also gets rid of the singleton and its drawbacks by using the plugin storage. Last but not least it implements the first model matching for FS9.
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "blackmisc/project.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/propertyindexallclasses.h"
|
||||
#include "blackmisc/simulation/fscommon/fscommonutil.h"
|
||||
#include <QTimer>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -30,6 +31,7 @@ using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Simulation::FsCommon;
|
||||
using namespace BlackSimPlugin::Fs9;
|
||||
using namespace BlackSimPlugin::FsCommon;
|
||||
|
||||
@@ -52,10 +54,17 @@ namespace BlackSimPlugin
|
||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
IPluginStorageProvider *pluginStorageProvider,
|
||||
QObject *parent) :
|
||||
CSimulatorFsCommon(info, ownAircraftProvider, remoteAircraftProvider, pluginStorageProvider, parent)
|
||||
CSimulatorFsCommon(info, ownAircraftProvider, remoteAircraftProvider, pluginStorageProvider,
|
||||
aircraftObjectsDir(), excludeDirectories(), parent)
|
||||
{
|
||||
connect(lobbyClient.data(), &CLobbyClient::disconnected, this, std::bind(&CSimulatorFs9::simulatorStatusChanged, this, 0));
|
||||
this->m_interpolator = new BlackCore::CInterpolatorLinear(remoteAircraftProvider, this);
|
||||
m_modelMatcher.setDefaultModel(CAircraftModel(
|
||||
"Boeing 737-400",
|
||||
CAircraftModel::TypeModelMatchingDefaultModel,
|
||||
"B737-400 default model",
|
||||
CAircraftIcaoData(CAircraftIcaoCode("B734", "L2J"), CAirlineIcaoCode(), "FFFFFF")
|
||||
));
|
||||
}
|
||||
|
||||
bool CSimulatorFs9::isConnected() const
|
||||
@@ -111,7 +120,17 @@ namespace BlackSimPlugin
|
||||
this->physicallyRemoveRemoteAircraft(callsign);
|
||||
}
|
||||
|
||||
CFs9Client *client = new CFs9Client(m_interpolator, this, callsign, CTime(25, CTimeUnit::ms()));
|
||||
CSimulatedAircraft newRemoteAircraftCopy(newRemoteAircraft);
|
||||
// matched models
|
||||
CAircraftModel aircraftModel = getClosestMatch(newRemoteAircraftCopy);
|
||||
Q_ASSERT(newRemoteAircraft.getCallsign() == aircraftModel.getCallsign());
|
||||
updateAircraftModel(newRemoteAircraft.getCallsign(), aircraftModel, simulatorOriginator());
|
||||
updateAircraftRendered(newRemoteAircraft.getCallsign(), true, simulatorOriginator());
|
||||
CSimulatedAircraft aircraftAfterModelApplied (getAircraftInRangeForCallsign(newRemoteAircraft.getCallsign()));
|
||||
aircraftAfterModelApplied.setRendered(true);
|
||||
emit modelMatchingCompleted(aircraftAfterModelApplied);
|
||||
|
||||
CFs9Client *client = new CFs9Client(callsign, aircraftModel.getModelString(), m_interpolator, CTime(25, CTimeUnit::ms()), this);
|
||||
client->setHostAddress(fs9Host->getHostAddress());
|
||||
client->setPlayerUserId(fs9Host->getPlayerUserId());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user