mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 19:13:52 +00:00
feat(editor): add WAUR JSON round-trip (--export/--import-waur-json)
Closes the editing loop on the spell-aura-type catalog: dump a
.waur to JSON, hand-edit auraKind / targetingHint / tick interval
/ stack rules (e.g. retune PeriodicDamage from 3000ms to 2500ms
ticks for a faster server, mark a custom aura as
HostileOnly+stackable up to 10, switch a server-custom DoT from
StatMod to Periodic kind), re-import to a byte-identical binary.
Three dual-encoded fields:
- auraKind: int 0..8 OR "periodic" / "stat-mod" / "damage-mod"
/ "movement" / "visual" / "trigger" / "resource" / "control"
/ "misc"
- targetingHint: int 0..3 OR "any" / "self" / "hostile" /
"beneficial"
- isStackable: bool OR int (machine-generated sidecars work
too)
Verified byte-identical round-trip on all three presets
(periodic / stats / movement). CLI flag count 1001 -> 1003.
This commit is contained in:
parent
7d3430c8fe
commit
18f07f1b8a
3 changed files with 188 additions and 0 deletions
|
|
@ -256,6 +256,7 @@ const char* const kArgRequired[] = {
|
|||
"--export-wsef-json", "--import-wsef-json",
|
||||
"--gen-aur", "--gen-aur-stats", "--gen-aur-movement",
|
||||
"--info-waur", "--validate-waur",
|
||||
"--export-waur-json", "--import-waur-json",
|
||||
"--gen-weather-temperate", "--gen-weather-arctic",
|
||||
"--gen-weather-desert", "--gen-weather-stormy",
|
||||
"--gen-zone-atmosphere",
|
||||
|
|
|
|||
|
|
@ -1919,6 +1919,10 @@ void printUsage(const char* argv0) {
|
|||
std::printf(" Print WAUR entries (id / kind / targeting / stack flag / max stack / tick interval / name)\n");
|
||||
std::printf(" --validate-waur <waur-base> [--json]\n");
|
||||
std::printf(" Static checks: name required, auraKind 0..8, targetingHint 0..3, no duplicate ids; errors on Periodic without tick interval; warns on non-periodic with tick interval, maxStackCount without isStackable\n");
|
||||
std::printf(" --export-waur-json <waur-base> [out.json]\n");
|
||||
std::printf(" Export binary .waur to a human-editable JSON sidecar (defaults to <base>.waur.json)\n");
|
||||
std::printf(" --import-waur-json <json-path> [out-base]\n");
|
||||
std::printf(" Import a .waur.json sidecar back into binary .waur (accepts auraKind/targetingHint int OR name; isStackable bool OR int)\n");
|
||||
std::printf(" --gen-weather-temperate <wow-base> [zoneName]\n");
|
||||
std::printf(" Emit .wow weather schedule: clear-dominant + occasional rain + fog (forest / grassland)\n");
|
||||
std::printf(" --gen-weather-arctic <wow-base> [zoneName]\n");
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include "pipeline/wowee_spell_aura_types.hpp"
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
|
@ -124,6 +125,182 @@ int handleInfo(int& i, int argc, char** argv) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int handleExportJson(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string outPath;
|
||||
if (parseOptArg(i, argc, argv)) outPath = argv[++i];
|
||||
base = stripWaurExt(base);
|
||||
if (!wowee::pipeline::WoweeSpellAuraTypeLoader::exists(base)) {
|
||||
std::fprintf(stderr,
|
||||
"export-waur-json: WAUR not found: %s.waur\n",
|
||||
base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeSpellAuraTypeLoader::load(base);
|
||||
if (outPath.empty()) outPath = base + ".waur.json";
|
||||
nlohmann::json j;
|
||||
j["catalog"] = c.name;
|
||||
nlohmann::json arr = nlohmann::json::array();
|
||||
for (const auto& e : c.entries) {
|
||||
nlohmann::json je;
|
||||
je["auraTypeId"] = e.auraTypeId;
|
||||
je["name"] = e.name;
|
||||
je["description"] = e.description;
|
||||
je["auraKind"] = e.auraKind;
|
||||
je["auraKindName"] =
|
||||
wowee::pipeline::WoweeSpellAuraType::auraKindName(e.auraKind);
|
||||
je["targetingHint"] = e.targetingHint;
|
||||
je["targetingHintName"] =
|
||||
wowee::pipeline::WoweeSpellAuraType::targetingHintName(e.targetingHint);
|
||||
je["isStackable"] = e.isStackable != 0;
|
||||
je["maxStackCount"] = e.maxStackCount;
|
||||
je["updateFrequencyMs"] = e.updateFrequencyMs;
|
||||
je["iconColorRGBA"] = e.iconColorRGBA;
|
||||
arr.push_back(je);
|
||||
}
|
||||
j["entries"] = arr;
|
||||
std::ofstream os(outPath);
|
||||
if (!os) {
|
||||
std::fprintf(stderr,
|
||||
"export-waur-json: failed to open %s for write\n",
|
||||
outPath.c_str());
|
||||
return 1;
|
||||
}
|
||||
os << j.dump(2) << "\n";
|
||||
std::printf("Wrote %s\n", outPath.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" auras : %zu\n", c.entries.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t parseAuraKindToken(const nlohmann::json& jv,
|
||||
uint8_t fallback) {
|
||||
if (jv.is_number_integer() || jv.is_number_unsigned()) {
|
||||
int v = jv.get<int>();
|
||||
if (v < 0 || v > wowee::pipeline::WoweeSpellAuraType::Misc)
|
||||
return fallback;
|
||||
return static_cast<uint8_t>(v);
|
||||
}
|
||||
if (jv.is_string()) {
|
||||
std::string s = jv.get<std::string>();
|
||||
for (auto& ch : s) ch = static_cast<char>(std::tolower(ch));
|
||||
if (s == "periodic") return wowee::pipeline::WoweeSpellAuraType::Periodic;
|
||||
if (s == "stat-mod" ||
|
||||
s == "statmod") return wowee::pipeline::WoweeSpellAuraType::StatMod;
|
||||
if (s == "damage-mod" ||
|
||||
s == "damagemod") return wowee::pipeline::WoweeSpellAuraType::DamageMod;
|
||||
if (s == "movement") return wowee::pipeline::WoweeSpellAuraType::Movement;
|
||||
if (s == "visual") return wowee::pipeline::WoweeSpellAuraType::Visual;
|
||||
if (s == "trigger") return wowee::pipeline::WoweeSpellAuraType::Trigger;
|
||||
if (s == "resource") return wowee::pipeline::WoweeSpellAuraType::Resource;
|
||||
if (s == "control") return wowee::pipeline::WoweeSpellAuraType::Control;
|
||||
if (s == "misc") return wowee::pipeline::WoweeSpellAuraType::Misc;
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
uint8_t parseTargetingHintToken(const nlohmann::json& jv,
|
||||
uint8_t fallback) {
|
||||
if (jv.is_number_integer() || jv.is_number_unsigned()) {
|
||||
int v = jv.get<int>();
|
||||
if (v < 0 || v > wowee::pipeline::WoweeSpellAuraType::BeneficialOnly)
|
||||
return fallback;
|
||||
return static_cast<uint8_t>(v);
|
||||
}
|
||||
if (jv.is_string()) {
|
||||
std::string s = jv.get<std::string>();
|
||||
for (auto& ch : s) ch = static_cast<char>(std::tolower(ch));
|
||||
if (s == "any" ||
|
||||
s == "anyunit") return wowee::pipeline::WoweeSpellAuraType::AnyUnit;
|
||||
if (s == "self" ||
|
||||
s == "selfonly") return wowee::pipeline::WoweeSpellAuraType::SelfOnly;
|
||||
if (s == "hostile" ||
|
||||
s == "hostileonly") return wowee::pipeline::WoweeSpellAuraType::HostileOnly;
|
||||
if (s == "beneficial" ||
|
||||
s == "beneficialonly") return wowee::pipeline::WoweeSpellAuraType::BeneficialOnly;
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
int handleImportJson(int& i, int argc, char** argv) {
|
||||
std::string jsonPath = argv[++i];
|
||||
std::string outBase;
|
||||
if (parseOptArg(i, argc, argv)) outBase = argv[++i];
|
||||
std::ifstream is(jsonPath);
|
||||
if (!is) {
|
||||
std::fprintf(stderr,
|
||||
"import-waur-json: failed to open %s\n", jsonPath.c_str());
|
||||
return 1;
|
||||
}
|
||||
nlohmann::json j;
|
||||
try {
|
||||
is >> j;
|
||||
} catch (const std::exception& ex) {
|
||||
std::fprintf(stderr,
|
||||
"import-waur-json: parse error in %s: %s\n",
|
||||
jsonPath.c_str(), ex.what());
|
||||
return 1;
|
||||
}
|
||||
wowee::pipeline::WoweeSpellAuraType c;
|
||||
if (j.contains("catalog") && j["catalog"].is_string())
|
||||
c.name = j["catalog"].get<std::string>();
|
||||
if (j.contains("entries") && j["entries"].is_array()) {
|
||||
for (const auto& je : j["entries"]) {
|
||||
wowee::pipeline::WoweeSpellAuraType::Entry e;
|
||||
if (je.contains("auraTypeId")) e.auraTypeId = je["auraTypeId"].get<uint32_t>();
|
||||
if (je.contains("name")) e.name = je["name"].get<std::string>();
|
||||
if (je.contains("description")) e.description = je["description"].get<std::string>();
|
||||
uint8_t kind = wowee::pipeline::WoweeSpellAuraType::Periodic;
|
||||
if (je.contains("auraKind"))
|
||||
kind = parseAuraKindToken(je["auraKind"], kind);
|
||||
else if (je.contains("auraKindName"))
|
||||
kind = parseAuraKindToken(je["auraKindName"], kind);
|
||||
e.auraKind = kind;
|
||||
uint8_t hint = wowee::pipeline::WoweeSpellAuraType::AnyUnit;
|
||||
if (je.contains("targetingHint"))
|
||||
hint = parseTargetingHintToken(je["targetingHint"], hint);
|
||||
else if (je.contains("targetingHintName"))
|
||||
hint = parseTargetingHintToken(je["targetingHintName"], hint);
|
||||
e.targetingHint = hint;
|
||||
if (je.contains("isStackable")) {
|
||||
if (je["isStackable"].is_boolean())
|
||||
e.isStackable = je["isStackable"].get<bool>() ? 1 : 0;
|
||||
else
|
||||
e.isStackable = je["isStackable"].get<uint8_t>() ? 1 : 0;
|
||||
}
|
||||
if (je.contains("maxStackCount")) e.maxStackCount = je["maxStackCount"].get<uint8_t>();
|
||||
if (je.contains("updateFrequencyMs")) e.updateFrequencyMs = je["updateFrequencyMs"].get<uint32_t>();
|
||||
if (je.contains("iconColorRGBA")) e.iconColorRGBA = je["iconColorRGBA"].get<uint32_t>();
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
}
|
||||
if (outBase.empty()) {
|
||||
outBase = jsonPath;
|
||||
const std::string suffix1 = ".waur.json";
|
||||
const std::string suffix2 = ".json";
|
||||
if (outBase.size() >= suffix1.size() &&
|
||||
outBase.compare(outBase.size() - suffix1.size(),
|
||||
suffix1.size(), suffix1) == 0) {
|
||||
outBase.resize(outBase.size() - suffix1.size());
|
||||
} else if (outBase.size() >= suffix2.size() &&
|
||||
outBase.compare(outBase.size() - suffix2.size(),
|
||||
suffix2.size(), suffix2) == 0) {
|
||||
outBase.resize(outBase.size() - suffix2.size());
|
||||
}
|
||||
}
|
||||
outBase = stripWaurExt(outBase);
|
||||
if (!wowee::pipeline::WoweeSpellAuraTypeLoader::save(c, outBase)) {
|
||||
std::fprintf(stderr,
|
||||
"import-waur-json: failed to save %s.waur\n",
|
||||
outBase.c_str());
|
||||
return 1;
|
||||
}
|
||||
std::printf("Wrote %s.waur\n", outBase.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" auras : %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);
|
||||
|
|
@ -237,6 +414,12 @@ bool handleSpellAuraTypesCatalog(int& i, int argc, char** argv,
|
|||
if (std::strcmp(argv[i], "--validate-waur") == 0 && i + 1 < argc) {
|
||||
outRc = handleValidate(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--export-waur-json") == 0 && i + 1 < argc) {
|
||||
outRc = handleExportJson(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--import-waur-json") == 0 && i + 1 < argc) {
|
||||
outRc = handleImportJson(i, argc, argv); return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue