mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T436, correct file name handling (UNC) and validate FSX position
This commit is contained in:
@@ -140,13 +140,18 @@ namespace BlackMisc
|
||||
{
|
||||
CStatusMessageList msgs;
|
||||
const ModelType t = this->getModelType();
|
||||
if (t == TypeOwnSimulatorModel || t == TypeManuallySet || t == TypeDatabaseEntry)
|
||||
if (t == TypeOwnSimulatorModel || t == TypeManuallySet || t == TypeDatabaseEntry || t == TypeModelMatching || t == TypeModelMatchingDefaultModel)
|
||||
{
|
||||
if (!this->hasExistingCorrespondingFile())
|
||||
{
|
||||
const CStatusMessage m = CStatusMessage(this).validationError("File '%1' not readable") << this->getFileName();
|
||||
msgs.push_back(m);
|
||||
}
|
||||
else
|
||||
{
|
||||
const CStatusMessage m = CStatusMessage(this).validationInfo("File '%1' existing") << this->getFileName();
|
||||
msgs.push_back(m);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -682,7 +687,7 @@ namespace BlackMisc
|
||||
bool CAircraftModel::hasExistingCorrespondingFile() const
|
||||
{
|
||||
if (!this->hasFileName()) { return false; }
|
||||
const QFileInfo fi(this->getFileName());
|
||||
const QFileInfo fi(CFileUtils::fixWindowsUncPath(this->getFileName()));
|
||||
return (fi.exists() && fi.isReadable());
|
||||
}
|
||||
|
||||
|
||||
@@ -222,10 +222,11 @@ namespace BlackMisc
|
||||
// unfortunately some files are malformed which could end up in wrong data
|
||||
|
||||
ok = false;
|
||||
QFile file(fileName); // includes path
|
||||
const QString fnFixed = CFileUtils::fixWindowsUncPath(fileName);
|
||||
QFile file(fnFixed); // includes path
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text))
|
||||
{
|
||||
const CStatusMessage m = CStatusMessage(getLogCategories()).warning("Unable to read file '%1'") << fileName;
|
||||
const CStatusMessage m = CStatusMessage(getLogCategories()).warning("Unable to read file '%1'") << fnFixed;
|
||||
msgs.push_back(m);
|
||||
return CAircraftCfgEntriesList();
|
||||
}
|
||||
@@ -352,7 +353,7 @@ namespace BlackMisc
|
||||
file.close();
|
||||
|
||||
// store all entries
|
||||
const QFileInfo fileInfo(fileName);
|
||||
const QFileInfo fileInfo(fnFixed);
|
||||
QDateTime fileTimestamp(fileInfo.lastModified());
|
||||
if (!fileTimestamp.isValid() || fileInfo.created() > fileTimestamp)
|
||||
{
|
||||
|
||||
@@ -306,6 +306,12 @@ namespace BlackSimPlugin
|
||||
//! Format conversion
|
||||
static SIMCONNECT_DATA_LATLONALT coordinateToFsxLatLonAlt(const BlackMisc::Geo::ICoordinateGeodetic &coordinate);
|
||||
|
||||
//! Valid FSX/P3D position
|
||||
static bool isValidFsxPosition(const SIMCONNECT_DATA_INITPOSITION &fsxPos);
|
||||
|
||||
//! Valid 180degrees value
|
||||
static bool isValid180Deg(double deg) { return deg > -180.0 && deg <= 180.0; }
|
||||
|
||||
static constexpr qint64 AutoTraceOffsetMs = 10 * 1000; //!< how long do we trace?
|
||||
HANDLE m_hSimConnect = nullptr; //!< handle to SimConnect object
|
||||
DispatchProc m_dispatchProc = &CSimulatorFsxCommon::SimConnectProc; //!< called function for dispatch, can be overriden by specialized P3D function
|
||||
|
||||
Reference in New Issue
Block a user