diff --git a/CMakeLists.txt b/CMakeLists.txt index 8debe8e9..ccc08398 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1300,6 +1300,7 @@ add_executable(wowee_editor tools/editor/main.cpp tools/editor/cli_gen_audio.cpp tools/editor/cli_zone_packs.cpp + tools/editor/cli_audits.cpp tools/editor/editor_app.cpp tools/editor/editor_camera.cpp tools/editor/editor_viewport.cpp diff --git a/tools/editor/cli_audits.cpp b/tools/editor/cli_audits.cpp new file mode 100644 index 00000000..d059f5e1 --- /dev/null +++ b/tools/editor/cli_audits.cpp @@ -0,0 +1,352 @@ +#include "cli_audits.hpp" + +#include "pipeline/wowee_model.hpp" +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace wowee { +namespace editor { +namespace cli { + +namespace { + +// Walk every direct subdirectory of that contains a +// zone.json. Used by both --validate-project-packs and +// --info-project-deps to enumerate zones. +std::vector enumerateZones(const std::string& projectDir) { + std::vector zones; + namespace fs = std::filesystem; + for (const auto& entry : fs::directory_iterator(projectDir)) { + if (!entry.is_directory()) continue; + if (!fs::exists(entry.path() / "zone.json")) continue; + zones.push_back(entry.path().string()); + } + std::sort(zones.begin(), zones.end()); + return zones; +} + +// Run -- for each zone via subprocess and report +// per-zone PASS/FAIL plus a project rollup. Generic so both +// audits share it. +int runPerZoneAudit(const std::string& projectDir, + const std::string& cmdName, + const std::string& perZoneFlag, + const std::string& selfPath, + const std::string& failHint) { + namespace fs = std::filesystem; + if (!fs::exists(projectDir) || !fs::is_directory(projectDir)) { + std::fprintf(stderr, + "%s: %s is not a directory\n", + cmdName.c_str(), projectDir.c_str()); + return 1; + } + auto zones = enumerateZones(projectDir); + if (zones.empty()) { + std::fprintf(stderr, + "%s: %s contains no zones\n", + cmdName.c_str(), projectDir.c_str()); + return 1; + } + int passed = 0, failed = 0; + std::printf("%s: %s\n", cmdName.c_str(), projectDir.c_str()); + std::printf(" zones: %zu\n\n", zones.size()); + for (const auto& z : zones) { + std::string cmd = "\"" + selfPath + "\" " + perZoneFlag + " \"" + + z + "\" > /dev/null 2>&1"; + int rc = std::system(cmd.c_str()); + std::string name = fs::path(z).filename().string(); + if (rc == 0) { + ++passed; + std::printf(" PASS %s\n", name.c_str()); + } else { + ++failed; + std::printf(" FAIL %s\n", name.c_str()); + } + } + std::printf("\n Total: %d passed, %d failed\n", passed, failed); + if (failed == 0) { + std::printf(" PROJECT PASS\n"); + } else { + std::printf(" PROJECT FAIL%s%s\n", + failHint.empty() ? "" : " — ", + failHint.c_str()); + } + return failed == 0 ? 0 : 1; +} + +int handleZoneDeps(int& i, int argc, char** argv) { + // Broken-reference audit: walk every WOM in the zone, collect + // its texturePaths, and check whether each path resolves to a + // real file via 4 candidate locations (as-is, relative to + // zone, in textures/, alongside the WOM). + std::string zoneDir = argv[++i]; + bool jsonOut = (i + 1 < argc && + std::strcmp(argv[i + 1], "--json") == 0); + if (jsonOut) i++; + namespace fs = std::filesystem; + if (!fs::exists(zoneDir + "/zone.json")) { + std::fprintf(stderr, + "info-zone-deps: %s has no zone.json\n", zoneDir.c_str()); + return 1; + } + struct DepRef { + std::string womPath; + std::string texPath; + bool exists; + }; + std::vector refs; + std::error_code ec; + for (const auto& e : fs::recursive_directory_iterator(zoneDir, ec)) { + if (!e.is_regular_file()) continue; + if (e.path().extension() != ".wom") continue; + std::string womRel = fs::relative(e.path(), zoneDir).string(); + std::string base = e.path().string(); + base = base.substr(0, base.size() - 4); + auto wom = wowee::pipeline::WoweeModelLoader::load(base); + for (const auto& tp : wom.texturePaths) { + if (tp.empty()) continue; + bool found = false; + fs::path candidates[4] = { + fs::path(tp), + fs::path(zoneDir) / tp, + fs::path(zoneDir) / "textures" / fs::path(tp).filename(), + e.path().parent_path() / fs::path(tp).filename(), + }; + for (const auto& c : candidates) { + if (fs::exists(c, ec) && fs::is_regular_file(c, ec)) { + found = true; + break; + } + } + refs.push_back({womRel, tp, found}); + } + } + std::sort(refs.begin(), refs.end(), + [](const DepRef& a, const DepRef& b) { + if (a.exists != b.exists) return !a.exists; + if (a.womPath != b.womPath) return a.womPath < b.womPath; + return a.texPath < b.texPath; + }); + int total = static_cast(refs.size()); + int missing = 0; + for (const auto& r : refs) if (!r.exists) ++missing; + if (jsonOut) { + nlohmann::json j; + j["zone"] = zoneDir; + j["totalRefs"] = total; + j["missingRefs"] = missing; + nlohmann::json arr = nlohmann::json::array(); + for (const auto& r : refs) { + arr.push_back({ + {"wom", r.womPath}, + {"texture", r.texPath}, + {"exists", r.exists}, + }); + } + j["refs"] = arr; + std::printf("%s\n", j.dump(2).c_str()); + return missing == 0 ? 0 : 1; + } + std::printf("Zone deps: %s\n", zoneDir.c_str()); + std::printf(" total refs : %d\n", total); + std::printf(" missing refs : %d\n", missing); + if (refs.empty()) { + std::printf(" *no texture references in any WOM*\n"); + return 0; + } + std::printf("\n exists WOM texture\n"); + for (const auto& r : refs) { + std::printf(" %-6s %-35s %s\n", + r.exists ? "yes" : "NO", + r.womPath.c_str(), + r.texPath.c_str()); + } + std::printf("\n %s\n", missing == 0 + ? "PASS — all texture references resolve" + : "FAIL — missing references above"); + return missing == 0 ? 0 : 1; +} + +int handleValidateZonePack(int& i, int argc, char** argv) { + // Audit a zone's open-format asset pack. Reports counts and + // total bytes per category (textures/, meshes/, audio/) plus + // any malformed WOMs or invalid WAVs. Exit code 1 if any + // check fails — useful in CI to gate that gen-zone-starter-pack + // output is healthy. + std::string zoneDir = argv[++i]; + bool jsonOut = (i + 1 < argc && + std::strcmp(argv[i + 1], "--json") == 0); + if (jsonOut) i++; + namespace fs = std::filesystem; + if (!fs::exists(zoneDir + "/zone.json")) { + std::fprintf(stderr, + "validate-zone-pack: %s has no zone.json\n", zoneDir.c_str()); + return 1; + } + struct CatStats { + int count = 0; + uint64_t bytes = 0; + int invalid = 0; + std::vector invalidPaths; + }; + CatStats tex, mesh, audio; + std::error_code ec; + // Textures: PNGs under textures/ (8-byte signature check) + fs::path texDir = fs::path(zoneDir) / "textures"; + if (fs::exists(texDir)) { + for (const auto& e : fs::recursive_directory_iterator(texDir, ec)) { + if (!e.is_regular_file()) continue; + if (e.path().extension() != ".png") continue; + tex.count++; + tex.bytes += e.file_size(); + FILE* f = std::fopen(e.path().c_str(), "rb"); + if (f) { + unsigned char sig[8]; + bool ok = (std::fread(sig, 1, 8, f) == 8 && + sig[0] == 0x89 && sig[1] == 'P' && + sig[2] == 'N' && sig[3] == 'G'); + std::fclose(f); + if (!ok) { + tex.invalid++; + tex.invalidPaths.push_back( + fs::relative(e.path(), zoneDir).string()); + } + } + } + } + // Meshes: WOMs under meshes/ (load & sanity check) + fs::path meshDir = fs::path(zoneDir) / "meshes"; + if (fs::exists(meshDir)) { + for (const auto& e : fs::recursive_directory_iterator(meshDir, ec)) { + if (!e.is_regular_file()) continue; + if (e.path().extension() != ".wom") continue; + mesh.count++; + mesh.bytes += e.file_size(); + std::string base = e.path().string(); + base = base.substr(0, base.size() - 4); + auto wom = wowee::pipeline::WoweeModelLoader::load(base); + if (wom.vertices.empty() || wom.indices.empty() || + wom.batches.empty()) { + mesh.invalid++; + mesh.invalidPaths.push_back( + fs::relative(e.path(), zoneDir).string()); + } + } + } + // Audio: WAVs under audio/ (RIFF header check) + fs::path audDir = fs::path(zoneDir) / "audio"; + if (fs::exists(audDir)) { + for (const auto& e : fs::recursive_directory_iterator(audDir, ec)) { + if (!e.is_regular_file()) continue; + if (e.path().extension() != ".wav") continue; + audio.count++; + audio.bytes += e.file_size(); + FILE* f = std::fopen(e.path().c_str(), "rb"); + if (f) { + char hdr[12]; + bool ok = (std::fread(hdr, 1, 12, f) == 12 && + std::memcmp(hdr, "RIFF", 4) == 0 && + std::memcmp(hdr + 8, "WAVE", 4) == 0); + std::fclose(f); + if (!ok) { + audio.invalid++; + audio.invalidPaths.push_back( + fs::relative(e.path(), zoneDir).string()); + } + } + } + } + int totalCount = tex.count + mesh.count + audio.count; + int totalInvalid = tex.invalid + mesh.invalid + audio.invalid; + uint64_t totalBytes = tex.bytes + mesh.bytes + audio.bytes; + bool pass = (totalInvalid == 0 && totalCount > 0); + if (jsonOut) { + auto catJ = [](const CatStats& c) { + return nlohmann::json{ + {"count", c.count}, + {"bytes", c.bytes}, + {"invalid", c.invalid}, + {"invalidPaths", c.invalidPaths}, + }; + }; + nlohmann::json j; + j["zone"] = zoneDir; + j["pass"] = pass; + j["totalCount"] = totalCount; + j["totalBytes"] = totalBytes; + j["totalInvalid"] = totalInvalid; + j["textures"] = catJ(tex); + j["meshes"] = catJ(mesh); + j["audio"] = catJ(audio); + std::printf("%s\n", j.dump(2).c_str()); + return pass ? 0 : 1; + } + std::printf("Zone pack audit: %s\n", zoneDir.c_str()); + std::printf("\n category count bytes invalid\n"); + std::printf(" textures %5d %7llu %7d\n", + tex.count, + static_cast(tex.bytes), + tex.invalid); + std::printf(" meshes %5d %7llu %7d\n", + mesh.count, + static_cast(mesh.bytes), + mesh.invalid); + std::printf(" audio %5d %7llu %7d\n", + audio.count, + static_cast(audio.bytes), + audio.invalid); + std::printf(" ----------------------------------\n"); + std::printf(" TOTAL %5d %7llu %7d\n", + totalCount, + static_cast(totalBytes), + totalInvalid); + for (const auto* cat : { &tex, &mesh, &audio }) { + for (const auto& p : cat->invalidPaths) { + std::printf(" INVALID %s\n", p.c_str()); + } + } + std::printf("\n %s\n", pass ? "PASS — pack is healthy" + : "FAIL — see invalid paths above"); + return pass ? 0 : 1; +} + +} // namespace + +bool handleAudits(int& i, int argc, char** argv, int& outRc) { + if (std::strcmp(argv[i], "--info-zone-deps") == 0 && i + 1 < argc) { + outRc = handleZoneDeps(i, argc, argv); + return true; + } + if (std::strcmp(argv[i], "--info-project-deps") == 0 && i + 1 < argc) { + std::string projectDir = argv[++i]; + std::string self = (argc > 0) ? argv[0] : "wowee_editor"; + outRc = runPerZoneAudit(projectDir, "Project deps", + "--info-zone-deps", self, + "re-run --info-zone-deps on FAILing zones for detail"); + return true; + } + if (std::strcmp(argv[i], "--validate-zone-pack") == 0 && i + 1 < argc) { + outRc = handleValidateZonePack(i, argc, argv); + return true; + } + if (std::strcmp(argv[i], "--validate-project-packs") == 0 && i + 1 < argc) { + std::string projectDir = argv[++i]; + std::string self = (argc > 0) ? argv[0] : "wowee_editor"; + outRc = runPerZoneAudit(projectDir, "Project pack audit", + "--validate-zone-pack", self, ""); + return true; + } + return false; +} + +} // namespace cli +} // namespace editor +} // namespace wowee diff --git a/tools/editor/cli_audits.hpp b/tools/editor/cli_audits.hpp new file mode 100644 index 00000000..eb2744e7 --- /dev/null +++ b/tools/editor/cli_audits.hpp @@ -0,0 +1,19 @@ +#pragma once + +namespace wowee { +namespace editor { +namespace cli { + +// Dispatch the four audit / dep-check handlers: +// --validate-zone-pack +// --validate-project-packs +// --info-zone-deps +// --info-project-deps +// +// Returns true if matched; outRc holds the exit code. Returns +// false if no match — caller should continue its dispatch chain. +bool handleAudits(int& i, int argc, char** argv, int& outRc); + +} // namespace cli +} // namespace editor +} // namespace wowee diff --git a/tools/editor/main.cpp b/tools/editor/main.cpp index 15f1ce98..6d30ece8 100644 --- a/tools/editor/main.cpp +++ b/tools/editor/main.cpp @@ -1,6 +1,7 @@ #include "editor_app.hpp" #include "cli_gen_audio.hpp" #include "cli_zone_packs.hpp" +#include "cli_audits.hpp" #include "content_pack.hpp" #include "npc_spawner.hpp" #include "object_placer.hpp" @@ -1369,6 +1370,9 @@ int main(int argc, char* argv[]) { if (wowee::editor::cli::handleZonePacks(i, argc, argv, outRc)) { return outRc; } + if (wowee::editor::cli::handleAudits(i, argc, argv, outRc)) { + return outRc; + } } if (std::strcmp(argv[i], "--data") == 0 && i + 1 < argc) { dataPath = argv[++i]; @@ -14482,154 +14486,6 @@ int main(int argc, char* argv[]) { totalAssets, static_cast(totalBytes)); return 0; - } else if (std::strcmp(argv[i], "--info-zone-deps") == 0 && i + 1 < argc) { - // Broken-reference audit: walk every WOM in the zone, - // collect its texturePaths, normalize them, and check - // whether each path exists relative to the zone dir. - // Reports any reference that does NOT resolve to a real - // file. Catches "WOM was added but its texture wasn't - // copied into textures/" mistakes before runtime. - std::string zoneDir = argv[++i]; - bool jsonOut = (i + 1 < argc && - std::strcmp(argv[i + 1], "--json") == 0); - if (jsonOut) i++; - namespace fs = std::filesystem; - if (!fs::exists(zoneDir + "/zone.json")) { - std::fprintf(stderr, - "info-zone-deps: %s has no zone.json\n", zoneDir.c_str()); - return 1; - } - // For each WOM, list (wom path, texture path, exists?). - // A texture path resolves if any of the candidate paths - // resolves: as-is, relative to zone dir, relative to - // zone/textures/, or with the basename matched in - // textures/. - struct DepRef { - std::string womPath; - std::string texPath; - bool exists; - }; - std::vector refs; - std::error_code ec; - for (const auto& e : fs::recursive_directory_iterator(zoneDir, ec)) { - if (!e.is_regular_file()) continue; - if (e.path().extension() != ".wom") continue; - std::string womRel = fs::relative(e.path(), zoneDir).string(); - std::string base = e.path().string(); - base = base.substr(0, base.size() - 4); - auto wom = wowee::pipeline::WoweeModelLoader::load(base); - for (const auto& tp : wom.texturePaths) { - if (tp.empty()) continue; - bool found = false; - fs::path candidates[4] = { - fs::path(tp), - fs::path(zoneDir) / tp, - fs::path(zoneDir) / "textures" / fs::path(tp).filename(), - e.path().parent_path() / fs::path(tp).filename(), - }; - for (const auto& c : candidates) { - if (fs::exists(c, ec) && fs::is_regular_file(c, ec)) { - found = true; - break; - } - } - refs.push_back({womRel, tp, found}); - } - } - std::sort(refs.begin(), refs.end(), - [](const DepRef& a, const DepRef& b) { - if (a.exists != b.exists) return !a.exists; - if (a.womPath != b.womPath) return a.womPath < b.womPath; - return a.texPath < b.texPath; - }); - int total = static_cast(refs.size()); - int missing = 0; - for (const auto& r : refs) if (!r.exists) ++missing; - if (jsonOut) { - nlohmann::json j; - j["zone"] = zoneDir; - j["totalRefs"] = total; - j["missingRefs"] = missing; - nlohmann::json arr = nlohmann::json::array(); - for (const auto& r : refs) { - arr.push_back({ - {"wom", r.womPath}, - {"texture", r.texPath}, - {"exists", r.exists}, - }); - } - j["refs"] = arr; - std::printf("%s\n", j.dump(2).c_str()); - return missing == 0 ? 0 : 1; - } - std::printf("Zone deps: %s\n", zoneDir.c_str()); - std::printf(" total refs : %d\n", total); - std::printf(" missing refs : %d\n", missing); - if (refs.empty()) { - std::printf(" *no texture references in any WOM*\n"); - return 0; - } - std::printf("\n exists WOM texture\n"); - for (const auto& r : refs) { - std::printf(" %-6s %-35s %s\n", - r.exists ? "yes" : "NO", - r.womPath.c_str(), - r.texPath.c_str()); - } - std::printf("\n %s\n", missing == 0 - ? "PASS — all texture references resolve" - : "FAIL — missing references above"); - return missing == 0 ? 0 : 1; - } else if (std::strcmp(argv[i], "--info-project-deps") == 0 && i + 1 < argc) { - // Run --info-zone-deps across every zone in a project - // and roll up per-zone PASS/FAIL plus a project total. - // Designed as a CI gate: exits non-zero if any zone has - // a broken texture reference. Lighter than re-implementing - // the dep walk here — defers to the per-zone command via - // subprocess so the resolution logic stays consistent. - std::string projectDir = argv[++i]; - namespace fs = std::filesystem; - if (!fs::exists(projectDir) || !fs::is_directory(projectDir)) { - std::fprintf(stderr, - "info-project-deps: %s is not a directory\n", - projectDir.c_str()); - return 1; - } - std::vector zones; - for (const auto& entry : fs::directory_iterator(projectDir)) { - if (!entry.is_directory()) continue; - if (!fs::exists(entry.path() / "zone.json")) continue; - zones.push_back(entry.path().string()); - } - std::sort(zones.begin(), zones.end()); - if (zones.empty()) { - std::fprintf(stderr, - "info-project-deps: %s contains no zones\n", - projectDir.c_str()); - return 1; - } - std::string self = (argc > 0) ? argv[0] : "wowee_editor"; - int passed = 0, failed = 0; - std::printf("Project deps: %s\n", projectDir.c_str()); - std::printf(" zones: %zu\n\n", zones.size()); - for (const auto& z : zones) { - std::string cmd = "\"" + self + "\" --info-zone-deps \"" + - z + "\" > /dev/null 2>&1"; - int rc = std::system(cmd.c_str()); - std::string name = fs::path(z).filename().string(); - if (rc == 0) { - ++passed; - std::printf(" PASS %s\n", name.c_str()); - } else { - ++failed; - std::printf(" FAIL %s\n", name.c_str()); - } - } - std::printf("\n Total: %d passed, %d failed\n", passed, failed); - std::printf(" %s\n", - failed == 0 ? "PROJECT PASS" - : "PROJECT FAIL — re-run --info-zone-deps on FAILing zones for detail"); - return failed == 0 ? 0 : 1; } else if (std::strcmp(argv[i], "--info-project-summary") == 0 && i + 1 < argc) { // Project-wide companion to --info-zone-summary. Walks // every zone in and reports a per-zone @@ -15045,196 +14901,6 @@ int main(int argc, char* argv[]) { std::printf(" total bytes : %llu\n", static_cast(totalBytes)); return 0; - } else if (std::strcmp(argv[i], "--validate-zone-pack") == 0 && i + 1 < argc) { - // Audit a zone's open-format asset pack. Reports counts - // and total bytes per category (textures/, meshes/, - // audio/) plus any malformed WOMs or invalid WAVs. - // Exit code 1 if any check fails — useful in CI to - // gate that gen-zone-starter-pack output is healthy. - std::string zoneDir = argv[++i]; - bool jsonOut = (i + 1 < argc && - std::strcmp(argv[i + 1], "--json") == 0); - if (jsonOut) i++; - namespace fs = std::filesystem; - if (!fs::exists(zoneDir + "/zone.json")) { - std::fprintf(stderr, - "validate-zone-pack: %s has no zone.json\n", zoneDir.c_str()); - return 1; - } - struct CatStats { - int count = 0; - uint64_t bytes = 0; - int invalid = 0; - std::vector invalidPaths; - }; - CatStats tex, mesh, audio; - std::error_code ec; - // Textures: PNGs under textures/ - fs::path texDir = fs::path(zoneDir) / "textures"; - if (fs::exists(texDir)) { - for (const auto& e : fs::recursive_directory_iterator(texDir, ec)) { - if (!e.is_regular_file()) continue; - if (e.path().extension() != ".png") continue; - tex.count++; - tex.bytes += e.file_size(); - // Quick PNG signature check (8 bytes) - FILE* f = std::fopen(e.path().c_str(), "rb"); - if (f) { - unsigned char sig[8]; - bool ok = (std::fread(sig, 1, 8, f) == 8 && - sig[0] == 0x89 && sig[1] == 'P' && - sig[2] == 'N' && sig[3] == 'G'); - std::fclose(f); - if (!ok) { - tex.invalid++; - tex.invalidPaths.push_back( - fs::relative(e.path(), zoneDir).string()); - } - } - } - } - // Meshes: WOMs under meshes/ — load & sanity check - fs::path meshDir = fs::path(zoneDir) / "meshes"; - if (fs::exists(meshDir)) { - for (const auto& e : fs::recursive_directory_iterator(meshDir, ec)) { - if (!e.is_regular_file()) continue; - if (e.path().extension() != ".wom") continue; - mesh.count++; - mesh.bytes += e.file_size(); - std::string base = e.path().string(); - base = base.substr(0, base.size() - 4); - auto wom = wowee::pipeline::WoweeModelLoader::load(base); - if (wom.vertices.empty() || wom.indices.empty() || - wom.batches.empty()) { - mesh.invalid++; - mesh.invalidPaths.push_back( - fs::relative(e.path(), zoneDir).string()); - } - } - } - // Audio: WAVs under audio/ — RIFF header check - fs::path audDir = fs::path(zoneDir) / "audio"; - if (fs::exists(audDir)) { - for (const auto& e : fs::recursive_directory_iterator(audDir, ec)) { - if (!e.is_regular_file()) continue; - if (e.path().extension() != ".wav") continue; - audio.count++; - audio.bytes += e.file_size(); - FILE* f = std::fopen(e.path().c_str(), "rb"); - if (f) { - char hdr[12]; - bool ok = (std::fread(hdr, 1, 12, f) == 12 && - std::memcmp(hdr, "RIFF", 4) == 0 && - std::memcmp(hdr + 8, "WAVE", 4) == 0); - std::fclose(f); - if (!ok) { - audio.invalid++; - audio.invalidPaths.push_back( - fs::relative(e.path(), zoneDir).string()); - } - } - } - } - int totalCount = tex.count + mesh.count + audio.count; - int totalInvalid = tex.invalid + mesh.invalid + audio.invalid; - uint64_t totalBytes = tex.bytes + mesh.bytes + audio.bytes; - bool pass = (totalInvalid == 0 && totalCount > 0); - if (jsonOut) { - auto catJ = [](const CatStats& c) { - return nlohmann::json{ - {"count", c.count}, - {"bytes", c.bytes}, - {"invalid", c.invalid}, - {"invalidPaths", c.invalidPaths}, - }; - }; - nlohmann::json j; - j["zone"] = zoneDir; - j["pass"] = pass; - j["totalCount"] = totalCount; - j["totalBytes"] = totalBytes; - j["totalInvalid"] = totalInvalid; - j["textures"] = catJ(tex); - j["meshes"] = catJ(mesh); - j["audio"] = catJ(audio); - std::printf("%s\n", j.dump(2).c_str()); - return pass ? 0 : 1; - } - std::printf("Zone pack audit: %s\n", zoneDir.c_str()); - std::printf("\n category count bytes invalid\n"); - std::printf(" textures %5d %7llu %7d\n", - tex.count, - static_cast(tex.bytes), - tex.invalid); - std::printf(" meshes %5d %7llu %7d\n", - mesh.count, - static_cast(mesh.bytes), - mesh.invalid); - std::printf(" audio %5d %7llu %7d\n", - audio.count, - static_cast(audio.bytes), - audio.invalid); - std::printf(" ----------------------------------\n"); - std::printf(" TOTAL %5d %7llu %7d\n", - totalCount, - static_cast(totalBytes), - totalInvalid); - for (const auto* cat : { &tex, &mesh, &audio }) { - for (const auto& p : cat->invalidPaths) { - std::printf(" INVALID %s\n", p.c_str()); - } - } - std::printf("\n %s\n", pass ? "PASS — pack is healthy" - : "FAIL — see invalid paths above"); - return pass ? 0 : 1; - } else if (std::strcmp(argv[i], "--validate-project-packs") == 0 && i + 1 < argc) { - // Run --validate-zone-pack across every zone in a project - // and aggregate the result. Reports a single PASS/FAIL - // line per zone plus a summary; exits non-zero if any - // zone fails. Designed for CI use as a gate before - // shipping a project. - std::string projectDir = argv[++i]; - namespace fs = std::filesystem; - if (!fs::exists(projectDir) || !fs::is_directory(projectDir)) { - std::fprintf(stderr, - "validate-project-packs: %s is not a directory\n", - projectDir.c_str()); - return 1; - } - std::vector zones; - for (const auto& entry : fs::directory_iterator(projectDir)) { - if (!entry.is_directory()) continue; - if (!fs::exists(entry.path() / "zone.json")) continue; - zones.push_back(entry.path().string()); - } - std::sort(zones.begin(), zones.end()); - if (zones.empty()) { - std::fprintf(stderr, - "validate-project-packs: %s contains no zones\n", - projectDir.c_str()); - return 1; - } - std::string self = (argc > 0) ? argv[0] : "wowee_editor"; - int passed = 0, failed = 0; - std::printf("Project pack audit: %s\n", projectDir.c_str()); - std::printf(" zones: %zu\n\n", zones.size()); - for (const auto& z : zones) { - std::string cmd = "\"" + self + "\" --validate-zone-pack \"" + - z + "\" > /dev/null 2>&1"; - int rc = std::system(cmd.c_str()); - std::string name = fs::path(z).filename().string(); - if (rc == 0) { - ++passed; - std::printf(" PASS %s\n", name.c_str()); - } else { - ++failed; - std::printf(" FAIL %s\n", name.c_str()); - } - } - std::printf("\n Total: %d passed, %d failed\n", passed, failed); - std::printf(" %s\n", - failed == 0 ? "PROJECT PASS" : "PROJECT FAIL"); - return failed == 0 ? 0 : 1; } else if (std::strcmp(argv[i], "--gen-random-project") == 0 && i + 1 < argc) { // Project-wide companion: spawn N random zones in one // pass. Names default to "Zone1, Zone2..."; tile