From 19affb6bcd40e4d313906f560dd8ca7541f5faa1 Mon Sep 17 00:00:00 2001 From: Kinglykrab Date: Tue, 15 Oct 2024 19:58:57 -0400 Subject: [PATCH] Update main.cpp --- zone/main.cpp | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/zone/main.cpp b/zone/main.cpp index 2e089394ec..b4cbf289b4 100644 --- a/zone/main.cpp +++ b/zone/main.cpp @@ -714,22 +714,32 @@ void UpdateWindowTitle(char *iNewTitle) bool CheckForCompatibleQuestPlugins() { - std::vector files = { - "quests/plugins/check_handin.pl", - "lua_modules/items.lua", - }; - - bool found = true; - for (const auto &file : files) { - auto f = path.GetServerPath() + "/" + file; - if (File::Exists(f)) { - auto r = File::GetContents(std::filesystem::path{f}.string()); - if (!Strings::Contains(r.contents, "CheckHandin")) { - found = false; - break; + const std::vector& directories = { "lua_modules", "plugins" }; + + bool lua_found = true; + bool perl_found = true; + + for (const auto& directory : directories) { + for (const auto& file : fs::directory_iterator(path.GetServerPath() + "/" + directory)) { + if (file.is_regular_file()) { + auto f = path.GetServerPath() + "/" + file.path().string(); + if (File::Exists(f)) { + auto r = File::GetContents(std::filesystem::path{ f }.string()); + if (!Strings::Contains(r.contents, "CheckHandin")) { + if (Strings::EqualFold(directory, "lua_modules")) { + lua_found = false; + LogError("Failed to find CheckHandin in lua_modules"); + } else if (Strings::EqualFold(directory, "plugins")) { + perl_found = false; + LogError("Failed to find CheckHandin in plugins"); + } + + break; + } + } } } } - return found; + return lua_found && perl_found; }