From fa8719009b90ed638d8fd30eab21c31958359889 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sat, 9 May 2026 22:10:09 -0700 Subject: [PATCH] feat(editor): add WCDF (Creature Difficulty) open catalog format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Open replacement for Blizzard's CreatureDifficulty.dbc. Maps a base creature entry to its difficulty variants: Normal-10 / Normal-25 / Heroic-10 / Heroic-25 in WotLK raid format. Each variant is itself a separate WCRT creature entry with its own stats, abilities, and loot. When a 25-man party engages an instance, the engine looks up the encounter base creature's difficultyId, reads the normal25Id field, and spawns that variant instead. This is how Lord Marrowgar in 25-Heroic ICC has 30M HP and hits for 80k while the same encounter in 10-Normal has 5M HP and hits for 25k — same spawn point, different WCRT entries. 5-man dungeons typically use only normal10Id + heroic10Id (the 25-man fields stay 0 — engine falls through to the 10-man variant when 25-man is queried). World bosses don't scale at all (all 4 variant fields stay 0, engine falls back to the base entry). Cross-references back to WCRT — every non-zero variant id field points at a WCRT.creatureId entry; the base creature itself lives in WCRT too. Three preset emitters: --gen-cdf (4 example bosses with full 4-variant routing), --gen-cdf-wotlk-raid (4 ICC-style raid bosses Marrowgar/Deathwhisper/Saurfang/LK with all 4 difficulty variants), --gen-cdf-fiveman (4 5-man dungeon bosses with only Normal+Heroic 10-man set). resolveVariant(id, mode) is the engine helper. Validation enforces id+name+baseCreatureId presence, spawnGroupKind 0..5, no duplicate ids; warns on: - WorldBoss kind with non-zero variant ids (world bosses don't scale) - duplicate baseCreatureId across routes (only first honored) - all-self-reference non-WorldBoss (creature doesn't actually scale) - Boss with n25 but not n10 (raid sequencing typo — n10 always comes with n25) Wired through the cross-format table; WCDF appears automatically in all 11 cross-format utilities. Format count 74 -> 75; CLI flag count 936 -> 941. --- CMakeLists.txt | 3 + .../pipeline/wowee_creature_difficulties.hpp | 126 ++++++++ src/pipeline/wowee_creature_difficulties.cpp | 273 ++++++++++++++++++ tools/editor/cli_arg_required.cpp | 2 + .../cli_creature_difficulties_catalog.cpp | 271 +++++++++++++++++ .../cli_creature_difficulties_catalog.hpp | 12 + tools/editor/cli_dispatch.cpp | 2 + tools/editor/cli_format_table.cpp | 1 + tools/editor/cli_help.cpp | 10 + tools/editor/cli_list_formats.cpp | 1 + 10 files changed, 701 insertions(+) create mode 100644 include/pipeline/wowee_creature_difficulties.hpp create mode 100644 src/pipeline/wowee_creature_difficulties.cpp create mode 100644 tools/editor/cli_creature_difficulties_catalog.cpp create mode 100644 tools/editor/cli_creature_difficulties_catalog.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index fae3ea68..85a7ae5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -663,6 +663,7 @@ set(WOWEE_SOURCES src/pipeline/wowee_creature_families.cpp src/pipeline/wowee_spell_power_costs.cpp src/pipeline/wowee_glyph_slots.cpp + src/pipeline/wowee_creature_difficulties.cpp src/pipeline/custom_zone_discovery.cpp src/pipeline/dbc_layout.cpp @@ -1483,6 +1484,7 @@ add_executable(wowee_editor tools/editor/cli_creature_families_catalog.cpp tools/editor/cli_spell_power_costs_catalog.cpp tools/editor/cli_glyph_slots_catalog.cpp + tools/editor/cli_creature_difficulties_catalog.cpp tools/editor/cli_quest_objective.cpp tools/editor/cli_quest_reward.cpp tools/editor/cli_clone.cpp @@ -1624,6 +1626,7 @@ add_executable(wowee_editor src/pipeline/wowee_creature_families.cpp src/pipeline/wowee_spell_power_costs.cpp src/pipeline/wowee_glyph_slots.cpp + src/pipeline/wowee_creature_difficulties.cpp src/pipeline/custom_zone_discovery.cpp src/pipeline/terrain_mesh.cpp diff --git a/include/pipeline/wowee_creature_difficulties.hpp b/include/pipeline/wowee_creature_difficulties.hpp new file mode 100644 index 00000000..0412119e --- /dev/null +++ b/include/pipeline/wowee_creature_difficulties.hpp @@ -0,0 +1,126 @@ +#pragma once + +#include +#include +#include + +namespace wowee { +namespace pipeline { + +// Wowee Open Creature Difficulty catalog (.wcdf) — novel +// replacement for Blizzard's CreatureDifficulty.dbc. Maps +// a base creature entry to its difficulty variants: +// Normal-10 / Normal-25 / Heroic-10 / Heroic-25 in WotLK +// raid format. Each variant is itself a separate WCRT +// creature entry with its own stats, abilities, and loot. +// +// When a 25-man party engages an instance, the engine +// looks up the encounter base creature's difficultyId, +// reads the normal25Id field, and spawns that variant +// instead. This is how Lord Marrowgar in 25-Heroic ICC +// has 30M HP and hits for 80k while the same encounter +// in 10-Normal has 5M HP and hits for 25k — same spawn +// point, different WCRT entries. +// +// 5-man dungeons typically use only normal10Id + +// heroic10Id (the 25-man fields stay 0). World bosses +// and rare elites that don't scale typically have a single +// non-zero variant matching the base id. +// +// Cross-references with previously-added formats: +// WCRT: every non-zero *Id field points at a +// WCRT.creatureId entry. The base creature lives +// in WCRT too — this catalog is purely the +// routing table from base id to variants. +// +// Binary layout (little-endian): +// magic[4] = "WCDF" +// version (uint32) = current 1 +// nameLen + name (catalog label) +// entryCount (uint32) +// entries (each): +// difficultyId (uint32) +// nameLen + name +// descLen + description +// baseCreatureId (uint32) +// normal10Id (uint32) +// normal25Id (uint32) +// heroic10Id (uint32) +// heroic25Id (uint32) +// spawnGroupKind (uint8) / pad[3] +// iconColorRGBA (uint32) +struct WoweeCreatureDifficulty { + enum SpawnGroupKind : uint8_t { + Boss = 0, // encounter boss / final boss + MiniBoss = 1, // sub-boss / room boss + RareElite = 2, // outdoor rare spawn + Trash = 3, // pull / hallway mob + Add = 4, // boss-spawned add + WorldBoss = 5, // open-world raid boss (no diff variants) + }; + + struct Entry { + uint32_t difficultyId = 0; + std::string name; + std::string description; + uint32_t baseCreatureId = 0; + uint32_t normal10Id = 0; + uint32_t normal25Id = 0; + uint32_t heroic10Id = 0; + uint32_t heroic25Id = 0; + uint8_t spawnGroupKind = Boss; + uint8_t pad0 = 0; + uint8_t pad1 = 0; + uint8_t pad2 = 0; + uint32_t iconColorRGBA = 0xFFFFFFFFu; + }; + + std::string name; + std::vector entries; + + bool isValid() const { return !entries.empty(); } + + const Entry* findById(uint32_t difficultyId) const; + const Entry* findByBaseCreature(uint32_t baseCreatureId) const; + + // Resolve to the variant creature id for the given + // difficulty index. mode: 0=Normal-10, 1=Normal-25, + // 2=Heroic-10, 3=Heroic-25. Returns 0 if no variant + // is configured for that mode (caller falls back to + // baseCreatureId). + uint32_t resolveVariant(uint32_t difficultyId, + uint8_t mode) const; + + static const char* spawnGroupKindName(uint8_t k); +}; + +class WoweeCreatureDifficultyLoader { +public: + static bool save(const WoweeCreatureDifficulty& cat, + const std::string& basePath); + static WoweeCreatureDifficulty load(const std::string& basePath); + static bool exists(const std::string& basePath); + + // Preset emitters used by --gen-cdf* variants. + // + // makeStarter — 4 example boss entries with full + // 4-variant 10/25/H10/H25 routing, + // using fictional creature ids in + // the 8000-8200 range. + // makeWotlkRaid — 4 Icecrown Citadel-style bosses + // (Marrowgar / Deathwhisper / + // Saurfang / Lich King) with full + // diff variants. + // makeFiveMan — 4 five-man dungeon bosses with + // only Normal + Heroic 10-man + // variants set (25-man fields stay + // 0 — engine falls through to the + // 10-man variant when 25-man is + // queried). + static WoweeCreatureDifficulty makeStarter(const std::string& catalogName); + static WoweeCreatureDifficulty makeWotlkRaid(const std::string& catalogName); + static WoweeCreatureDifficulty makeFiveMan(const std::string& catalogName); +}; + +} // namespace pipeline +} // namespace wowee diff --git a/src/pipeline/wowee_creature_difficulties.cpp b/src/pipeline/wowee_creature_difficulties.cpp new file mode 100644 index 00000000..5ba7b7b5 --- /dev/null +++ b/src/pipeline/wowee_creature_difficulties.cpp @@ -0,0 +1,273 @@ +#include "pipeline/wowee_creature_difficulties.hpp" + +#include +#include +#include + +namespace wowee { +namespace pipeline { + +namespace { + +constexpr char kMagic[4] = {'W', 'C', 'D', 'F'}; +constexpr uint32_t kVersion = 1; + +template +void writePOD(std::ofstream& os, const T& v) { + os.write(reinterpret_cast(&v), sizeof(T)); +} + +template +bool readPOD(std::ifstream& is, T& v) { + is.read(reinterpret_cast(&v), sizeof(T)); + return is.gcount() == static_cast(sizeof(T)); +} + +void writeStr(std::ofstream& os, const std::string& s) { + uint32_t n = static_cast(s.size()); + writePOD(os, n); + if (n > 0) os.write(s.data(), n); +} + +bool readStr(std::ifstream& is, std::string& s) { + uint32_t n = 0; + if (!readPOD(is, n)) return false; + if (n > (1u << 20)) return false; + s.resize(n); + if (n > 0) { + is.read(s.data(), n); + if (is.gcount() != static_cast(n)) { + s.clear(); + return false; + } + } + return true; +} + +std::string normalizePath(std::string base) { + if (base.size() < 5 || base.substr(base.size() - 5) != ".wcdf") { + base += ".wcdf"; + } + return base; +} + +uint32_t packRgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 0xFF) { + return (static_cast(a) << 24) | + (static_cast(b) << 16) | + (static_cast(g) << 8) | + static_cast(r); +} + +} // namespace + +const WoweeCreatureDifficulty::Entry* +WoweeCreatureDifficulty::findById(uint32_t difficultyId) const { + for (const auto& e : entries) + if (e.difficultyId == difficultyId) return &e; + return nullptr; +} + +const WoweeCreatureDifficulty::Entry* +WoweeCreatureDifficulty::findByBaseCreature( + uint32_t baseCreatureId) const { + for (const auto& e : entries) + if (e.baseCreatureId == baseCreatureId) return &e; + return nullptr; +} + +uint32_t WoweeCreatureDifficulty::resolveVariant( + uint32_t difficultyId, uint8_t mode) const { + const Entry* e = findById(difficultyId); + if (!e) return 0; + switch (mode) { + case 0: return e->normal10Id; + case 1: return e->normal25Id; + case 2: return e->heroic10Id; + case 3: return e->heroic25Id; + default: return 0; + } +} + +const char* WoweeCreatureDifficulty::spawnGroupKindName(uint8_t k) { + switch (k) { + case Boss: return "boss"; + case MiniBoss: return "mini-boss"; + case RareElite: return "rare-elite"; + case Trash: return "trash"; + case Add: return "add"; + case WorldBoss: return "world-boss"; + default: return "unknown"; + } +} + +bool WoweeCreatureDifficultyLoader::save( + const WoweeCreatureDifficulty& cat, + const std::string& basePath) { + std::ofstream os(normalizePath(basePath), std::ios::binary); + if (!os) return false; + os.write(kMagic, 4); + writePOD(os, kVersion); + writeStr(os, cat.name); + uint32_t entryCount = static_cast(cat.entries.size()); + writePOD(os, entryCount); + for (const auto& e : cat.entries) { + writePOD(os, e.difficultyId); + writeStr(os, e.name); + writeStr(os, e.description); + writePOD(os, e.baseCreatureId); + writePOD(os, e.normal10Id); + writePOD(os, e.normal25Id); + writePOD(os, e.heroic10Id); + writePOD(os, e.heroic25Id); + writePOD(os, e.spawnGroupKind); + writePOD(os, e.pad0); + writePOD(os, e.pad1); + writePOD(os, e.pad2); + writePOD(os, e.iconColorRGBA); + } + return os.good(); +} + +WoweeCreatureDifficulty WoweeCreatureDifficultyLoader::load( + const std::string& basePath) { + WoweeCreatureDifficulty out; + std::ifstream is(normalizePath(basePath), std::ios::binary); + if (!is) return out; + char magic[4]; + is.read(magic, 4); + if (std::memcmp(magic, kMagic, 4) != 0) return out; + uint32_t version = 0; + if (!readPOD(is, version) || version != kVersion) return out; + if (!readStr(is, out.name)) return out; + uint32_t entryCount = 0; + if (!readPOD(is, entryCount)) return out; + if (entryCount > (1u << 20)) return out; + out.entries.resize(entryCount); + for (auto& e : out.entries) { + if (!readPOD(is, e.difficultyId)) { + out.entries.clear(); return out; + } + if (!readStr(is, e.name) || !readStr(is, e.description)) { + out.entries.clear(); return out; + } + if (!readPOD(is, e.baseCreatureId) || + !readPOD(is, e.normal10Id) || + !readPOD(is, e.normal25Id) || + !readPOD(is, e.heroic10Id) || + !readPOD(is, e.heroic25Id) || + !readPOD(is, e.spawnGroupKind) || + !readPOD(is, e.pad0) || + !readPOD(is, e.pad1) || + !readPOD(is, e.pad2) || + !readPOD(is, e.iconColorRGBA)) { + out.entries.clear(); return out; + } + } + return out; +} + +bool WoweeCreatureDifficultyLoader::exists( + const std::string& basePath) { + std::ifstream is(normalizePath(basePath), std::ios::binary); + return is.good(); +} + +WoweeCreatureDifficulty WoweeCreatureDifficultyLoader::makeStarter( + const std::string& catalogName) { + using D = WoweeCreatureDifficulty; + WoweeCreatureDifficulty c; + c.name = catalogName; + auto add = [&](uint32_t id, const char* name, uint32_t base, + uint32_t n10, uint32_t n25, uint32_t h10, + uint32_t h25, uint8_t kind, + uint8_t r, uint8_t g, uint8_t b, + const char* desc) { + D::Entry e; + e.difficultyId = id; e.name = name; e.description = desc; + e.baseCreatureId = base; + e.normal10Id = n10; e.normal25Id = n25; + e.heroic10Id = h10; e.heroic25Id = h25; + e.spawnGroupKind = kind; + e.iconColorRGBA = packRgba(r, g, b); + c.entries.push_back(e); + }; + // 4 example bosses with the full 4-variant route. + add(1, "ExampleBoss1", 8000, 8001, 8002, 8003, 8004, + D::Boss, 240, 100, 100, + "Encounter boss with all 4 difficulty variants set."); + add(2, "ExampleBoss2", 8010, 8011, 8012, 8013, 8014, + D::Boss, 240, 100, 100, + "Encounter boss with all 4 difficulty variants set."); + add(3, "ExampleSub", 8100, 8101, 8102, 8103, 8104, + D::MiniBoss, 240, 180, 100, + "Mini-boss with all 4 difficulty variants set."); + add(4, "ExampleAdd", 8200, 8201, 8202, 8203, 8204, + D::Add, 150, 150, 240, + "Boss add with all 4 difficulty variants set."); + return c; +} + +WoweeCreatureDifficulty WoweeCreatureDifficultyLoader::makeWotlkRaid( + const std::string& catalogName) { + using D = WoweeCreatureDifficulty; + WoweeCreatureDifficulty c; + c.name = catalogName; + auto add = [&](uint32_t id, const char* name, uint32_t base, + uint32_t n10, uint32_t n25, uint32_t h10, + uint32_t h25, const char* desc) { + D::Entry e; + e.difficultyId = id; e.name = name; e.description = desc; + e.baseCreatureId = base; + e.normal10Id = n10; e.normal25Id = n25; + e.heroic10Id = h10; e.heroic25Id = h25; + e.spawnGroupKind = D::Boss; + e.iconColorRGBA = packRgba(220, 80, 100); // raid red + c.entries.push_back(e); + }; + // Icecrown Citadel boss IDs (illustrative — real + // numbers from AzerothCore's creature_template). + add(100, "LordMarrowgar", 36612, 36612, 39120, 39121, 39122, + "First ICC boss — 5 bone spike phases at 4 difficulties."); + add(101, "LadyDeathwhisper", 36855, 36855, 38421, 38422, 38423, + "Second ICC boss — 2-phase mind control encounter."); + add(102, "DeathbringerSaurfang", 37813, 37813, 38762, 38763, 38764, + "Plagueworks gatekeeper — Mark of the Fallen Champion."); + add(103, "TheLichKing", 36597, 36597, 39166, 39167, 39168, + "ICC final boss — Frostmourne defile encounter."); + return c; +} + +WoweeCreatureDifficulty WoweeCreatureDifficultyLoader::makeFiveMan( + const std::string& catalogName) { + using D = WoweeCreatureDifficulty; + WoweeCreatureDifficulty c; + c.name = catalogName; + auto add = [&](uint32_t id, const char* name, uint32_t base, + uint32_t n10, uint32_t h10, const char* desc) { + D::Entry e; + e.difficultyId = id; e.name = name; e.description = desc; + e.baseCreatureId = base; + e.normal10Id = n10; + // 25-man fields stay 0 — 5-man dungeons don't have + // 25-man variants. The engine falls back to n10 + // when a 25-man variant is queried (resolveVariant + // returns 0, caller substitutes baseCreatureId). + e.heroic10Id = h10; + e.spawnGroupKind = D::Boss; + e.iconColorRGBA = packRgba(180, 200, 100); // dungeon green + c.entries.push_back(e); + }; + // 5-man dungeon bosses — only Normal + Heroic variants. + add(200, "DungeonBoss1", 31000, 31000, 31100, + "5-man dungeon boss — Normal + Heroic only, no 25-man."); + add(201, "DungeonBoss2", 31010, 31010, 31110, + "5-man dungeon boss — Normal + Heroic only, no 25-man."); + add(202, "DungeonBoss3", 31020, 31020, 31120, + "5-man dungeon boss — Normal + Heroic only, no 25-man."); + add(203, "DungeonFinal", 31030, 31030, 31130, + "5-man dungeon final boss — Normal + Heroic only."); + return c; +} + +} // namespace pipeline +} // namespace wowee diff --git a/tools/editor/cli_arg_required.cpp b/tools/editor/cli_arg_required.cpp index db36ce76..1a4d08dd 100644 --- a/tools/editor/cli_arg_required.cpp +++ b/tools/editor/cli_arg_required.cpp @@ -228,6 +228,8 @@ const char* const kArgRequired[] = { "--gen-gfs", "--gen-gfs-wotlk", "--gen-gfs-cata", "--info-wgfs", "--validate-wgfs", "--export-wgfs-json", "--import-wgfs-json", + "--gen-cdf", "--gen-cdf-wotlk-raid", "--gen-cdf-fiveman", + "--info-wcdf", "--validate-wcdf", "--gen-weather-temperate", "--gen-weather-arctic", "--gen-weather-desert", "--gen-weather-stormy", "--gen-zone-atmosphere", diff --git a/tools/editor/cli_creature_difficulties_catalog.cpp b/tools/editor/cli_creature_difficulties_catalog.cpp new file mode 100644 index 00000000..e874ad27 --- /dev/null +++ b/tools/editor/cli_creature_difficulties_catalog.cpp @@ -0,0 +1,271 @@ +#include "cli_creature_difficulties_catalog.hpp" +#include "cli_arg_parse.hpp" +#include "cli_box_emitter.hpp" + +#include "pipeline/wowee_creature_difficulties.hpp" +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace wowee { +namespace editor { +namespace cli { + +namespace { + +std::string stripWcdfExt(std::string base) { + stripExt(base, ".wcdf"); + return base; +} + +bool saveOrError(const wowee::pipeline::WoweeCreatureDifficulty& c, + const std::string& base, const char* cmd) { + if (!wowee::pipeline::WoweeCreatureDifficultyLoader::save(c, base)) { + std::fprintf(stderr, "%s: failed to save %s.wcdf\n", + cmd, base.c_str()); + return false; + } + return true; +} + +void printGenSummary(const wowee::pipeline::WoweeCreatureDifficulty& c, + const std::string& base) { + std::printf("Wrote %s.wcdf\n", base.c_str()); + std::printf(" catalog : %s\n", c.name.c_str()); + std::printf(" routes : %zu\n", c.entries.size()); +} + +int handleGenStarter(int& i, int argc, char** argv) { + std::string base = argv[++i]; + std::string name = "StarterDifficulties"; + if (parseOptArg(i, argc, argv)) name = argv[++i]; + base = stripWcdfExt(base); + auto c = wowee::pipeline::WoweeCreatureDifficultyLoader::makeStarter(name); + if (!saveOrError(c, base, "gen-cdf")) return 1; + printGenSummary(c, base); + return 0; +} + +int handleGenWotlkRaid(int& i, int argc, char** argv) { + std::string base = argv[++i]; + std::string name = "WotlkICCBosses"; + if (parseOptArg(i, argc, argv)) name = argv[++i]; + base = stripWcdfExt(base); + auto c = wowee::pipeline::WoweeCreatureDifficultyLoader::makeWotlkRaid(name); + if (!saveOrError(c, base, "gen-cdf-wotlk-raid")) return 1; + printGenSummary(c, base); + return 0; +} + +int handleGenFiveMan(int& i, int argc, char** argv) { + std::string base = argv[++i]; + std::string name = "FiveManDungeons"; + if (parseOptArg(i, argc, argv)) name = argv[++i]; + base = stripWcdfExt(base); + auto c = wowee::pipeline::WoweeCreatureDifficultyLoader::makeFiveMan(name); + if (!saveOrError(c, base, "gen-cdf-fiveman")) return 1; + printGenSummary(c, base); + return 0; +} + +int handleInfo(int& i, int argc, char** argv) { + std::string base = argv[++i]; + bool jsonOut = consumeJsonFlag(i, argc, argv); + base = stripWcdfExt(base); + if (!wowee::pipeline::WoweeCreatureDifficultyLoader::exists(base)) { + std::fprintf(stderr, "WCDF not found: %s.wcdf\n", base.c_str()); + return 1; + } + auto c = wowee::pipeline::WoweeCreatureDifficultyLoader::load(base); + if (jsonOut) { + nlohmann::json j; + j["wcdf"] = base + ".wcdf"; + j["name"] = c.name; + j["count"] = c.entries.size(); + nlohmann::json arr = nlohmann::json::array(); + for (const auto& e : c.entries) { + arr.push_back({ + {"difficultyId", e.difficultyId}, + {"name", e.name}, + {"description", e.description}, + {"baseCreatureId", e.baseCreatureId}, + {"normal10Id", e.normal10Id}, + {"normal25Id", e.normal25Id}, + {"heroic10Id", e.heroic10Id}, + {"heroic25Id", e.heroic25Id}, + {"spawnGroupKind", e.spawnGroupKind}, + {"spawnGroupKindName", wowee::pipeline::WoweeCreatureDifficulty::spawnGroupKindName(e.spawnGroupKind)}, + {"iconColorRGBA", e.iconColorRGBA}, + }); + } + j["entries"] = arr; + std::printf("%s\n", j.dump(2).c_str()); + return 0; + } + std::printf("WCDF: %s.wcdf\n", base.c_str()); + std::printf(" catalog : %s\n", c.name.c_str()); + std::printf(" routes : %zu\n", c.entries.size()); + if (c.entries.empty()) return 0; + std::printf(" id kind base n10 n25 h10 h25 name\n"); + for (const auto& e : c.entries) { + std::printf(" %4u %-10s %5u %5u %5u %5u %5u %s\n", + e.difficultyId, + wowee::pipeline::WoweeCreatureDifficulty::spawnGroupKindName(e.spawnGroupKind), + e.baseCreatureId, + e.normal10Id, e.normal25Id, + e.heroic10Id, e.heroic25Id, + e.name.c_str()); + } + return 0; +} + +int handleValidate(int& i, int argc, char** argv) { + std::string base = argv[++i]; + bool jsonOut = consumeJsonFlag(i, argc, argv); + base = stripWcdfExt(base); + if (!wowee::pipeline::WoweeCreatureDifficultyLoader::exists(base)) { + std::fprintf(stderr, + "validate-wcdf: WCDF not found: %s.wcdf\n", base.c_str()); + return 1; + } + auto c = wowee::pipeline::WoweeCreatureDifficultyLoader::load(base); + std::vector errors; + std::vector warnings; + if (c.entries.empty()) { + warnings.push_back("catalog has zero entries"); + } + std::vector idsSeen; + std::vector baseSeen; + for (size_t k = 0; k < c.entries.size(); ++k) { + const auto& e = c.entries[k]; + std::string ctx = "entry " + std::to_string(k) + + " (id=" + std::to_string(e.difficultyId); + if (!e.name.empty()) ctx += " " + e.name; + ctx += ")"; + if (e.difficultyId == 0) + errors.push_back(ctx + ": difficultyId is 0"); + if (e.name.empty()) + errors.push_back(ctx + ": name is empty"); + if (e.spawnGroupKind > wowee::pipeline::WoweeCreatureDifficulty::WorldBoss) { + errors.push_back(ctx + ": spawnGroupKind " + + std::to_string(e.spawnGroupKind) + " not in 0..5"); + } + if (e.baseCreatureId == 0) + errors.push_back(ctx + + ": baseCreatureId is 0 — missing WCRT cross-ref"); + // World bosses don't scale, so all 4 variant fields + // should be 0 (engine falls through to base). + if (e.spawnGroupKind == wowee::pipeline::WoweeCreatureDifficulty::WorldBoss && + (e.normal10Id || e.normal25Id || e.heroic10Id || e.heroic25Id)) { + warnings.push_back(ctx + + ": WorldBoss kind with non-zero variant ids — " + "world bosses don't scale, set variant fields to 0"); + } + // The asymmetric case n25 set without n10 is + // suspicious — typically a typo, since raid + // sequencing always introduces n10 alongside n25. + // (5-man bosses legitimately have only n10/h10, so + // we don't warn on missing n25 alone.) + if (e.spawnGroupKind == wowee::pipeline::WoweeCreatureDifficulty::Boss && + e.normal25Id && !e.normal10Id) { + warnings.push_back(ctx + + ": Boss has normal25Id but not normal10Id — " + "raid sequencing introduces n10 alongside n25; " + "this is probably a typo"); + } + for (uint32_t prev : idsSeen) { + if (prev == e.difficultyId) { + errors.push_back(ctx + ": duplicate difficultyId"); + break; + } + } + idsSeen.push_back(e.difficultyId); + // Two routes for the same base creature collide — + // engine would only honor the first. + if (e.baseCreatureId != 0) { + for (uint32_t prevBase : baseSeen) { + if (prevBase == e.baseCreatureId) { + warnings.push_back(ctx + + ": duplicate baseCreatureId " + + std::to_string(e.baseCreatureId) + + " — only the first route entry will be honored"); + break; + } + } + baseSeen.push_back(e.baseCreatureId); + } + // Check for self-reference loops (base == any + // variant) which are valid for world bosses but + // nonsensical otherwise. + if (e.spawnGroupKind != wowee::pipeline::WoweeCreatureDifficulty::WorldBoss) { + if ((e.normal10Id == e.baseCreatureId && + e.normal25Id == e.baseCreatureId && + e.heroic10Id == e.baseCreatureId && + e.heroic25Id == e.baseCreatureId) && + e.normal10Id != 0) { + warnings.push_back(ctx + + ": all four variants point at baseCreatureId — " + "creature doesn't scale; consider WorldBoss kind"); + } + } + } + bool ok = errors.empty(); + if (jsonOut) { + nlohmann::json j; + j["wcdf"] = base + ".wcdf"; + j["ok"] = ok; + j["errors"] = errors; + j["warnings"] = warnings; + std::printf("%s\n", j.dump(2).c_str()); + return ok ? 0 : 1; + } + std::printf("validate-wcdf: %s.wcdf\n", base.c_str()); + if (ok && warnings.empty()) { + std::printf(" OK — %zu routes, all difficultyIds unique, all base ids set\n", + c.entries.size()); + return 0; + } + if (!warnings.empty()) { + std::printf(" warnings (%zu):\n", warnings.size()); + for (const auto& w : warnings) + std::printf(" - %s\n", w.c_str()); + } + if (!errors.empty()) { + std::printf(" ERRORS (%zu):\n", errors.size()); + for (const auto& e : errors) + std::printf(" - %s\n", e.c_str()); + } + return ok ? 0 : 1; +} + +} // namespace + +bool handleCreatureDifficultiesCatalog(int& i, int argc, + char** argv, int& outRc) { + if (std::strcmp(argv[i], "--gen-cdf") == 0 && i + 1 < argc) { + outRc = handleGenStarter(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--gen-cdf-wotlk-raid") == 0 && i + 1 < argc) { + outRc = handleGenWotlkRaid(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--gen-cdf-fiveman") == 0 && i + 1 < argc) { + outRc = handleGenFiveMan(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--info-wcdf") == 0 && i + 1 < argc) { + outRc = handleInfo(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--validate-wcdf") == 0 && i + 1 < argc) { + outRc = handleValidate(i, argc, argv); return true; + } + return false; +} + +} // namespace cli +} // namespace editor +} // namespace wowee diff --git a/tools/editor/cli_creature_difficulties_catalog.hpp b/tools/editor/cli_creature_difficulties_catalog.hpp new file mode 100644 index 00000000..7663ff09 --- /dev/null +++ b/tools/editor/cli_creature_difficulties_catalog.hpp @@ -0,0 +1,12 @@ +#pragma once + +namespace wowee { +namespace editor { +namespace cli { + +bool handleCreatureDifficultiesCatalog(int& i, int argc, + char** argv, int& outRc); + +} // namespace cli +} // namespace editor +} // namespace wowee diff --git a/tools/editor/cli_dispatch.cpp b/tools/editor/cli_dispatch.cpp index 4edbb03d..5fa007d6 100644 --- a/tools/editor/cli_dispatch.cpp +++ b/tools/editor/cli_dispatch.cpp @@ -113,6 +113,7 @@ #include "cli_creature_families_catalog.hpp" #include "cli_spell_power_costs_catalog.hpp" #include "cli_glyph_slots_catalog.hpp" +#include "cli_creature_difficulties_catalog.hpp" #include "cli_quest_objective.hpp" #include "cli_quest_reward.hpp" #include "cli_clone.hpp" @@ -267,6 +268,7 @@ constexpr DispatchFn kDispatchTable[] = { handleCreatureFamiliesCatalog, handleSpellPowerCostsCatalog, handleGlyphSlotsCatalog, + handleCreatureDifficultiesCatalog, handleQuestObjective, handleQuestReward, handleClone, diff --git a/tools/editor/cli_format_table.cpp b/tools/editor/cli_format_table.cpp index 25446ba6..4d45e884 100644 --- a/tools/editor/cli_format_table.cpp +++ b/tools/editor/cli_format_table.cpp @@ -77,6 +77,7 @@ constexpr FormatMagicEntry kFormats[] = { {{'W','C','E','F'}, ".wcef", "creatures", "--info-wcef", "Creature / pet family catalog"}, {{'W','S','P','C'}, ".wspc", "spells", "--info-wspc", "Spell power cost bucket catalog"}, {{'W','G','F','S'}, ".wgfs", "glyphs", "--info-wgfs", "Glyph slot layout catalog"}, + {{'W','C','D','F'}, ".wcdf", "creatures", "--info-wcdf", "Creature difficulty variant catalog"}, {{'W','F','A','C'}, ".wfac", "factions", nullptr, "Faction catalog"}, {{'W','L','C','K'}, ".wlck", "locks", nullptr, "Lock catalog"}, {{'W','S','K','L'}, ".wskl", "skills", nullptr, "Skill catalog"}, diff --git a/tools/editor/cli_help.cpp b/tools/editor/cli_help.cpp index 8ad1d7fe..78ce58d8 100644 --- a/tools/editor/cli_help.cpp +++ b/tools/editor/cli_help.cpp @@ -1789,6 +1789,16 @@ void printUsage(const char* argv0) { std::printf(" Export binary .wgfs to a human-editable JSON sidecar (defaults to .wgfs.json)\n"); std::printf(" --import-wgfs-json [out-base]\n"); std::printf(" Import a .wgfs.json sidecar back into binary .wgfs (accepts slotKind int OR slotKindName string)\n"); + std::printf(" --gen-cdf [name]\n"); + std::printf(" Emit .wcdf starter: 4 example boss/mini/add routes with full 4-variant 10/25/H10/H25 mapping\n"); + std::printf(" --gen-cdf-wotlk-raid [name]\n"); + std::printf(" Emit .wcdf 4 ICC-style raid bosses (Marrowgar / Deathwhisper / Saurfang / Lich King) with all 4 difficulty variants\n"); + std::printf(" --gen-cdf-fiveman [name]\n"); + std::printf(" Emit .wcdf 4 5-man dungeon bosses with only Normal+Heroic 10-man variants set (25-man fields stay 0)\n"); + std::printf(" --info-wcdf [--json]\n"); + std::printf(" Print WCDF entries (id / kind / baseCreatureId / 4 variant ids / name)\n"); + std::printf(" --validate-wcdf [--json]\n"); + std::printf(" Static checks: id+name+baseCreatureId required, spawnGroupKind 0..5, no duplicate ids; warns on WorldBoss with variants, Boss with only n10, duplicate baseIds, all-self-ref non-WorldBoss\n"); std::printf(" --gen-weather-temperate [zoneName]\n"); std::printf(" Emit .wow weather schedule: clear-dominant + occasional rain + fog (forest / grassland)\n"); std::printf(" --gen-weather-arctic [zoneName]\n"); diff --git a/tools/editor/cli_list_formats.cpp b/tools/editor/cli_list_formats.cpp index 87591a9c..7426b892 100644 --- a/tools/editor/cli_list_formats.cpp +++ b/tools/editor/cli_list_formats.cpp @@ -99,6 +99,7 @@ constexpr FormatRow kFormats[] = { {"WCEF", ".wcef", "creatures", "CreatureFamily.dbc + pet trees", "Creature / pet family catalog"}, {"WSPC", ".wspc", "spells", "Spell.dbc power-cost fields", "Spell power cost bucket catalog"}, {"WGFS", ".wgfs", "glyphs", "GlyphSlot.dbc", "Glyph slot layout catalog"}, + {"WCDF", ".wcdf", "creatures", "CreatureDifficulty.dbc", "Creature difficulty variant catalog"}, // Additional pipeline catalogs without the alternating // gen/info/validate CLI surface (loaded by the engine