mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-24 17:48:20 +00:00
Fix CheckForCompatibleQuestPlugins to use config-driven directory paths (#5097)
This commit is contained in:
+20
-32
@@ -711,48 +711,36 @@ void UpdateWindowTitle(char *iNewTitle)
|
|||||||
|
|
||||||
bool CheckForCompatibleQuestPlugins()
|
bool CheckForCompatibleQuestPlugins()
|
||||||
{
|
{
|
||||||
const std::vector<std::pair<std::string, bool *>> directories = {
|
|
||||||
{"lua_modules", nullptr},
|
|
||||||
{"plugins", nullptr}
|
|
||||||
};
|
|
||||||
|
|
||||||
bool lua_found = false;
|
bool lua_found = false;
|
||||||
bool perl_found = false;
|
bool perl_found = false;
|
||||||
|
|
||||||
try {
|
auto check_dir = [&](const std::string& dir_path, bool& found) {
|
||||||
for (const auto &[directory, flag]: directories) {
|
if (!File::Exists(dir_path)) { return; }
|
||||||
std::string dir_path = PathManager::Instance()->GetServerPath() + "/" + directory;
|
try {
|
||||||
if (!File::Exists(dir_path)) { continue; }
|
for (const auto& file : fs::directory_iterator(dir_path)) {
|
||||||
|
|
||||||
for (const auto &file: fs::directory_iterator(dir_path)) {
|
|
||||||
if (!file.is_regular_file()) { continue; }
|
if (!file.is_regular_file()) { continue; }
|
||||||
|
auto r = File::GetContents(file.path().string());
|
||||||
std::string file_path = file.path().string();
|
if (Strings::Contains(r.contents, "CheckHandin")) {
|
||||||
if (!File::Exists(file_path)) { continue; }
|
found = true;
|
||||||
|
return;
|
||||||
auto r = File::GetContents(file_path);
|
|
||||||
if (!Strings::Contains(r.contents, "CheckHandin")) { continue; }
|
|
||||||
|
|
||||||
if (directory == "lua_modules") {
|
|
||||||
lua_found = true;
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
perl_found = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lua_found && perl_found) { return true; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (const fs::filesystem_error &ex) {
|
catch (const fs::filesystem_error& ex) {
|
||||||
LogError("Failed to check for compatible quest plugins: {}", ex.what());
|
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) {
|
for (const auto& path : PathManager::Instance()->GetPluginPaths()) {
|
||||||
LogError("Failed to find CheckHandin in lua_modules");
|
check_dir(path, perl_found);
|
||||||
}
|
|
||||||
if (!perl_found) {
|
|
||||||
LogError("Failed to find CheckHandin in plugins");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
return lua_found && perl_found;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user