mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
[xSwiftBus] Automatically find and load CSL packages
ref T657
This commit is contained in:
committed by
Klaus Basan
parent
a7509669f9
commit
61adfefa7a
@@ -85,6 +85,12 @@ namespace XSwiftBus
|
||||
{
|
||||
if (! s_legacyDataOK) { return false; }
|
||||
|
||||
findAllCslPackages(g_xplanePath);
|
||||
for (const auto &package : m_cslPackages)
|
||||
{
|
||||
loadPlanesPackage(package);
|
||||
}
|
||||
|
||||
if (! m_initialized)
|
||||
{
|
||||
auto err = XPMPMultiplayerInit(preferences, preferences);
|
||||
@@ -139,6 +145,34 @@ namespace XSwiftBus
|
||||
}
|
||||
}
|
||||
|
||||
void CTraffic::findAllCslPackages(const std::string &path)
|
||||
{
|
||||
char nameBuffer[65536];
|
||||
char *indices[4096];
|
||||
int returnedFiles;
|
||||
int totalFiles;
|
||||
|
||||
// Remove trailing /
|
||||
std::string dir = path.substr(0, path.size() - 1);
|
||||
XPLMGetDirectoryContents(dir.c_str(), 0, nameBuffer, sizeof(nameBuffer), indices, sizeof(indices) / sizeof(char*), &totalFiles, &returnedFiles);
|
||||
for (int i = 0; i < returnedFiles; i++)
|
||||
{
|
||||
std::string fileName(indices[i]);
|
||||
if (fileName == "xsb_aircraft.txt")
|
||||
{
|
||||
const std::string seperator = "/\\";
|
||||
const std::size_t sepPos = dir.find_last_of(seperator);
|
||||
std::string parentPath = dir.substr(0, sepPos);
|
||||
m_cslPackages.insert(parentPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string filePath(path + fileName + g_sep);
|
||||
findAllCslPackages(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CTraffic::emitSimFrame()
|
||||
{
|
||||
if (m_emitSimFrame) { sendDBusSignal("simFrame"); }
|
||||
@@ -526,16 +560,6 @@ namespace XSwiftBus
|
||||
cleanup();
|
||||
});
|
||||
}
|
||||
else if (message.getMethodName() == "loadPlanesPackage")
|
||||
{
|
||||
std::string path;
|
||||
message.beginArgumentRead();
|
||||
message.getArgument(path);
|
||||
queueDBusCall([ = ]()
|
||||
{
|
||||
sendDBusReply(sender, serial, loadPlanesPackage(path));
|
||||
});
|
||||
}
|
||||
else if (message.getMethodName() == "setDefaultIcao")
|
||||
{
|
||||
std::string defaultIcao;
|
||||
|
||||
Reference in New Issue
Block a user