From 488f42b0a16cc4095a1edb305fd25dcb6104ff6d Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Thu, 6 Apr 2017 03:06:25 +0100 Subject: [PATCH] refs #928 Parse and load OBJ8 CSL packages. --- .../xplane/aircraftmodelloaderxplane.cpp | 21 +++++++++++-------- .../xplane/aircraftmodelloaderxplane.h | 2 +- .../simulator/xplane/simulatorxplane.cpp | 3 ++- src/xbus/libxplanemp | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.cpp b/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.cpp index 615584c19..3d63e347e 100644 --- a/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.cpp +++ b/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.cpp @@ -128,11 +128,11 @@ namespace BlackMisc QString CAircraftModelLoaderXPlane::CSLPlane::getModelName() const { - const QString modelName = + QString modelName = dirNames.join(' ') % QLatin1Char(' ') % objectName % QLatin1Char(' ') % textureName; - return modelName; + return std::move(modelName).trimmed(); } CAircraftModelList CAircraftModelLoaderXPlane::performParsing(const QString &rootDirectory, const QStringList &excludeDirectories) @@ -476,9 +476,13 @@ namespace BlackMisc CLogMessage(this).warning("%1 - %2: OBJ8_AIRCARFT command requires 1 argument.") << path << lineNum; } - // RW: I need an example of the file to properly implement and test it. - CLogMessage(this).warning("Not implemented yet."); - return false; + package.planes.push_back(CSLPlane()); + package.planes.back().dirNames << package.path.mid(package.path.lastIndexOf('/') + 1); + package.planes.back().objectName = tokens[1]; + package.planes.back().filePath = package.path; + // Package name and object name uniquely identify an OBJ8 aircraft. + // File path just points to the package root. + return true; } bool CAircraftModelLoaderXPlane::parseObj8Command(const QStringList &tokens, CSLPackage &package, const QString &path, int lineNum) @@ -487,12 +491,11 @@ namespace BlackMisc // OBJ8 if (tokens.size() != 4) { - CLogMessage(this).warning("%1 - %2: OBJ8_AIRCARFT command requires 3 arguments.") << path << lineNum; + CLogMessage(this).warning("%1 - %2: OBJ8 command requires 3 arguments.") << path << lineNum; } - // RW: I need an example of the file to properly implement and test it. - CLogMessage(this).warning("Not implemented yet."); - return false; + // command contains no useful information for us + return true; } bool CAircraftModelLoaderXPlane::parseHasGearCommand(const QStringList &tokens, CSLPackage &package, const QString &path, int lineNum) diff --git a/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.h b/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.h index 032c19e8e..5fde5d1c1 100644 --- a/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.h +++ b/src/blackmisc/simulation/xplane/aircraftmodelloaderxplane.h @@ -71,7 +71,7 @@ namespace BlackMisc // Model name parts QStringList dirNames; //!< List dir names starting from xsb_aircrafts.txt parent down to obj folder QString objectName; //!< Complete basename of the object file - QString textureName; //!< Complete basename of the texture file + QString textureName; //!< Complete basename of the texture file. Can be empty. QString filePath; //!< object filePath QString icao; //!< Icao type of this model diff --git a/src/plugins/simulator/xplane/simulatorxplane.cpp b/src/plugins/simulator/xplane/simulatorxplane.cpp index 431d144de..57ece0b3b 100644 --- a/src/plugins/simulator/xplane/simulatorxplane.cpp +++ b/src/plugins/simulator/xplane/simulatorxplane.cpp @@ -476,7 +476,8 @@ namespace BlackSimPlugin QString CSimulatorXPlane::findCslPackage(const QString &modelFile) { - QDir dir = QFileInfo(modelFile).dir(); + const QFileInfo info(modelFile); + QDir dir = info.isDir() ? QDir(modelFile) : info.dir(); do { if (dir.exists(QStringLiteral("xsb_aircraft.txt"))) diff --git a/src/xbus/libxplanemp b/src/xbus/libxplanemp index 5ee5b8990..ff760ecff 160000 --- a/src/xbus/libxplanemp +++ b/src/xbus/libxplanemp @@ -1 +1 @@ -Subproject commit 5ee5b899096963048252d25533d45afe48ca4b73 +Subproject commit ff760ecffb74412c38712f98d659712d9afb290a