mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +08:00
Ref T683, style
This commit is contained in:
@@ -284,7 +284,7 @@ namespace BlackCore
|
|||||||
bool CContextOwnAircraft::updateOwnParts(const CAircraftParts &parts)
|
bool CContextOwnAircraft::updateOwnParts(const CAircraftParts &parts)
|
||||||
{
|
{
|
||||||
QWriteLocker l(&m_lockAircraft);
|
QWriteLocker l(&m_lockAircraft);
|
||||||
bool changed = (m_ownAircraft.getParts() != parts);
|
const bool changed = (m_ownAircraft.getParts() != parts);
|
||||||
if (!changed) { return false; }
|
if (!changed) { return false; }
|
||||||
m_ownAircraft.setParts(parts);
|
m_ownAircraft.setParts(parts);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -845,10 +845,10 @@ namespace BlackCore
|
|||||||
this->rememberGroundElevation(callsign, elevation);
|
this->rememberGroundElevation(callsign, elevation);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CLength cgO = this->overriddenCGorDefault(simulatorCG, modelString);
|
const CLength cgOvr = this->overriddenCGorDefault(simulatorCG, modelString);
|
||||||
if (!cgO.isNull() && !this->hasSameSimulatorCG(cgO, callsign))
|
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
|
// here we know we have a valid model and CG
|
||||||
m_autoPublishing.insert(modelString, simulatorCG); // still using CG here, not the overridden value
|
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)
|
void ISimulator::reverseLookupAndUpdateOwnAircraftModel(const QString &modelString)
|
||||||
{
|
{
|
||||||
CAircraftModel model = getOwnAircraftModel();
|
CAircraftModel model = this->getOwnAircraftModel();
|
||||||
model.setModelString(modelString);
|
model.setModelString(modelString);
|
||||||
this->reverseLookupAndUpdateOwnAircraftModel(model);
|
this->reverseLookupAndUpdateOwnAircraftModel(model);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -534,6 +534,7 @@ namespace BlackMisc
|
|||||||
bool CSimulatedAircraft::setCG(const CLength &cg)
|
bool CSimulatedAircraft::setCG(const CLength &cg)
|
||||||
{
|
{
|
||||||
if (cg.isNull()) { return false; }
|
if (cg.isNull()) { return false; }
|
||||||
|
// ???? set to both models, or only the matched model ????
|
||||||
const int c = m_models.setCG(cg);
|
const int c = m_models.setCG(cg);
|
||||||
return c > 0;
|
return c > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ namespace BlackSimPlugin
|
|||||||
// Updates
|
// Updates
|
||||||
// Do not update ICAO codes, as this overrides reverse lookups
|
// Do not update ICAO codes, as this overrides reverse lookups
|
||||||
// updateOwnIcaoCodes(m_flightgearData.aircraftIcaoCode, CAirlineIcaoCode());
|
// updateOwnIcaoCodes(m_flightgearData.aircraftIcaoCode, CAirlineIcaoCode());
|
||||||
updateOwnSituation(situation);
|
this->updateOwnSituation(situation);
|
||||||
|
|
||||||
// defaults
|
// defaults
|
||||||
CSimulatedAircraft myAircraft(getOwnAircraft());
|
CSimulatedAircraft myAircraft(getOwnAircraft());
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ namespace BlackSimPlugin
|
|||||||
data.append(qPrintable(value), value.size() + 1);
|
data.append(qPrintable(value), value.size() + 1);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
} // ns
|
||||||
}
|
} // ns
|
||||||
}
|
} // ns
|
||||||
}
|
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ namespace BlackSimPlugin
|
|||||||
int bank = qRound(std::floor(pbhstrct.bank / CFs9Sdk::bankMultiplier()));
|
int bank = qRound(std::floor(pbhstrct.bank / CFs9Sdk::bankMultiplier()));
|
||||||
|
|
||||||
// MSFS has inverted pitch and bank angles
|
// 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;
|
pitch = ~pitch;
|
||||||
bank = ~bank;
|
bank = ~bank;
|
||||||
situation.setPitch(CAngle(pitch, CAngleUnit::deg()));
|
situation.setPitch(CAngle(pitch, CAngleUnit::deg()));
|
||||||
@@ -258,7 +260,7 @@ namespace BlackSimPlugin
|
|||||||
if (selcal != m_selcal)
|
if (selcal != m_selcal)
|
||||||
{
|
{
|
||||||
//! KB 2018-11 that would need to go to updateOwnAircraftFromSimulator if the simulator ever supports 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;
|
m_selcal = selcal;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@@ -378,7 +380,7 @@ namespace BlackSimPlugin
|
|||||||
m_skipCockpitUpdateCycles--;
|
m_skipCockpitUpdateCycles--;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftSituation aircraftSituation = simDataOwnAircraft.getSituation();
|
const CAircraftSituation aircraftSituation = simDataOwnAircraft.getSituation();
|
||||||
this->updateOwnSituation(aircraftSituation);
|
this->updateOwnSituation(aircraftSituation);
|
||||||
|
|
||||||
if (m_isWeatherActivated)
|
if (m_isWeatherActivated)
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
CFsuipc *m_fsuipc = nullptr; //!< FSUIPC
|
CFsuipc *m_fsuipc = nullptr; //!< FSUIPC
|
||||||
bool m_useFsuipc = false; //!< use FSUIPC
|
bool m_useFsuipc = false; //!< use FSUIPC
|
||||||
bool m_simPaused = false; //!< Simulator paused?
|
bool m_simPaused = false; //!< simulator paused?
|
||||||
bool m_simTimeSynced = false; //!< Time synchronized?
|
bool m_simTimeSynced = false; //!< time synchronized?
|
||||||
BlackMisc::PhysicalQuantities::CTime m_syncTimeOffset; //!< time offset
|
BlackMisc::PhysicalQuantities::CTime m_syncTimeOffset; //!< time offset
|
||||||
BlackMisc::Aviation::CAirportList m_airportsInRangeFromSimulator; //!< airports in range of own aircraft
|
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
|
//! \sa SimConnect events http://msdn.microsoft.com/en-us/library/cc526980.aspx
|
||||||
struct DataDefinitionOwnAircraft
|
struct DataDefinitionOwnAircraft
|
||||||
{
|
{
|
||||||
double latitude; //!< Latitude (deg)
|
double latitudeDeg; //!< Latitude (deg)
|
||||||
double longitude; //!< Longitude (deg)
|
double longitudeDeg; //!< Longitude (deg)
|
||||||
double altitude; //!< Altitude (ft)
|
double altitudeFt; //!< Altitude (ft)
|
||||||
double altitudeAGL; //!< Altitude above ground (ft)
|
double altitudeAGLFt; //!< Altitude above ground (ft)
|
||||||
double pressureAltitude; //!< Pressure altitude (m)
|
double pressureAltitudeM; //!< Pressure altitude (m)
|
||||||
double cgToGround; //!< Static CG to ground (ft)
|
double cgToGroundFt; //!< Static CG to ground (ft)
|
||||||
double trueHeading; //!< True heading (deg)
|
double trueHeadingDeg; //!< True heading (deg)
|
||||||
double pitch; //!< Pitch (deg)
|
double pitchDeg; //!< Pitch (deg)
|
||||||
double bank; //!< Bank (deg)
|
double bankDeg; //!< Bank (deg)
|
||||||
double velocity; //!< Ground velocity
|
double velocity; //!< Ground velocity
|
||||||
double elevation; //!< Elevation (ft)
|
double elevationFt; //!< Elevation (ft)
|
||||||
double simOnGround; //!< Is aircraft on ground?
|
double simOnGround; //!< Is aircraft on ground?
|
||||||
// 12
|
// 12
|
||||||
double lightStrobe; //!< Is strobe light on?
|
double lightStrobe; //!< Is strobe light on?
|
||||||
|
|||||||
@@ -632,24 +632,24 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
CSimulatedAircraft myAircraft(getOwnAircraft());
|
CSimulatedAircraft myAircraft(getOwnAircraft());
|
||||||
CCoordinateGeodetic position;
|
CCoordinateGeodetic position;
|
||||||
position.setLatitude(CLatitude(simulatorOwnAircraft.latitude, CAngleUnit::deg()));
|
position.setLatitude(CLatitude(simulatorOwnAircraft.latitudeDeg, CAngleUnit::deg()));
|
||||||
position.setLongitude(CLongitude(simulatorOwnAircraft.longitude, 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;
|
CAircraftSituation aircraftSituation;
|
||||||
aircraftSituation.setMSecsSinceEpoch(ts);
|
aircraftSituation.setMSecsSinceEpoch(ts);
|
||||||
aircraftSituation.setPosition(position);
|
aircraftSituation.setPosition(position);
|
||||||
// MSFS has inverted pitch and bank angles
|
// MSFS has inverted pitch and bank angles
|
||||||
aircraftSituation.setPitch(CAngle(-simulatorOwnAircraft.pitch, CAngleUnit::deg()));
|
aircraftSituation.setPitch(CAngle(-simulatorOwnAircraft.pitchDeg, CAngleUnit::deg()));
|
||||||
aircraftSituation.setBank(CAngle(-simulatorOwnAircraft.bank, CAngleUnit::deg()));
|
aircraftSituation.setBank(CAngle(-simulatorOwnAircraft.bankDeg, CAngleUnit::deg()));
|
||||||
aircraftSituation.setHeading(CHeading(simulatorOwnAircraft.trueHeading, CHeading::True, CAngleUnit::deg()));
|
aircraftSituation.setHeading(CHeading(simulatorOwnAircraft.trueHeadingDeg, CHeading::True, CAngleUnit::deg()));
|
||||||
aircraftSituation.setGroundSpeed(CSpeed(simulatorOwnAircraft.velocity, CSpeedUnit::kts()));
|
aircraftSituation.setGroundSpeed(CSpeed(simulatorOwnAircraft.velocity, CSpeedUnit::kts()));
|
||||||
aircraftSituation.setGroundElevation(CAltitude(simulatorOwnAircraft.elevation, CAltitude::MeanSeaLevel, CLengthUnit::ft()), CAircraftSituation::FromProvider);
|
aircraftSituation.setGroundElevation(CAltitude(simulatorOwnAircraft.elevationFt, CAltitude::MeanSeaLevel, CLengthUnit::ft()), CAircraftSituation::FromProvider);
|
||||||
aircraftSituation.setAltitude(CAltitude(simulatorOwnAircraft.altitude, CAltitude::MeanSeaLevel, CLengthUnit::ft()));
|
aircraftSituation.setAltitude(CAltitude(simulatorOwnAircraft.altitudeFt, CAltitude::MeanSeaLevel, CLengthUnit::ft()));
|
||||||
aircraftSituation.setPressureAltitude(CAltitude(simulatorOwnAircraft.pressureAltitude, CAltitude::MeanSeaLevel, CAltitude::PressureAltitude, CLengthUnit::m()));
|
aircraftSituation.setPressureAltitude(CAltitude(simulatorOwnAircraft.pressureAltitudeM, CAltitude::MeanSeaLevel, CAltitude::PressureAltitude, CLengthUnit::m()));
|
||||||
// set on ground also in situation for consistency and future usage
|
// set on ground also in situation for consistency and future usage
|
||||||
// it is duplicated in parts
|
// it is duplicated in parts
|
||||||
aircraftSituation.setOnGround(dtb(simulatorOwnAircraft.simOnGround) ? CAircraftSituation::OnGround : CAircraftSituation::NotOnGround, CAircraftSituation::OutOnGroundOwnAircraft);
|
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/sb3"), boolToEnabledDisabled(m_useSbOffsets));
|
||||||
m_simulatorInternals.setValue(QStringLiteral("fsx/sb3packets"), m_useSbOffsets ? QString::number(m_sbDataReceived) : QStringLiteral("disabled"));
|
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
|
// Simulated objects instead of NON ATC
|
||||||
m_simulatorInternals.setValue(QStringLiteral("fsx/addAsSimulatedObject"), boolToEnabledDisabled(m_useAddSimulatedObj));
|
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)
|
void CSimulatorFsxCommon::triggerUpdateRemoteAircraftFromSimulator(const CSimConnectObject &simObject, const DataDefinitionPosData &remoteAircraftData)
|
||||||
@@ -2493,7 +2498,6 @@ namespace BlackSimPlugin
|
|||||||
m_sbDataReceived = 0;
|
m_sbDataReceived = 0;
|
||||||
m_syncTimeDeferredCounter = 0;
|
m_syncTimeDeferredCounter = 0;
|
||||||
m_skipCockpitUpdateCycles = 0;
|
m_skipCockpitUpdateCycles = 0;
|
||||||
m_ownAircraftUpdateCycles = 0;
|
|
||||||
m_requestIdSimObjAircraft = static_cast<SIMCONNECT_DATA_REQUEST_ID>(RequestSimObjAircraftStart);
|
m_requestIdSimObjAircraft = static_cast<SIMCONNECT_DATA_REQUEST_ID>(RequestSimObjAircraftStart);
|
||||||
m_dispatchErrors = 0;
|
m_dispatchErrors = 0;
|
||||||
m_receiveExceptionCount = 0;
|
m_receiveExceptionCount = 0;
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ namespace BlackSimPlugin
|
|||||||
// Updates
|
// Updates
|
||||||
// Do not update ICAO codes, as this overrides reverse lookups
|
// Do not update ICAO codes, as this overrides reverse lookups
|
||||||
// updateOwnIcaoCodes(m_xplaneData.aircraftIcaoCode, CAirlineIcaoCode());
|
// updateOwnIcaoCodes(m_xplaneData.aircraftIcaoCode, CAirlineIcaoCode());
|
||||||
updateOwnSituation(situation);
|
this->updateOwn(situation);
|
||||||
|
|
||||||
// defaults
|
// defaults
|
||||||
CSimulatedAircraft myAircraft(getOwnAircraft());
|
CSimulatedAircraft myAircraft(getOwnAircraft());
|
||||||
|
|||||||
Reference in New Issue
Block a user