feat(validate): report file counts and per-format invalid totals

The previous --validate output told you whether *some* file of each
type existed, which was hard to act on for partially-valid zones.
Now reports the per-format file count and how many failed magic
validation, e.g. 'WOM (12 invalid: 2)' so a zone author can spot
missing or corrupted models without grepping through file listings.
This commit is contained in:
Kelsi 2026-05-06 07:12:04 -07:00
parent 7e2dc4ec1d
commit 5af4bba556
3 changed files with 35 additions and 19 deletions

View file

@ -277,25 +277,28 @@ ContentPacker::ValidationResult ContentPacker::validateZone(const std::string& z
if (!entry.is_regular_file()) continue;
std::string ext = entry.path().extension().string();
std::string fname = entry.path().filename().string();
if (ext == ".wot") r.hasWot = true;
if (ext == ".wot") { r.hasWot = true; r.wotCount++; }
if (ext == ".whm") {
r.hasWhm = true;
r.hasWhm = true; r.whmCount++;
if (checkMagic(entry.path().string(), WHM_MAGIC)) r.whmValid = true;
}
if (ext == ".wom") {
r.hasWom = true;
r.hasWom = true; r.womCount++;
if (checkAnyMagic(entry.path().string(), {WOM_MAGIC, WOM2_MAGIC, WOM3_MAGIC}))
r.womValid = true;
else r.womInvalidCount++;
}
if (ext == ".wob") {
r.hasWob = true;
r.hasWob = true; r.wobCount++;
if (checkMagic(entry.path().string(), WOB_MAGIC)) r.wobValid = true;
else r.wobInvalidCount++;
}
if (ext == ".woc") {
r.hasWoc = true;
r.hasWoc = true; r.wocCount++;
if (checkMagic(entry.path().string(), WOC_MAGIC)) r.wocValid = true;
else r.wocInvalidCount++;
}
if (ext == ".png") r.hasPng = true;
if (ext == ".png") { r.hasPng = true; r.pngCount++; }
if (fname == "zone.json") r.hasZoneJson = true;
if (fname == "creatures.json") r.hasCreatures = true;
if (fname == "quests.json") r.hasQuests = true;

View file

@ -41,6 +41,14 @@ public:
bool hasPng = false, hasWom = false, hasWob = false, hasWoc = false;
bool hasCreatures = false, hasQuests = false, hasObjects = false;
bool whmValid = false, womValid = false, wobValid = false, wocValid = false;
// Counts of each format file (the has* booleans only tell whether
// at least one exists; counts are useful for the --validate report).
int wotCount = 0, whmCount = 0, womCount = 0, wobCount = 0;
int wocCount = 0, pngCount = 0;
// Counts of files that failed magic validation. A non-zero count
// means the zone has at least one corrupted file; a player would
// see missing geometry on load.
int womInvalidCount = 0, wobInvalidCount = 0, wocInvalidCount = 0;
int openFormatScore() const;
std::string summary() const;
};

View file

@ -192,20 +192,25 @@ int main(int argc, char* argv[]) {
std::printf("Open format score: %d/7\n", score);
std::printf("Formats: %s\n", v.summary().c_str());
std::printf("Files present:\n");
std::printf(" WOT (terrain meta) : %s\n", v.hasWot ? "yes" : "no");
std::printf(" WHM (heightmap) : %s%s\n",
v.hasWhm ? "yes" : "no",
std::printf(" WOT (terrain meta) : %s (%d)\n",
v.hasWot ? "yes" : "no", v.wotCount);
std::printf(" WHM (heightmap) : %s (%d)%s\n",
v.hasWhm ? "yes" : "no", v.whmCount,
v.hasWhm && !v.whmValid ? " (BAD MAGIC)" : "");
std::printf(" WOM (models) : %s%s\n",
v.hasWom ? "yes" : "no",
v.hasWom && !v.womValid ? " (BAD MAGIC)" : "");
std::printf(" WOB (buildings) : %s%s\n",
v.hasWob ? "yes" : "no",
v.hasWob && !v.wobValid ? " (BAD MAGIC)" : "");
std::printf(" WOC (collision) : %s%s\n",
v.hasWoc ? "yes" : "no",
v.hasWoc && !v.wocValid ? " (BAD MAGIC)" : "");
std::printf(" PNG (textures) : %s\n", v.hasPng ? "yes" : "no");
std::printf(" WOM (models) : %s (%d)%s\n",
v.hasWom ? "yes" : "no", v.womCount,
v.womInvalidCount > 0 ?
(" (" + std::to_string(v.womInvalidCount) + " invalid)").c_str() : "");
std::printf(" WOB (buildings) : %s (%d)%s\n",
v.hasWob ? "yes" : "no", v.wobCount,
v.wobInvalidCount > 0 ?
(" (" + std::to_string(v.wobInvalidCount) + " invalid)").c_str() : "");
std::printf(" WOC (collision) : %s (%d)%s\n",
v.hasWoc ? "yes" : "no", v.wocCount,
v.wocInvalidCount > 0 ?
(" (" + std::to_string(v.wocInvalidCount) + " invalid)").c_str() : "");
std::printf(" PNG (textures) : %s (%d)\n",
v.hasPng ? "yes" : "no", v.pngCount);
std::printf(" zone.json : %s\n", v.hasZoneJson ? "yes" : "no");
std::printf(" creatures.json : %s\n", v.hasCreatures ? "yes" : "no");
std::printf(" quests.json : %s\n", v.hasQuests ? "yes" : "no");