mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
[FSD] Check attributes of full JSON parts
This commit is contained in:
committed by
Mat Sutcliffe
parent
70c88f0982
commit
4d7468f913
@@ -170,6 +170,7 @@ namespace BlackCore
|
||||
m_ownAirlineIcaoCode = ownAircraft.getAirlineIcaoCode();
|
||||
|
||||
/* use setLiveryAndModelString
|
||||
No longer do it here, use setLiveryAndModelString
|
||||
m_ownLivery = ownAircraft.getModel().getSwiftLiveryString(m_simTypeInfo);
|
||||
m_ownModelString = ownAircraft.getModelString();
|
||||
m_sendLiveryString = true;
|
||||
@@ -1207,6 +1208,7 @@ namespace BlackCore
|
||||
if (packet == JsonPackets::aircraftConfigRequest())
|
||||
{
|
||||
// this MUST work for NOT IN RANGE aircraft as well
|
||||
// Here we send our OWN parts
|
||||
QJsonObject config = this->getOwnAircraftParts().toJson();
|
||||
config.insert(CAircraftParts::attributeNameIsFullJson(), true);
|
||||
QString data = QJsonDocument(QJsonObject { { "config", config } }).toJson(QJsonDocument::Compact);
|
||||
@@ -1253,7 +1255,7 @@ namespace BlackCore
|
||||
Capabilities capabilities = Capabilities::None;
|
||||
for (int i = 0; i < clientResponse.m_responseData.size(); ++i)
|
||||
{
|
||||
QString keyValuePair = clientResponse.m_responseData.at(i);
|
||||
const QString keyValuePair = clientResponse.m_responseData.at(i);
|
||||
if (keyValuePair.count('=') != 1) { continue; }
|
||||
|
||||
const QStringList split = keyValuePair.split('=');
|
||||
|
||||
@@ -191,6 +191,9 @@ namespace BlackMisc
|
||||
//! Attribute name
|
||||
static const QString &attributeNameIsFullJson();
|
||||
|
||||
//! Number of attributes for full JSON
|
||||
static constexpr int attributesCountFullJson = 7;
|
||||
|
||||
private:
|
||||
CAircraftLights m_lights;
|
||||
CAircraftEngineList m_engines;
|
||||
|
||||
@@ -422,6 +422,13 @@ namespace BlackMisc
|
||||
{
|
||||
if (isFull)
|
||||
{
|
||||
if (CBuildConfig::isLocalDeveloperDebugBuild())
|
||||
{
|
||||
// validation in dev.env.
|
||||
const int attributes = jsonObject.size();
|
||||
const bool correctCount = (attributes == CAircraftParts::attributesCountFullJson);
|
||||
BLACK_VERIFY_X(correctCount, Q_FUNC_INFO, "Wrong full aircraft parts");
|
||||
}
|
||||
parts.convertFromJson(jsonObject);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user