Skip to content

Commit

Permalink
Fixed twice listing plugin files.
Browse files Browse the repository at this point in the history
  • Loading branch information
MiranDMC committed Jun 15, 2024
1 parent 9dfd475 commit 7c4de2f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions source/CPluginSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,19 @@ void CPluginSystem::LoadPlugins()

for (DWORD i = 0; i < files.count; i++)
{
if (std::find(filenames.begin(), filenames.end(), files.strings[i]) != filenames.end())
continue; // file already listed

auto name = FS::path(files.strings[i]).filename().string();
name = name.substr(prefix.length()); // cut off prefix
name.resize(name.length() - extension.length()); // cut off extension
std::transform(name.begin(), name.end(), name.begin(), [](unsigned char c) { return std::toupper(c); });

if (names.find(name) == names.end())
// case insensitive search in already listed plugin names
auto found = std::find_if(names.begin(), names.end(), [&](const std::string& s) {
return _stricmp(s.c_str(), name.c_str()) == 0;
});

if (found == names.end())
{
names.insert(name);
filenames.emplace_back(files.strings[i]);
Expand All @@ -53,7 +60,7 @@ void CPluginSystem::LoadPlugins()
// reverse order, so opcodes from CLEO5 plugins can overwrite opcodes from legacy plugins
if (!filenames.empty())
{
for (auto it = filenames.crbegin(); it < filenames.crend(); it++)
for (auto it = filenames.crbegin(); it != filenames.crend(); it++)
{
const auto filename = it->c_str();
TRACE("Loading plugin '%s'", filename);
Expand Down

0 comments on commit 7c4de2f

Please sign in to comment.