mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 05:55:33 +08:00
[FG] Do not send modelstring or a shorter livery string for FG
* FG does not support modelstrings for "flyable" planes * remove unused setSimInfo functions, consolidated, cleanup * simulator dependent "getSwiftLiveryString" * encapsulated in getConfiguredLiveryString, getConfiguredModelString * see https://discordapp.com/channels/539048679160676382/567091362030419981/698124094482415616
This commit is contained in:
committed by
Mat Sutcliffe
parent
90e77ac9f1
commit
92d53a4077
@@ -151,14 +151,6 @@ namespace BlackCore
|
||||
m_fsdTextCodec = textCodec;
|
||||
}
|
||||
|
||||
void CFSDClient::setSimulatorInfo(const CSimulatorPluginInfo &simInfo)
|
||||
{
|
||||
Q_ASSERT_X(this->getConnectionStatus().isDisconnected(), Q_FUNC_INFO, "Can't change server details while still connected");
|
||||
|
||||
QWriteLocker l(&m_lockUserClientBuffered);
|
||||
m_simulatorInfo = simInfo;
|
||||
}
|
||||
|
||||
void CFSDClient::setCallsign(const CCallsign &callsign)
|
||||
{
|
||||
Q_ASSERT_X(this->getConnectionStatus().isDisconnected(), Q_FUNC_INFO, "Can't change callsign while still connected");
|
||||
@@ -176,10 +168,13 @@ namespace BlackCore
|
||||
QWriteLocker l(&m_lockUserClientBuffered);
|
||||
m_ownAircraftIcaoCode = ownAircraft.getAircraftIcaoCode();
|
||||
m_ownAirlineIcaoCode = ownAircraft.getAirlineIcaoCode();
|
||||
m_ownLivery = ownAircraft.getModel().getSwiftLiveryString();
|
||||
|
||||
/* use setLiveryAndModelString
|
||||
m_ownLivery = ownAircraft.getModel().getSwiftLiveryString(m_simTypeInfo);
|
||||
m_ownModelString = ownAircraft.getModelString();
|
||||
m_sendLiveryString = true;
|
||||
m_sendMModelString = true;
|
||||
m_sendModelString = true;
|
||||
*/
|
||||
}
|
||||
|
||||
void CFSDClient::setLiveryAndModelString(const QString &livery, bool sendLiveryString, const QString &modelString, bool sendModelString)
|
||||
@@ -188,16 +183,18 @@ namespace BlackCore
|
||||
m_ownLivery = livery;
|
||||
m_ownModelString = modelString;
|
||||
m_sendLiveryString = sendLiveryString;
|
||||
m_sendMModelString = sendModelString;
|
||||
m_sendModelString = sendModelString;
|
||||
}
|
||||
|
||||
void CFSDClient::setSimType(const CSimulatorPluginInfo &simInfo)
|
||||
void CFSDClient::setSimType(const CSimulatorInfo &simInfo)
|
||||
{
|
||||
//! \fixme Define recognized simulators somewhere */
|
||||
const CSimulatorInfo::Simulator sim = simInfo.getSimulatorInfo().getSimulator();
|
||||
this->setSimType(simInfo.getSimulator());
|
||||
}
|
||||
|
||||
void CFSDClient::setSimType(const CSimulatorInfo::Simulator simulator)
|
||||
{
|
||||
QWriteLocker l(&m_lockUserClientBuffered);
|
||||
switch (sim)
|
||||
switch (simulator)
|
||||
{
|
||||
case CSimulatorInfo::FSX: m_simType = SimType::MSFSX; break;
|
||||
case CSimulatorInfo::P3D: m_simType = SimType::P3Dv4; break;
|
||||
@@ -206,6 +203,7 @@ namespace BlackCore
|
||||
case CSimulatorInfo::XPLANE: m_simType = SimType::XPLANE11; break;
|
||||
default: m_simType = SimType::Unknown; break;
|
||||
}
|
||||
m_simTypeInfo = CSimulatorInfo(simulator);
|
||||
}
|
||||
|
||||
QStringList CFSDClient::getPresetValues() const
|
||||
@@ -284,11 +282,13 @@ namespace BlackCore
|
||||
{
|
||||
const AddPilot pilotLogin(callsign, cid, password, m_pilotRating, m_protocolRevision, m_simType, name);
|
||||
sendQueudedMessage(pilotLogin);
|
||||
CStatusMessage(this).info(u"Sending login as '%1' '%2' '%3' '%4' '%5' '%6'") << callsign << cid << toQString(m_pilotRating) << m_protocolRevision << toQString(m_simType) << name;
|
||||
}
|
||||
else if (m_loginMode.isObserver())
|
||||
{
|
||||
const AddAtc addAtc(callsign, name, cid, password, m_atcRating, m_protocolRevision);
|
||||
sendQueudedMessage(addAtc);
|
||||
CStatusMessage(this).info(u"Sending OBS login as '%1' '%2' '%3' '%4' '%5'") << callsign << cid << toQString(m_atcRating) << m_protocolRevision << name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -627,18 +627,12 @@ namespace BlackCore
|
||||
if (!connected) { return; }
|
||||
|
||||
const CSimulatedAircraft myAircraft(getOwnAircraft());
|
||||
QString modelString;
|
||||
{
|
||||
QReadLocker l(&m_lockUserClientBuffered);
|
||||
modelString = m_ownModelString.isEmpty() ? myAircraft.getModelString() : m_ownModelString;
|
||||
}
|
||||
if (modelString.isEmpty()) { modelString = noModelString(); }
|
||||
|
||||
const QString modelString = this->getConfiguredModelString(myAircraft);
|
||||
const PlaneInfoRequestFsinn planeInfoRequestFsinn(getOwnCallsignAsString(), callsign.toQString(),
|
||||
myAircraft.getAirlineIcaoCodeDesignator(),
|
||||
myAircraft.getAircraftIcaoCodeDesignator(),
|
||||
myAircraft.getAircraftIcaoCombinedType(),
|
||||
m_sendMModelString ? modelString : QString());
|
||||
modelString);
|
||||
sendQueudedMessage(planeInfoRequestFsinn);
|
||||
increaseStatisticsValue(QStringLiteral("sendPlaneInfoRequestFsinn"));
|
||||
}
|
||||
@@ -654,13 +648,12 @@ namespace BlackCore
|
||||
{
|
||||
if (this->getConnectionStatus().isDisconnected() && ! m_unitTestMode) { return; }
|
||||
const CSimulatedAircraft myAircraft(getOwnAircraft());
|
||||
QString modelString = m_ownModelString.isEmpty() ? myAircraft.getModelString() : m_ownModelString;
|
||||
if (modelString.isEmpty()) { modelString = noModelString(); }
|
||||
const QString modelString = this->getConfiguredModelString(myAircraft);
|
||||
const PlaneInformationFsinn planeInformationFsinn(getOwnCallsignAsString(), callsign.toQString(),
|
||||
myAircraft.getAirlineIcaoCodeDesignator(),
|
||||
myAircraft.getAircraftIcaoCodeDesignator(),
|
||||
myAircraft.getAircraftIcaoCombinedType(),
|
||||
m_sendMModelString ? modelString : QString());
|
||||
modelString);
|
||||
sendQueudedMessage(planeInformationFsinn);
|
||||
increaseStatisticsValue(QStringLiteral("sendPlaneInformationFsinn"));
|
||||
}
|
||||
@@ -718,6 +711,22 @@ namespace BlackCore
|
||||
parseMessage(message);
|
||||
}
|
||||
|
||||
QString CFSDClient::getConfiguredModelString(const CSimulatedAircraft &myAircraft) const
|
||||
{
|
||||
if (!m_sendModelString) { return noModelString(); }
|
||||
QReadLocker l(&m_lockUserClientBuffered);
|
||||
const QString ms = m_ownModelString.isEmpty() ? myAircraft.getModelString() : m_ownModelString;
|
||||
return ms.isEmpty() ? noModelString() : ms;
|
||||
}
|
||||
|
||||
QString CFSDClient::getConfiguredLiveryString(const CSimulatedAircraft &myAircraft) const
|
||||
{
|
||||
if (!m_sendLiveryString) { return QString(); }
|
||||
QReadLocker l(&m_lockUserClientBuffered);
|
||||
const QString livery = m_ownLivery.isEmpty() ? myAircraft.getModel().getSwiftLiveryString() : m_ownLivery;
|
||||
return livery;
|
||||
}
|
||||
|
||||
void CFSDClient::sendAuthChallenge(const QString &challenge)
|
||||
{
|
||||
const AuthChallenge pduAuthChallenge(getOwnCallsignAsString(), "SERVER", challenge);
|
||||
@@ -1348,10 +1357,11 @@ namespace BlackCore
|
||||
{
|
||||
PlaneInfoRequest planeInfoRequest = PlaneInfoRequest::fromTokens(tokens);
|
||||
|
||||
const QString airlineIcao = m_server.getFsdSetup().force3LetterAirlineCodes() ? getOwnAircraft().getAirlineIcaoCode().getDesignator()
|
||||
: getOwnAircraft().getAirlineIcaoCode().getVDesignator();
|
||||
const QString acTypeICAO = getOwnAircraft().getAircraftIcaoCode().getDesignator();
|
||||
const QString livery = getOwnAircraft().getModel().getSwiftLiveryString();
|
||||
const CSimulatedAircraft myAircraft = this->getOwnAircraft();
|
||||
const QString airlineIcao = m_server.getFsdSetup().force3LetterAirlineCodes() ? myAircraft.getAirlineIcaoCode().getDesignator()
|
||||
: myAircraft.getAirlineIcaoCode().getVDesignator();
|
||||
const QString acTypeICAO = myAircraft.getAircraftIcaoCode().getDesignator();
|
||||
const QString livery = this->getConfiguredLiveryString(myAircraft);
|
||||
|
||||
sendPlaneInformation(planeInfoRequest.sender(), acTypeICAO, airlineIcao, livery);
|
||||
}
|
||||
|
||||
@@ -101,14 +101,14 @@ namespace BlackCore
|
||||
void setClientIdAndKey(quint16 id, const QByteArray &key);
|
||||
void setClientCapabilities(Capabilities capabilities) { QWriteLocker l(&m_lockUserClientBuffered); m_capabilities = capabilities; }
|
||||
void setServer(const BlackMisc::Network::CServer &server);
|
||||
void setSimulatorInfo(const BlackMisc::Simulation::CSimulatorPluginInfo &simInfo);
|
||||
void setLoginMode(const BlackMisc::Network::CLoginMode &mode) { QWriteLocker l(&m_lockUserClientBuffered); m_loginMode = mode; }
|
||||
void setCallsign(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
void setPartnerCallsign(const BlackMisc::Aviation::CCallsign &callsign) { QWriteLocker l(&m_lockUserClientBuffered); m_partnerCallsign = callsign; }
|
||||
void setIcaoCodes(const BlackMisc::Simulation::CSimulatedAircraft &ownAircraft);
|
||||
void setLiveryAndModelString(const QString &livery, bool sendLiveryString, const QString &modelString, bool sendModelString);
|
||||
void setSimType(SimType type) { QWriteLocker l(&m_lockUserClientBuffered); m_simType = type; }
|
||||
void setSimType(const BlackMisc::Simulation::CSimulatorPluginInfo &simInfo);
|
||||
void setSimType(const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
||||
void setSimType(const BlackMisc::Simulation::CSimulatorInfo::Simulator simulator);
|
||||
void setPilotRating(PilotRating rating) { QWriteLocker l(&m_lockUserClientBuffered); m_pilotRating = rating; }
|
||||
void setAtcRating(AtcRating rating) { QWriteLocker l(&m_lockUserClientBuffered); m_atcRating = rating; }
|
||||
//! @}
|
||||
@@ -301,6 +301,12 @@ namespace BlackCore
|
||||
return noms;
|
||||
}
|
||||
|
||||
//! Model string as configured, also dependent from simulator
|
||||
QString getConfiguredModelString(const BlackMisc::Simulation::CSimulatedAircraft &myAircraft) const;
|
||||
|
||||
//! Livery string, also dependent from simulator
|
||||
QString getConfiguredLiveryString(const BlackMisc::Simulation::CSimulatedAircraft &myAircraft) const;
|
||||
|
||||
//! JSON packets
|
||||
struct JsonPackets
|
||||
{
|
||||
@@ -474,12 +480,12 @@ namespace BlackCore
|
||||
std::atomic_bool m_filterPasswordFromLogin { false };
|
||||
|
||||
// timer parents are needed as we move to thread
|
||||
QTimer m_scheduledConfigUpdate { this }; //!< config updates
|
||||
QTimer m_positionUpdateTimer { this }; //!< sending positions
|
||||
QTimer m_scheduledConfigUpdate { this }; //!< config updates
|
||||
QTimer m_positionUpdateTimer { this }; //!< sending positions
|
||||
QTimer m_interimPositionUpdateTimer { this }; //!< sending interim positions
|
||||
QTimer m_fsdSendMessageTimer { this }; //!< FSD message sending
|
||||
|
||||
qint64 m_additionalOffsetTime = 0; //!< additional offset time
|
||||
qint64 m_additionalOffsetTime = 0; //!< additional offset time
|
||||
|
||||
std::atomic_bool m_statistics { false };
|
||||
QMap <QString, int> m_callStatistics; //!< how many calls?
|
||||
@@ -493,6 +499,7 @@ namespace BlackCore
|
||||
SimType m_simType = SimType::Unknown;
|
||||
PilotRating m_pilotRating = PilotRating::Unknown;
|
||||
AtcRating m_atcRating = AtcRating::Unknown;
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simTypeInfo; // same as m_simType
|
||||
|
||||
// Client data
|
||||
QString m_clientName;
|
||||
@@ -504,7 +511,6 @@ namespace BlackCore
|
||||
Capabilities m_capabilities = Capabilities::None;
|
||||
|
||||
// buffered data for FSD
|
||||
BlackMisc::Simulation::CSimulatorPluginInfo m_simulatorInfo; //!< used simulator
|
||||
BlackMisc::Aviation::CCallsign m_ownCallsign; //!< "buffered callsign", as this must not change when connected
|
||||
BlackMisc::Aviation::CCallsign m_partnerCallsign; //!< "buffered"callsign", of partner flying in shared cockpit
|
||||
BlackMisc::Aviation::CAircraftIcaoCode m_ownAircraftIcaoCode; //!< "buffered icao", as this must not change when connected
|
||||
@@ -512,7 +518,7 @@ namespace BlackCore
|
||||
QString m_ownLivery; //!< "buffered livery", as this must not change when connected
|
||||
QString m_ownModelString; //!< "buffered model string", as this must not change when connected
|
||||
std::atomic_bool m_sendLiveryString { true };
|
||||
std::atomic_bool m_sendMModelString { true };
|
||||
std::atomic_bool m_sendModelString { true };
|
||||
|
||||
mutable QReadWriteLock m_lockUserClientBuffered { QReadWriteLock::Recursive }; //!< for user, client and buffered data
|
||||
QString getOwnCallsignAsString() const { QReadLocker l(&m_lockUserClientBuffered); return m_ownCallsign.asString(); }
|
||||
|
||||
Reference in New Issue
Block a user