From 5ece60574a98f19ce120b0a5e33c2a70eea468c8 Mon Sep 17 00:00:00 2001 From: Neptnium <46964341+Neptnium@users.noreply.github.com> Date: Tue, 7 May 2024 08:45:58 +0200 Subject: [PATCH 1/2] Make Plugin load order deterministic fix typo "mResourceServerPath" named "mFolder" Fix typo number 2 --- src/TLuaEngine.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/TLuaEngine.cpp b/src/TLuaEngine.cpp index 031e5cc..f3e987c 100644 --- a/src/TLuaEngine.cpp +++ b/src/TLuaEngine.cpp @@ -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 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); } } From 40158dc25273daa8b2283773ced9e5a7db8e2511 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Wed, 8 May 2024 11:21:38 +0200 Subject: [PATCH 2/2] fix compile error --- src/TLuaEngine.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/TLuaEngine.cpp b/src/TLuaEngine.cpp index f3e987c..b16f283 100644 --- a/src/TLuaEngine.cpp +++ b/src/TLuaEngine.cpp @@ -379,8 +379,7 @@ void TLuaEngine::CollectAndInitPlugins() { }); for (const auto& Dir : PluginsEntries) { - auto Path = Dir.path(); - Path = fs::relative(Path); + auto Path = fs::relative(Dir); TLuaPluginConfig Config { Path.stem().string() }; FindAndParseConfig(Path, Config); InitializePlugin(Path, Config);