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

@@ -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;