#include "pipeline/custom_zone_discovery.hpp" #include "core/logger.hpp" #include #include namespace wowee { namespace pipeline { std::vector CustomZoneDiscovery::scan(const std::vector& searchPaths) { std::vector results; for (const auto& path : searchPaths) { auto found = scanDirectory(path); results.insert(results.end(), found.begin(), found.end()); } return results; } std::vector CustomZoneDiscovery::scanDirectory(const std::string& path) { namespace fs = std::filesystem; std::vector results; if (!fs::exists(path)) return results; for (auto& entry : fs::directory_iterator(path)) { if (!entry.is_directory()) continue; std::string zoneJson = entry.path().string() + "/zone.json"; if (!fs::exists(zoneJson)) continue; std::ifstream f(zoneJson); if (!f) continue; std::string content((std::istreambuf_iterator(f)), std::istreambuf_iterator()); auto findStr = [&](const std::string& key) -> std::string { auto pos = content.find("\"" + key + "\""); if (pos == std::string::npos) return ""; pos = content.find('"', content.find(':', pos) + 1); if (pos == std::string::npos) return ""; auto end = content.find('"', pos + 1); return content.substr(pos + 1, end - pos - 1); }; CustomZoneInfo info; info.name = findStr("mapName"); if (info.name.empty()) info.name = findStr("name"); info.author = findStr("author"); info.description = findStr("description"); info.directory = entry.path().string(); info.hasCreatures = fs::exists(entry.path().string() + "/creatures.json"); info.hasQuests = fs::exists(entry.path().string() + "/quests.json"); if (!info.name.empty()) { results.push_back(info); LOG_INFO("Discovered custom zone: ", info.name, " in ", info.directory); } } return results; } } // namespace pipeline } // namespace wowee