Issue #17 Udjust to model string changes in xplanemp2

This commit is contained in:
Mat Sutcliffe
2020-05-30 15:42:08 +01:00
parent cdd95a3a0b
commit 5548d8af2d
3 changed files with 18 additions and 13 deletions

View File

@@ -158,8 +158,8 @@ namespace BlackMisc
{
QString modelName =
dirNames.join(' ') %
u' ' % objectName %
u' ' % textureName;
u' ' % objectName;
if (objectVersion == OBJ7) { modelName += u' ' % textureName; }
return std::move(modelName).trimmed();
}
@@ -514,6 +514,9 @@ namespace BlackMisc
return false;
}
}
package.planes.back().objectName = tokens[1];
package.planes.back().objectVersion = CSLPlane::OBJ8;
return true;
}
@@ -547,17 +550,8 @@ namespace BlackMisc
// Remove the last one being the obj itself
dirNames.removeLast();
QFileInfo fileInfo(fullPath);
if (! fileInfo.exists())
{
const CStatusMessage m = CStatusMessage(this).error(u"XPlane object '%1' does not exist.") << fullPath;
m_loadingMessages.push_back(m);
return false;
}
package.planes.back().dirNames = dirNames;
package.planes.back().objectName = fileInfo.completeBaseName();
package.planes.back().filePath = fullPath;
package.planes.back().objectVersion = CSLPlane::OBJ8;
if (tokens.size() >= 5)
{

View File

@@ -233,6 +233,16 @@ namespace XSwiftBus
auto err = XPMPMultiplayerLoadCSLPackages(path.c_str());
if (*err) { return err; }
for (int i = 0, end = XPMPGetNumberOfInstalledModels(); i < end; ++i)
{
const char *mixedcase;
XPMPGetModelInfo(i, &mixedcase, nullptr, nullptr, nullptr);
std::string uppercase(mixedcase);
std::transform(uppercase.begin(), uppercase.end(), uppercase.begin(), [](char c) { return static_cast<char>(std::toupper(c)); });
m_modelStrings[uppercase] = mixedcase;
}
return {};
}
@@ -259,13 +269,13 @@ namespace XSwiftBus
if (planeIt != m_planesByCallsign.end()) { return; }
XPMPPlaneID id = nullptr;
if (modelName.empty())
if (modelName.empty() || m_modelStrings.count(modelName) == 0)
{
id = XPMPCreatePlane(aircraftIcao.c_str(), airlineIcao.c_str(), livery.c_str());
}
else
{
id = XPMPCreatePlaneWithModelName(modelName.c_str(), aircraftIcao.c_str(), airlineIcao.c_str(), livery.c_str());
id = XPMPCreatePlaneWithModelName(m_modelStrings[modelName].c_str(), aircraftIcao.c_str(), airlineIcao.c_str(), livery.c_str());
}
if (!id)

View File

@@ -207,6 +207,7 @@ namespace XSwiftBus
static std::string pos2String(const XPLMCameraPosition_t *camPos);
//! @}
std::unordered_map<std::string, std::string> m_modelStrings; // mapping uppercase to mixedcase
std::unordered_map<std::string, Plane *> m_planesByCallsign;
std::unordered_map<void *, Plane *> m_planesById;
std::vector<std::string> m_followPlaneViewSequence;