mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 04:25:42 +08:00
Issue #17 Udjust to model string changes in xplanemp2
This commit is contained in:
@@ -158,8 +158,8 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
QString modelName =
|
QString modelName =
|
||||||
dirNames.join(' ') %
|
dirNames.join(' ') %
|
||||||
u' ' % objectName %
|
u' ' % objectName;
|
||||||
u' ' % textureName;
|
if (objectVersion == OBJ7) { modelName += u' ' % textureName; }
|
||||||
return std::move(modelName).trimmed();
|
return std::move(modelName).trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,6 +514,9 @@ namespace BlackMisc
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
package.planes.back().objectName = tokens[1];
|
||||||
|
package.planes.back().objectVersion = CSLPlane::OBJ8;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,17 +550,8 @@ namespace BlackMisc
|
|||||||
// Remove the last one being the obj itself
|
// Remove the last one being the obj itself
|
||||||
dirNames.removeLast();
|
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().dirNames = dirNames;
|
||||||
package.planes.back().objectName = fileInfo.completeBaseName();
|
|
||||||
package.planes.back().filePath = fullPath;
|
package.planes.back().filePath = fullPath;
|
||||||
package.planes.back().objectVersion = CSLPlane::OBJ8;
|
|
||||||
|
|
||||||
if (tokens.size() >= 5)
|
if (tokens.size() >= 5)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -233,6 +233,16 @@ namespace XSwiftBus
|
|||||||
|
|
||||||
auto err = XPMPMultiplayerLoadCSLPackages(path.c_str());
|
auto err = XPMPMultiplayerLoadCSLPackages(path.c_str());
|
||||||
if (*err) { return err; }
|
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 {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,13 +269,13 @@ namespace XSwiftBus
|
|||||||
if (planeIt != m_planesByCallsign.end()) { return; }
|
if (planeIt != m_planesByCallsign.end()) { return; }
|
||||||
|
|
||||||
XPMPPlaneID id = nullptr;
|
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());
|
id = XPMPCreatePlane(aircraftIcao.c_str(), airlineIcao.c_str(), livery.c_str());
|
||||||
}
|
}
|
||||||
else
|
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)
|
if (!id)
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ namespace XSwiftBus
|
|||||||
static std::string pos2String(const XPLMCameraPosition_t *camPos);
|
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<std::string, Plane *> m_planesByCallsign;
|
||||||
std::unordered_map<void *, Plane *> m_planesById;
|
std::unordered_map<void *, Plane *> m_planesById;
|
||||||
std::vector<std::string> m_followPlaneViewSequence;
|
std::vector<std::string> m_followPlaneViewSequence;
|
||||||
|
|||||||
Reference in New Issue
Block a user