mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T683, style
This commit is contained in:
committed by
Mat Sutcliffe
parent
70a350ed66
commit
daeea07090
@@ -284,7 +284,7 @@ namespace BlackCore
|
||||
bool CContextOwnAircraft::updateOwnParts(const CAircraftParts &parts)
|
||||
{
|
||||
QWriteLocker l(&m_lockAircraft);
|
||||
bool changed = (m_ownAircraft.getParts() != parts);
|
||||
const bool changed = (m_ownAircraft.getParts() != parts);
|
||||
if (!changed) { return false; }
|
||||
m_ownAircraft.setParts(parts);
|
||||
return true;
|
||||
|
||||
@@ -845,10 +845,10 @@ namespace BlackCore
|
||||
this->rememberGroundElevation(callsign, elevation);
|
||||
}
|
||||
|
||||
const CLength cgO = this->overriddenCGorDefault(simulatorCG, modelString);
|
||||
if (!cgO.isNull() && !this->hasSameSimulatorCG(cgO, callsign))
|
||||
const CLength cgOvr = this->overriddenCGorDefault(simulatorCG, modelString);
|
||||
if (!cgOvr.isNull() && !this->hasSameSimulatorCG(cgOvr, callsign))
|
||||
{
|
||||
this->insertCG(cgO, modelString, callsign); // per model string and CG
|
||||
this->insertCG(cgOvr, modelString, callsign); // per model string and CG
|
||||
|
||||
// here we know we have a valid model and CG
|
||||
m_autoPublishing.insert(modelString, simulatorCG); // still using CG here, not the overridden value
|
||||
@@ -1210,7 +1210,7 @@ namespace BlackCore
|
||||
|
||||
void ISimulator::reverseLookupAndUpdateOwnAircraftModel(const QString &modelString)
|
||||
{
|
||||
CAircraftModel model = getOwnAircraftModel();
|
||||
CAircraftModel model = this->getOwnAircraftModel();
|
||||
model.setModelString(modelString);
|
||||
this->reverseLookupAndUpdateOwnAircraftModel(model);
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ namespace BlackMisc
|
||||
switch (i)
|
||||
{
|
||||
case IndexValue: return CVariant::from(m_value);
|
||||
case IndexUnit: return CVariant::from(m_unit);
|
||||
case IndexUnit: return CVariant::from(m_unit);
|
||||
case IndexValueRounded0DigitsWithUnit: return CVariant::from(this->valueRoundedWithUnit(0));
|
||||
case IndexValueRounded1DigitsWithUnit: return CVariant::from(this->valueRoundedWithUnit(1));
|
||||
case IndexValueRounded2DigitsWithUnit: return CVariant::from(this->valueRoundedWithUnit(2));
|
||||
|
||||
@@ -534,6 +534,7 @@ namespace BlackMisc
|
||||
bool CSimulatedAircraft::setCG(const CLength &cg)
|
||||
{
|
||||
if (cg.isNull()) { return false; }
|
||||
// ???? set to both models, or only the matched model ????
|
||||
const int c = m_models.setCG(cg);
|
||||
return c > 0;
|
||||
}
|
||||
|
||||
@@ -347,8 +347,8 @@ namespace BlackMisc
|
||||
{
|
||||
QWriteLocker l(&m_lockElvCoordinates);
|
||||
m_statsCurrentElevRequestTimeMs = -1;
|
||||
m_statsMaxElevRequestTimeMs = -1;
|
||||
m_elvFound = m_elvMissed = 0;
|
||||
m_statsMaxElevRequestTimeMs = -1;
|
||||
m_elvFound = m_elvMissed = 0;
|
||||
}
|
||||
|
||||
ISimulationEnvironmentProvider::ISimulationEnvironmentProvider(const CSimulatorPluginInfo &pluginInfo) :
|
||||
@@ -447,7 +447,7 @@ namespace BlackMisc
|
||||
m_pendingElevationRequests.clear();
|
||||
m_statsCurrentElevRequestTimeMs = -1;
|
||||
m_statsMaxElevRequestTimeMs = -1;
|
||||
m_elvFound = m_elvMissed = 0;
|
||||
m_elvFound = m_elvMissed = 0;
|
||||
}
|
||||
|
||||
void ISimulationEnvironmentProvider::clearCGs()
|
||||
|
||||
@@ -195,7 +195,7 @@ namespace BlackSimPlugin
|
||||
// Updates
|
||||
// Do not update ICAO codes, as this overrides reverse lookups
|
||||
// updateOwnIcaoCodes(m_flightgearData.aircraftIcaoCode, CAirlineIcaoCode());
|
||||
updateOwnSituation(situation);
|
||||
this->updateOwnSituation(situation);
|
||||
|
||||
// defaults
|
||||
CSimulatedAircraft myAircraft(getOwnAircraft());
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace BlackSimPlugin
|
||||
positionSlewMode.lat_f = static_cast<quint16>(qAbs((latitude - positionSlewMode.lat_i) * 65536));
|
||||
|
||||
// Longitude - integer and decimal places
|
||||
const double longitude = situation.getPosition().longitude().value(CAngleUnit::deg()) * (65536.0 * 65536.0) / 360.0;
|
||||
const double longitude = situation.getPosition().longitude().value(CAngleUnit::deg()) * (65536.0 * 65536.0) / 360.0;
|
||||
positionSlewMode.lon_hi = static_cast<qint32>(longitude);
|
||||
positionSlewMode.lon_lo = static_cast<quint16>(qAbs((longitude - positionSlewMode.lon_hi) * 65536));
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace BlackSimPlugin
|
||||
pbhstrct.bank = qRound(std::floor(situation.getBank().value(CAngleUnit::deg()) * CFs9Sdk::bankMultiplier()));
|
||||
// MSFS has inverted pitch and bank angles
|
||||
pbhstrct.pitch = ~pbhstrct.pitch;
|
||||
pbhstrct.bank = ~pbhstrct.bank;
|
||||
pbhstrct.bank = ~pbhstrct.bank;
|
||||
|
||||
pbhstrct.onground = situation.isOnGround() ? 1 : 0;
|
||||
positionSlewMode.pbh = pbhstrct.pbh;
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace BlackSimPlugin
|
||||
data.append(qPrintable(value), value.size() + 1);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -90,8 +90,10 @@ namespace BlackSimPlugin
|
||||
int bank = qRound(std::floor(pbhstrct.bank / CFs9Sdk::bankMultiplier()));
|
||||
|
||||
// MSFS has inverted pitch and bank angles
|
||||
// ~ and NOT -: https://dev.swift-project.org/rSWIFTPILOTCLIENT7f90652b
|
||||
// The problem with - is that -(-512) is 512 but the maximum is 511 so this overflows back to -512 and causes a visual glitch.
|
||||
pitch = ~pitch;
|
||||
bank = ~bank;
|
||||
bank = ~bank;
|
||||
situation.setPitch(CAngle(pitch, CAngleUnit::deg()));
|
||||
situation.setBank(CAngle(bank, CAngleUnit::deg()));
|
||||
situation.setHeading(CHeading(pbhstrct.hdg / CFs9Sdk::headingMultiplier(), CHeading::Magnetic, CAngleUnit::deg()));
|
||||
@@ -233,9 +235,9 @@ namespace BlackSimPlugin
|
||||
const CTransponder newTransponder = ownAircraft.getTransponder();
|
||||
|
||||
bool changed = false;
|
||||
if (newCom1.getFrequencyActive() != m_simCom1.getFrequencyActive()) { changed = true; }
|
||||
if (newCom1.getFrequencyActive() != m_simCom1.getFrequencyActive()) { changed = true; }
|
||||
if (newCom1.getFrequencyStandby() != m_simCom1.getFrequencyStandby()) { changed = true; }
|
||||
if (newCom2.getFrequencyActive() != m_simCom2.getFrequencyActive()) { changed = true; }
|
||||
if (newCom2.getFrequencyActive() != m_simCom2.getFrequencyActive()) { changed = true; }
|
||||
if (newCom2.getFrequencyStandby() != m_simCom2.getFrequencyStandby()) { changed = true; }
|
||||
if (newTransponder.getTransponderCode() != m_simTransponder.getTransponderCode()) { changed = true; }
|
||||
if (newTransponder.getTransponderMode() != m_simTransponder.getTransponderMode()) { changed = true; }
|
||||
@@ -258,7 +260,7 @@ namespace BlackSimPlugin
|
||||
if (selcal != m_selcal)
|
||||
{
|
||||
//! KB 2018-11 that would need to go to updateOwnAircraftFromSimulator if the simulator ever supports SELCAL
|
||||
//! KB 2018-11 als we would need to send the value to FS9/FSX (currently we only deal with it on FS9/FSX level)
|
||||
//! KB 2018-11 as we would need to send the value to FS9/FSX (currently we only deal with it on FS9/FSX level)
|
||||
m_selcal = selcal;
|
||||
changed = true;
|
||||
}
|
||||
@@ -378,7 +380,7 @@ namespace BlackSimPlugin
|
||||
m_skipCockpitUpdateCycles--;
|
||||
}
|
||||
|
||||
CAircraftSituation aircraftSituation = simDataOwnAircraft.getSituation();
|
||||
const CAircraftSituation aircraftSituation = simDataOwnAircraft.getSituation();
|
||||
this->updateOwnSituation(aircraftSituation);
|
||||
|
||||
if (m_isWeatherActivated)
|
||||
|
||||
@@ -490,9 +490,9 @@ namespace BlackSimPlugin
|
||||
const double lonCorrectionFactor = 360.0 / (65536.0 * 65536.0 * 65536.0 * 65536.0);
|
||||
CAircraftSituation situation = aircraft.getSituation();
|
||||
CCoordinateGeodetic position = situation.getPosition();
|
||||
CLatitude lat(latitudeRaw * latCorrectionFactor, CAngleUnit::deg());
|
||||
CLatitude lat(latitudeRaw * latCorrectionFactor, CAngleUnit::deg());
|
||||
CLongitude lon(longitudeRaw * lonCorrectionFactor, CAngleUnit::deg());
|
||||
CAltitude groundAltitude(groundAltitudeRaw / 256.0, CLengthUnit::m());
|
||||
CAltitude groundAltitude(groundAltitudeRaw / 256.0, CLengthUnit::m());
|
||||
position.setLatitude(lat);
|
||||
position.setLongitude(lon);
|
||||
position.setGeodeticHeight(groundAltitude);
|
||||
@@ -509,7 +509,7 @@ namespace BlackSimPlugin
|
||||
|
||||
// speeds, situation
|
||||
CAngle pitch = CAngle(pitchRaw, CAngleUnit::deg());
|
||||
CAngle bank = CAngle(bankRaw, CAngleUnit::deg());
|
||||
CAngle bank = CAngle(bankRaw, CAngleUnit::deg());
|
||||
CHeading heading = CHeading(headingRaw * angleCorrectionFactor, CHeading::True, CAngleUnit::deg());
|
||||
CSpeed groundspeed(groundspeedRaw / 65536.0, CSpeedUnit::m_s());
|
||||
CAltitude altitude(altitudeRaw / (65536.0 * 65536.0), CAltitude::MeanSeaLevel, CLengthUnit::m());
|
||||
|
||||
@@ -80,8 +80,8 @@ namespace BlackSimPlugin
|
||||
|
||||
CFsuipc *m_fsuipc = nullptr; //!< FSUIPC
|
||||
bool m_useFsuipc = false; //!< use FSUIPC
|
||||
bool m_simPaused = false; //!< Simulator paused?
|
||||
bool m_simTimeSynced = false; //!< Time synchronized?
|
||||
bool m_simPaused = false; //!< simulator paused?
|
||||
bool m_simTimeSynced = false; //!< time synchronized?
|
||||
BlackMisc::PhysicalQuantities::CTime m_syncTimeOffset; //!< time offset
|
||||
BlackMisc::Aviation::CAirportList m_airportsInRangeFromSimulator; //!< airports in range of own aircraft
|
||||
|
||||
|
||||
@@ -29,17 +29,17 @@ namespace BlackSimPlugin
|
||||
//! \sa SimConnect events http://msdn.microsoft.com/en-us/library/cc526980.aspx
|
||||
struct DataDefinitionOwnAircraft
|
||||
{
|
||||
double latitude; //!< Latitude (deg)
|
||||
double longitude; //!< Longitude (deg)
|
||||
double altitude; //!< Altitude (ft)
|
||||
double altitudeAGL; //!< Altitude above ground (ft)
|
||||
double pressureAltitude; //!< Pressure altitude (m)
|
||||
double cgToGround; //!< Static CG to ground (ft)
|
||||
double trueHeading; //!< True heading (deg)
|
||||
double pitch; //!< Pitch (deg)
|
||||
double bank; //!< Bank (deg)
|
||||
double latitudeDeg; //!< Latitude (deg)
|
||||
double longitudeDeg; //!< Longitude (deg)
|
||||
double altitudeFt; //!< Altitude (ft)
|
||||
double altitudeAGLFt; //!< Altitude above ground (ft)
|
||||
double pressureAltitudeM; //!< Pressure altitude (m)
|
||||
double cgToGroundFt; //!< Static CG to ground (ft)
|
||||
double trueHeadingDeg; //!< True heading (deg)
|
||||
double pitchDeg; //!< Pitch (deg)
|
||||
double bankDeg; //!< Bank (deg)
|
||||
double velocity; //!< Ground velocity
|
||||
double elevation; //!< Elevation (ft)
|
||||
double elevationFt; //!< Elevation (ft)
|
||||
double simOnGround; //!< Is aircraft on ground?
|
||||
// 12
|
||||
double lightStrobe; //!< Is strobe light on?
|
||||
|
||||
@@ -54,10 +54,10 @@ namespace BlackSimPlugin
|
||||
namespace FsxCommon
|
||||
{
|
||||
CSimulatorFsxCommon::CSimulatorFsxCommon(const CSimulatorPluginInfo &info,
|
||||
IOwnAircraftProvider *ownAircraftProvider,
|
||||
IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
IWeatherGridProvider *weatherGridProvider,
|
||||
IClientProvider *clientProvider,
|
||||
IWeatherGridProvider *weatherGridProvider,
|
||||
IClientProvider *clientProvider,
|
||||
QObject *parent) :
|
||||
CSimulatorFsCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, clientProvider, parent)
|
||||
{
|
||||
@@ -373,9 +373,9 @@ namespace BlackSimPlugin
|
||||
m_dispatchTimeMs = -1;
|
||||
m_dispatchProcTimeMs = -1;
|
||||
m_requestSimObjectDataCount = 0;
|
||||
m_dispatchReceiveIdLast = SIMCONNECT_RECV_ID_NULL;
|
||||
m_dispatchReceiveIdLast = SIMCONNECT_RECV_ID_NULL;
|
||||
m_dispatchReceiveIdMaxTime = SIMCONNECT_RECV_ID_NULL;
|
||||
m_dispatchRequestIdLast = CSimConnectDefinitions::RequestEndMarker;
|
||||
m_dispatchRequestIdLast = CSimConnectDefinitions::RequestEndMarker;
|
||||
m_dispatchRequestIdMaxTime = CSimConnectDefinitions::RequestEndMarker;
|
||||
CSimulatorPluginCommon::resetAircraftStatistics();
|
||||
}
|
||||
@@ -632,24 +632,24 @@ namespace BlackSimPlugin
|
||||
|
||||
CSimulatedAircraft myAircraft(getOwnAircraft());
|
||||
CCoordinateGeodetic position;
|
||||
position.setLatitude(CLatitude(simulatorOwnAircraft.latitude, CAngleUnit::deg()));
|
||||
position.setLongitude(CLongitude(simulatorOwnAircraft.longitude, CAngleUnit::deg()));
|
||||
position.setLatitude(CLatitude(simulatorOwnAircraft.latitudeDeg, CAngleUnit::deg()));
|
||||
position.setLongitude(CLongitude(simulatorOwnAircraft.longitudeDeg, CAngleUnit::deg()));
|
||||
|
||||
if (simulatorOwnAircraft.pitch < -90.0 || simulatorOwnAircraft.pitch >= 90.0)
|
||||
if (simulatorOwnAircraft.pitchDeg < -90.0 || simulatorOwnAircraft.pitchDeg >= 90.0)
|
||||
{
|
||||
CLogMessage(this).warning(u"FSX: Pitch value (own aircraft) out of limits: %1") << simulatorOwnAircraft.pitch;
|
||||
CLogMessage(this).warning(u"FSX: Pitch value (own aircraft) out of limits: %1") << simulatorOwnAircraft.pitchDeg;
|
||||
}
|
||||
CAircraftSituation aircraftSituation;
|
||||
aircraftSituation.setMSecsSinceEpoch(ts);
|
||||
aircraftSituation.setPosition(position);
|
||||
// MSFS has inverted pitch and bank angles
|
||||
aircraftSituation.setPitch(CAngle(-simulatorOwnAircraft.pitch, CAngleUnit::deg()));
|
||||
aircraftSituation.setBank(CAngle(-simulatorOwnAircraft.bank, CAngleUnit::deg()));
|
||||
aircraftSituation.setHeading(CHeading(simulatorOwnAircraft.trueHeading, CHeading::True, CAngleUnit::deg()));
|
||||
aircraftSituation.setPitch(CAngle(-simulatorOwnAircraft.pitchDeg, CAngleUnit::deg()));
|
||||
aircraftSituation.setBank(CAngle(-simulatorOwnAircraft.bankDeg, CAngleUnit::deg()));
|
||||
aircraftSituation.setHeading(CHeading(simulatorOwnAircraft.trueHeadingDeg, CHeading::True, CAngleUnit::deg()));
|
||||
aircraftSituation.setGroundSpeed(CSpeed(simulatorOwnAircraft.velocity, CSpeedUnit::kts()));
|
||||
aircraftSituation.setGroundElevation(CAltitude(simulatorOwnAircraft.elevation, CAltitude::MeanSeaLevel, CLengthUnit::ft()), CAircraftSituation::FromProvider);
|
||||
aircraftSituation.setAltitude(CAltitude(simulatorOwnAircraft.altitude, CAltitude::MeanSeaLevel, CLengthUnit::ft()));
|
||||
aircraftSituation.setPressureAltitude(CAltitude(simulatorOwnAircraft.pressureAltitude, CAltitude::MeanSeaLevel, CAltitude::PressureAltitude, CLengthUnit::m()));
|
||||
aircraftSituation.setGroundElevation(CAltitude(simulatorOwnAircraft.elevationFt, CAltitude::MeanSeaLevel, CLengthUnit::ft()), CAircraftSituation::FromProvider);
|
||||
aircraftSituation.setAltitude(CAltitude(simulatorOwnAircraft.altitudeFt, CAltitude::MeanSeaLevel, CLengthUnit::ft()));
|
||||
aircraftSituation.setPressureAltitude(CAltitude(simulatorOwnAircraft.pressureAltitudeM, CAltitude::MeanSeaLevel, CAltitude::PressureAltitude, CLengthUnit::m()));
|
||||
// set on ground also in situation for consistency and future usage
|
||||
// it is duplicated in parts
|
||||
aircraftSituation.setOnGround(dtb(simulatorOwnAircraft.simOnGround) ? CAircraftSituation::OnGround : CAircraftSituation::NotOnGround, CAircraftSituation::OutOnGroundOwnAircraft);
|
||||
@@ -765,11 +765,16 @@ namespace BlackSimPlugin
|
||||
m_simulatorInternals.setValue(QStringLiteral("fsx/sb3"), boolToEnabledDisabled(m_useSbOffsets));
|
||||
m_simulatorInternals.setValue(QStringLiteral("fsx/sb3packets"), m_useSbOffsets ? QString::number(m_sbDataReceived) : QStringLiteral("disabled"));
|
||||
|
||||
// CG
|
||||
const CLength cg(simulatorOwnAircraft.cgToGroundFt, CLengthUnit::ft());
|
||||
this->updateOwnCG(cg);
|
||||
|
||||
// Simulated objects instead of NON ATC
|
||||
m_simulatorInternals.setValue(QStringLiteral("fsx/addAsSimulatedObject"), boolToEnabledDisabled(m_useAddSimulatedObj));
|
||||
}
|
||||
|
||||
m_ownAircraftUpdateCycles++; // with 50updates/sec long enough even for 32bit
|
||||
} // slow updates
|
||||
|
||||
m_ownAircraftUpdateCycles++; // with 50 updates/sec long enough even for 32bit
|
||||
}
|
||||
|
||||
void CSimulatorFsxCommon::triggerUpdateRemoteAircraftFromSimulator(const CSimConnectObject &simObject, const DataDefinitionPosData &remoteAircraftData)
|
||||
@@ -2488,16 +2493,15 @@ namespace BlackSimPlugin
|
||||
|
||||
// reset values
|
||||
m_simulatingChangedTs = -1;
|
||||
m_simConnected = false;
|
||||
m_simConnected = false;
|
||||
m_simSimulating = false;
|
||||
m_sbDataReceived = 0;
|
||||
m_syncTimeDeferredCounter = 0;
|
||||
m_syncTimeDeferredCounter = 0;
|
||||
m_skipCockpitUpdateCycles = 0;
|
||||
m_ownAircraftUpdateCycles = 0;
|
||||
m_requestIdSimObjAircraft = static_cast<SIMCONNECT_DATA_REQUEST_ID>(RequestSimObjAircraftStart);
|
||||
m_dispatchErrors = 0;
|
||||
m_receiveExceptionCount = 0;
|
||||
m_addedProbes = 0;
|
||||
m_addedProbes = 0;
|
||||
m_initFsxTerrainProbes = false;
|
||||
m_sendIdTraces.clear();
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace BlackSimPlugin
|
||||
// Updates
|
||||
// Do not update ICAO codes, as this overrides reverse lookups
|
||||
// updateOwnIcaoCodes(m_xplaneData.aircraftIcaoCode, CAirlineIcaoCode());
|
||||
updateOwnSituation(situation);
|
||||
this->updateOwn(situation);
|
||||
|
||||
// defaults
|
||||
CSimulatedAircraft myAircraft(getOwnAircraft());
|
||||
|
||||
Reference in New Issue
Block a user