feat(editor): add WAUC JSON round-trip authoring workflow

Closes the WAUC open-format loop with --export-wauc-json /
--import-wauc-json, mirroring the JSON pairs added for
every other novel binary format. All 33 binary formats
added since WOL now have full JSON round-trip authoring.

Each house round-trips all 14 scalar fields plus the
factionAccess enum dual int + name forms (alliance / horde
/ neutral / both).

Verified byte-identical round-trip on the faction-pair
preset (3 houses including Stormwind/Orgrimmar/Booty Bay
with different cut rates and auctioneer NPC IDs preserved
through the JSON layer).

Adds 2 flags (679 documented total now).
This commit is contained in:
Kelsi 2026-05-09 18:45:01 -07:00
parent af214d8b34
commit 89fcd4d4cb
3 changed files with 141 additions and 0 deletions

View file

@ -115,6 +115,7 @@ const char* const kArgRequired[] = {
"--export-wpet-json", "--import-wpet-json",
"--gen-auction", "--gen-auction-pair", "--gen-auction-restricted",
"--info-wauc", "--validate-wauc",
"--export-wauc-json", "--import-wauc-json",
"--gen-channels", "--gen-channels-city", "--gen-channels-moderated",
"--info-wchn", "--validate-wchn",
"--gen-weather-temperate", "--gen-weather-arctic",

View file

@ -130,6 +130,136 @@ int handleInfo(int& i, int argc, char** argv) {
return 0;
}
int handleExportJson(int& i, int argc, char** argv) {
// Mirrors the JSON pairs added for every other novel
// open format. Each house emits all 12 scalar fields
// plus dual int + name forms for factionAccess.
std::string base = argv[++i];
std::string outPath;
if (parseOptArg(i, argc, argv)) outPath = argv[++i];
base = stripWaucExt(base);
if (outPath.empty()) outPath = base + ".wauc.json";
if (!wowee::pipeline::WoweeAuctionLoader::exists(base)) {
std::fprintf(stderr,
"export-wauc-json: WAUC not found: %s.wauc\n", base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeAuctionLoader::load(base);
nlohmann::json j;
j["name"] = c.name;
nlohmann::json arr = nlohmann::json::array();
for (const auto& e : c.entries) {
arr.push_back({
{"houseId", e.houseId},
{"auctioneerNpcId", e.auctioneerNpcId},
{"name", e.name},
{"factionAccess", e.factionAccess},
{"factionAccessName", wowee::pipeline::WoweeAuction::factionAccessName(e.factionAccess)},
{"baseDepositRateBp", e.baseDepositRateBp},
{"houseCutRateBp", e.houseCutRateBp},
{"maxBidCopper", e.maxBidCopper},
{"shortHours", e.shortHours},
{"mediumHours", e.mediumHours},
{"longHours", e.longHours},
{"shortMultBp", e.shortMultBp},
{"mediumMultBp", e.mediumMultBp},
{"longMultBp", e.longMultBp},
{"disallowedClassMask", e.disallowedClassMask},
});
}
j["entries"] = arr;
std::ofstream out(outPath);
if (!out) {
std::fprintf(stderr,
"export-wauc-json: cannot write %s\n", outPath.c_str());
return 1;
}
out << j.dump(2) << "\n";
out.close();
std::printf("Wrote %s\n", outPath.c_str());
std::printf(" source : %s.wauc\n", base.c_str());
std::printf(" houses : %zu\n", c.entries.size());
return 0;
}
int handleImportJson(int& i, int argc, char** argv) {
std::string jsonPath = argv[++i];
std::string outBase;
if (parseOptArg(i, argc, argv)) outBase = argv[++i];
if (outBase.empty()) {
outBase = jsonPath;
std::string suffix = ".wauc.json";
if (outBase.size() > suffix.size() &&
outBase.substr(outBase.size() - suffix.size()) == suffix) {
outBase = outBase.substr(0, outBase.size() - suffix.size());
} else if (outBase.size() > 5 &&
outBase.substr(outBase.size() - 5) == ".json") {
outBase = outBase.substr(0, outBase.size() - 5);
}
}
outBase = stripWaucExt(outBase);
std::ifstream in(jsonPath);
if (!in) {
std::fprintf(stderr,
"import-wauc-json: cannot read %s\n", jsonPath.c_str());
return 1;
}
nlohmann::json j;
try { in >> j; }
catch (const std::exception& e) {
std::fprintf(stderr,
"import-wauc-json: bad JSON in %s: %s\n",
jsonPath.c_str(), e.what());
return 1;
}
auto factionFromName = [](const std::string& s) -> uint8_t {
if (s == "alliance") return wowee::pipeline::WoweeAuction::Alliance;
if (s == "horde") return wowee::pipeline::WoweeAuction::Horde;
if (s == "neutral") return wowee::pipeline::WoweeAuction::Neutral;
if (s == "both") return wowee::pipeline::WoweeAuction::Both;
return wowee::pipeline::WoweeAuction::Alliance;
};
wowee::pipeline::WoweeAuction c;
c.name = j.value("name", std::string{});
if (j.contains("entries") && j["entries"].is_array()) {
for (const auto& je : j["entries"]) {
wowee::pipeline::WoweeAuction::Entry e;
e.houseId = je.value("houseId", 0u);
e.auctioneerNpcId = je.value("auctioneerNpcId", 0u);
e.name = je.value("name", std::string{});
if (je.contains("factionAccess") &&
je["factionAccess"].is_number_integer()) {
e.factionAccess = static_cast<uint8_t>(
je["factionAccess"].get<int>());
} else if (je.contains("factionAccessName") &&
je["factionAccessName"].is_string()) {
e.factionAccess = factionFromName(
je["factionAccessName"].get<std::string>());
}
e.baseDepositRateBp = je.value("baseDepositRateBp", 1500u);
e.houseCutRateBp = je.value("houseCutRateBp", 500u);
e.maxBidCopper = je.value("maxBidCopper", 0u);
e.shortHours = static_cast<uint16_t>(je.value("shortHours", 12));
e.mediumHours = static_cast<uint16_t>(je.value("mediumHours", 24));
e.longHours = static_cast<uint16_t>(je.value("longHours", 48));
e.shortMultBp = je.value("shortMultBp", 10000u);
e.mediumMultBp = je.value("mediumMultBp", 20000u);
e.longMultBp = je.value("longMultBp", 40000u);
e.disallowedClassMask = je.value("disallowedClassMask", 0u);
c.entries.push_back(e);
}
}
if (!wowee::pipeline::WoweeAuctionLoader::save(c, outBase)) {
std::fprintf(stderr,
"import-wauc-json: failed to save %s.wauc\n", outBase.c_str());
return 1;
}
std::printf("Wrote %s.wauc\n", outBase.c_str());
std::printf(" source : %s\n", jsonPath.c_str());
std::printf(" houses : %zu\n", c.entries.size());
return 0;
}
int handleValidate(int& i, int argc, char** argv) {
std::string base = argv[++i];
bool jsonOut = consumeJsonFlag(i, argc, argv);
@ -231,6 +361,12 @@ bool handleAuctionCatalog(int& i, int argc, char** argv, int& outRc) {
if (std::strcmp(argv[i], "--validate-wauc") == 0 && i + 1 < argc) {
outRc = handleValidate(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--export-wauc-json") == 0 && i + 1 < argc) {
outRc = handleExportJson(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--import-wauc-json") == 0 && i + 1 < argc) {
outRc = handleImportJson(i, argc, argv); return true;
}
return false;
}

View file

@ -1259,6 +1259,10 @@ void printUsage(const char* argv0) {
std::printf(" Print WAUC houses (id / faction / deposit + cut percent / 3 duration tiers / disallow mask / npc)\n");
std::printf(" --validate-wauc <wauc-base> [--json]\n");
std::printf(" Static checks: id>0+unique, faction 0..3, durations short<=medium<=long, cut < 100%%\n");
std::printf(" --export-wauc-json <wauc-base> [out.json]\n");
std::printf(" Export binary .wauc to a human-editable JSON sidecar (defaults to <base>.wauc.json)\n");
std::printf(" --import-wauc-json <json-path> [out-base]\n");
std::printf(" Import a .wauc.json sidecar back into binary .wauc (accepts factionAccess int OR name string)\n");
std::printf(" --gen-channels <wchn-base> [name]\n");
std::printf(" Emit .wchn starter: 4 stock channels (General / Trade / LFG / GuildRecruit) with autoJoin defaults\n");
std::printf(" --gen-channels-city <wchn-base> [name]\n");