From 987dc81f13d90d634981a13025bfbc54ebd6b309 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 11:16:08 -0700 Subject: [PATCH] feat(editor): --list-zones --json for machine-readable zone discovery Adds JSON mode to the zone discovery scanner. Returns an array of zone objects, each with name/dir/mapId/author/description/tiles/ hasCreatures/hasQuests. Lets CI scripts iterate every available zone and run a per-zone gate, e.g.: for zone in $(wowee_editor --list-zones --json | jq -r '.[].directory'); do wowee_editor --validate "$zone" --json | jq -e '.score == 7' done Fifth and last commonly-used inspector to gain --json mode (after --info-extract, --validate, --info-wcp, --zone-summary). --- tools/editor/main.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/editor/main.cpp b/tools/editor/main.cpp index 2b30897d..fc81dcf1 100644 --- a/tools/editor/main.cpp +++ b/tools/editor/main.cpp @@ -30,7 +30,7 @@ static void printUsage(const char* argv0) { std::printf(" --adt Load an ADT tile on startup\n"); std::printf(" --convert-m2 Convert M2 model to WOM open format (no GUI)\n"); std::printf(" --convert-wmo Convert WMO building to WOB open format (no GUI)\n"); - std::printf(" --list-zones List discovered custom zones and exit\n"); + std::printf(" --list-zones [--json] List discovered custom zones and exit\n"); std::printf(" --scaffold-zone [tx ty] Create a blank zone in custom_zones// and exit\n"); std::printf(" --build-woc Generate a WOC collision mesh from WHM/WOT and exit\n"); std::printf(" --regen-collision Rebuild every WOC under a zone dir and exit\n"); @@ -1000,7 +1000,30 @@ int main(int argc, char* argv[]) { std::printf("WCP unpacked to: %s\n", destDir.c_str()); return 0; } else if (std::strcmp(argv[i], "--list-zones") == 0) { + // Optional --json after the flag for machine-readable output. + bool jsonOut = (i + 1 < argc && + std::strcmp(argv[i + 1], "--json") == 0); + if (jsonOut) i++; auto zones = wowee::pipeline::CustomZoneDiscovery::scan({"custom_zones", "output"}); + if (jsonOut) { + nlohmann::json j = nlohmann::json::array(); + for (const auto& z : zones) { + nlohmann::json zoneObj; + zoneObj["name"] = z.name; + zoneObj["directory"] = z.directory; + zoneObj["mapId"] = z.mapId; + zoneObj["author"] = z.author; + zoneObj["description"] = z.description; + zoneObj["hasCreatures"] = z.hasCreatures; + zoneObj["hasQuests"] = z.hasQuests; + nlohmann::json tiles = nlohmann::json::array(); + for (const auto& t : z.tiles) tiles.push_back({t.first, t.second}); + zoneObj["tiles"] = tiles; + j.push_back(std::move(zoneObj)); + } + std::printf("%s\n", j.dump(2).c_str()); + return 0; + } if (zones.empty()) { std::printf("No custom zones found in custom_zones/ or output/\n"); } else {