From f66b8607d3ae3558d10164298e24387507bd2552 Mon Sep 17 00:00:00 2001 From: Nazwadi <8131324+nazwadi@users.noreply.github.com> Date: Sun, 7 Jun 2026 12:50:25 -0400 Subject: [PATCH] Fix CheckForCompatibleQuestPlugins to use config-driven directory paths (#5097) --- zone/main.cpp | 52 ++++++++++++++++++++------------------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/zone/main.cpp b/zone/main.cpp index 9aab5adf8..e3ebb1959 100644 --- a/zone/main.cpp +++ b/zone/main.cpp @@ -711,48 +711,36 @@ void UpdateWindowTitle(char *iNewTitle) bool CheckForCompatibleQuestPlugins() { - const std::vector> directories = { - {"lua_modules", nullptr}, - {"plugins", nullptr} - }; - bool lua_found = false; bool perl_found = false; - try { - for (const auto &[directory, flag]: directories) { - std::string dir_path = PathManager::Instance()->GetServerPath() + "/" + directory; - if (!File::Exists(dir_path)) { continue; } - - for (const auto &file: fs::directory_iterator(dir_path)) { + auto check_dir = [&](const std::string& dir_path, bool& found) { + if (!File::Exists(dir_path)) { return; } + try { + for (const auto& file : fs::directory_iterator(dir_path)) { if (!file.is_regular_file()) { continue; } - - std::string file_path = file.path().string(); - if (!File::Exists(file_path)) { continue; } - - auto r = File::GetContents(file_path); - if (!Strings::Contains(r.contents, "CheckHandin")) { continue; } - - if (directory == "lua_modules") { - lua_found = true; + auto r = File::GetContents(file.path().string()); + if (Strings::Contains(r.contents, "CheckHandin")) { + found = true; + return; } - else { - perl_found = true; - } - - if (lua_found && perl_found) { return true; } } } - } catch (const fs::filesystem_error &ex) { - LogError("Failed to check for compatible quest plugins: {}", ex.what()); + catch (const fs::filesystem_error& ex) { + LogError("Failed to check for compatible quest plugins: {}", ex.what()); + } + }; + + for (const auto& path : PathManager::Instance()->GetLuaModulePaths()) { + check_dir(path, lua_found); } - if (!lua_found) { - LogError("Failed to find CheckHandin in lua_modules"); - } - if (!perl_found) { - LogError("Failed to find CheckHandin in plugins"); + for (const auto& path : PathManager::Instance()->GetPluginPaths()) { + check_dir(path, perl_found); } + if (!lua_found) { LogError("Failed to find CheckHandin in the Lua module quest directories"); } + if (!perl_found) { LogError("Failed to find CheckHandin in the Perl plugins quest directories");} + return lua_found && perl_found; }