mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-01 23:35:41 +00:00
Make Plugin load order deterministic
fix typo "mResourceServerPath" named "mFolder" Fix typo number 2
This commit is contained in:
parent
4d7967d5d9
commit
5ece60574a
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user