Make Plugin load order deterministic

fix typo "mResourceServerPath" named "mFolder"

Fix typo number 2
This commit is contained in:
Neptnium 2024-05-07 08:45:58 +02:00 committed by Lion Kortlepel
parent 4d7967d5d9
commit 5ece60574a
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B

View File

@ -360,16 +360,30 @@ void TLuaEngine::CollectAndInitPlugins() {
if (!fs::exists(mResourceServerPath)) {
fs::create_directories(mResourceServerPath);
}
for (const auto& Dir : fs::directory_iterator(mResourceServerPath)) {
std::vector<fs::path> PluginsEntries;
for (const auto& Entry : fs::directory_iterator(mResourceServerPath)) {
if (Entry.is_directory()) {
PluginsEntries.push_back(Entry);
} else {
beammp_error("\"" + Entry.path().string() + "\" is not a directory, skipping");
}
}
std::sort(PluginsEntries.begin(), PluginsEntries.end(), [](const fs::path& first, const fs::path& second) {
auto firstStr = first.string();
auto secondStr = second.string();
std::transform(firstStr.begin(), firstStr.end(), firstStr.begin(), ::tolower);
std::transform(secondStr.begin(), secondStr.end(), secondStr.begin(), ::tolower);
return firstStr < secondStr;
});
for (const auto& Dir : PluginsEntries) {
auto Path = Dir.path();
Path = fs::relative(Path);
if (!Dir.is_directory()) {
beammp_error("\"" + Dir.path().string() + "\" is not a directory, skipping");
} else {
TLuaPluginConfig Config { Path.stem().string() };
FindAndParseConfig(Path, Config);
InitializePlugin(Path, Config);
}
TLuaPluginConfig Config { Path.stem().string() };
FindAndParseConfig(Path, Config);
InitializePlugin(Path, Config);
}
}