mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
Issue #17 Udjust to model string changes in xplanemp2
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user