From 23ba7ed6a0ae8f29aa24ee17660124fe137a1ae2 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sat, 9 May 2026 21:23:38 -0700 Subject: [PATCH] feat(pipeline): add WQSO (Wowee Quest Sort) catalog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 67th open format — replaces QuestSort.dbc plus the quest-log categorization fields in QuestInfo.dbc. Defines the categories that quests fall into for the quest-log UI: class quests (Warrior trial, etc), profession quests, daily quests, holiday events, reputation grinds, dungeon / heroic / raid quests, repeatables, PvP, tournament. 12 sort kinds (General / ClassQuest / Profession / Daily / Holiday / Reputation / Dungeon / Raid / Heroic / Repeatable / PvP / Tournament). Each WQT (quest) entry can reference a sortId here to be grouped under the right header in the quest log. Sorts can be class-restricted (Warrior quests only show for warriors), profession-restricted, or faction-reputation-gated. Cross-references with prior formats — targetClassMask uses WCHC.classId bit positions (matches WGLY/WSET/WGTP convention), targetProfessionId points at WTSK.profession enum, targetFactionId points at WFAC.factionId. CLI: --gen-qso (3 generic sorts — General catch-all, Daily reset, Repeatable non-daily), --gen-qso-class (10 class- specific sorts with proper bit masks for Warrior 0x02 through Druid 0x800), --gen-qso-profession (8 profession sorts with WTSK profession enum cross-refs), --info-wqso, --validate-wqso with --json variants. Validator catches id+name+displayName required, kind 0..11, ClassQuest with classMask=0 (not actually class-restricted), Profession with profId=0 + non-Blacksmithing-name (likely typo since 0=Blacksmithing in WTSK), and Reputation with factionId=0 (no faction to grind). Format graph: 66 → 67 binary formats. CLI flag count: 877 → 882. --- CMakeLists.txt | 3 + include/pipeline/wowee_quest_sorts.hpp | 112 ++++++++++ src/pipeline/wowee_quest_sorts.cpp | 242 ++++++++++++++++++++++ tools/editor/cli_arg_required.cpp | 2 + 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 + tools/editor/cli_quest_sorts_catalog.cpp | 249 +++++++++++++++++++++++ tools/editor/cli_quest_sorts_catalog.hpp | 12 ++ 10 files changed, 634 insertions(+) create mode 100644 include/pipeline/wowee_quest_sorts.hpp create mode 100644 src/pipeline/wowee_quest_sorts.cpp create mode 100644 tools/editor/cli_quest_sorts_catalog.cpp create mode 100644 tools/editor/cli_quest_sorts_catalog.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index bdbf2249..6c5ef73c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -655,6 +655,7 @@ set(WOWEE_SOURCES src/pipeline/wowee_item_suffixes.cpp src/pipeline/wowee_combat_ratings.cpp src/pipeline/wowee_unit_movement.cpp + src/pipeline/wowee_quest_sorts.cpp src/pipeline/custom_zone_discovery.cpp src/pipeline/dbc_layout.cpp @@ -1464,6 +1465,7 @@ add_executable(wowee_editor tools/editor/cli_item_suffixes_catalog.cpp tools/editor/cli_combat_ratings_catalog.cpp tools/editor/cli_unit_movement_catalog.cpp + tools/editor/cli_quest_sorts_catalog.cpp tools/editor/cli_quest_objective.cpp tools/editor/cli_quest_reward.cpp tools/editor/cli_clone.cpp @@ -1597,6 +1599,7 @@ add_executable(wowee_editor src/pipeline/wowee_item_suffixes.cpp src/pipeline/wowee_combat_ratings.cpp src/pipeline/wowee_unit_movement.cpp + src/pipeline/wowee_quest_sorts.cpp src/pipeline/custom_zone_discovery.cpp src/pipeline/terrain_mesh.cpp diff --git a/include/pipeline/wowee_quest_sorts.hpp b/include/pipeline/wowee_quest_sorts.hpp new file mode 100644 index 00000000..b7340ad0 --- /dev/null +++ b/include/pipeline/wowee_quest_sorts.hpp @@ -0,0 +1,112 @@ +#pragma once + +#include +#include +#include + +namespace wowee { +namespace pipeline { + +// Wowee Open Quest Sort catalog (.wqso) — novel +// replacement for Blizzard's QuestSort.dbc plus the quest- +// log categorization fields in QuestInfo.dbc. Defines the +// categories that quests fall into for the quest-log UI: +// Class quests / Profession quests / Daily quests / PvP / +// Holiday / Reputation / Dungeon / Raid / Heroic / +// Repeatable / Tournament etc. +// +// Each WQT (quest) entry references a sortId here to be +// grouped under the right header in the quest log. Sorts +// can be class-restricted (Warrior class quests only show +// for warriors), profession-restricted, or faction- +// reputation-gated. +// +// Cross-references with previously-added formats: +// WQSO.entry.targetClassMask uses WCHC.classId bit +// positions (matches WGLY/WSET +// convention). +// WQSO.entry.targetProfessionId → WTSK.profession enum +// (Blacksmithing=0, etc). +// WQSO.entry.targetFactionId → WFAC.factionId +// +// Binary layout (little-endian): +// magic[4] = "WQSO" +// version (uint32) = current 1 +// nameLen + name (catalog label) +// entryCount (uint32) +// entries (each): +// sortId (uint32) +// nameLen + name +// displayLen + displayName +// descLen + description +// iconLen + iconPath +// sortKind (uint8) / displayPriority (uint8) / +// targetProfessionId (uint8) / pad[1] +// targetClassMask (uint32) +// targetFactionId (uint32) +struct WoweeQuestSort { + enum SortKind : uint8_t { + General = 0, // catch-all / area-quest + ClassQuest = 1, // class-specific (Warrior trial) + Profession = 2, // profession recipe / quest + Daily = 3, // daily reset quest + Holiday = 4, // seasonal event quest + Reputation = 5, // faction grind quest + Dungeon = 6, // 5-man dungeon quest + Raid = 7, // 10/25-man raid quest + Heroic = 8, // dungeon heroic-mode quest + Repeatable = 9, // non-daily repeatable + PvP = 10, // battleground / arena quest + Tournament = 11, // Argent Tournament style + }; + + struct Entry { + uint32_t sortId = 0; + std::string name; + std::string displayName; // shown in quest log UI + std::string description; + std::string iconPath; + uint8_t sortKind = General; + uint8_t displayPriority = 0; + uint8_t targetProfessionId = 0; // WTSK profession enum + uint32_t targetClassMask = 0; // WCHC bit mask (0 = any) + uint32_t targetFactionId = 0; // WFAC cross-ref (0 = any) + }; + + std::string name; + std::vector entries; + + bool isValid() const { return !entries.empty(); } + + const Entry* findById(uint32_t sortId) const; + + static const char* sortKindName(uint8_t k); +}; + +class WoweeQuestSortLoader { +public: + static bool save(const WoweeQuestSort& cat, + const std::string& basePath); + static WoweeQuestSort load(const std::string& basePath); + static bool exists(const std::string& basePath); + + // Preset emitters used by --gen-qso* variants. + // + // makeStarter — 3 generic sorts (General catch-all, + // Daily reset, Repeatable non-daily). + // makeClass — 10 class-specific sorts (Warrior / + // Paladin / Hunter / Rogue / Priest / + // DK / Shaman / Mage / Warlock / Druid) + // each with the matching WCHC class + // bit set. + // makeProfession — 8 profession sorts (Blacksmithing, + // Tailoring, Engineering, Alchemy, + // Enchanting, Leatherworking, + // Jewelcrafting, Inscription). + static WoweeQuestSort makeStarter(const std::string& catalogName); + static WoweeQuestSort makeClass(const std::string& catalogName); + static WoweeQuestSort makeProfession(const std::string& catalogName); +}; + +} // namespace pipeline +} // namespace wowee diff --git a/src/pipeline/wowee_quest_sorts.cpp b/src/pipeline/wowee_quest_sorts.cpp new file mode 100644 index 00000000..11879334 --- /dev/null +++ b/src/pipeline/wowee_quest_sorts.cpp @@ -0,0 +1,242 @@ +#include "pipeline/wowee_quest_sorts.hpp" + +#include +#include +#include + +namespace wowee { +namespace pipeline { + +namespace { + +constexpr char kMagic[4] = {'W', 'Q', 'S', 'O'}; +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) != ".wqso") { + base += ".wqso"; + } + return base; +} + +} // namespace + +const WoweeQuestSort::Entry* +WoweeQuestSort::findById(uint32_t sortId) const { + for (const auto& e : entries) if (e.sortId == sortId) return &e; + return nullptr; +} + +const char* WoweeQuestSort::sortKindName(uint8_t k) { + switch (k) { + case General: return "general"; + case ClassQuest: return "class"; + case Profession: return "profession"; + case Daily: return "daily"; + case Holiday: return "holiday"; + case Reputation: return "reputation"; + case Dungeon: return "dungeon"; + case Raid: return "raid"; + case Heroic: return "heroic"; + case Repeatable: return "repeatable"; + case PvP: return "pvp"; + case Tournament: return "tournament"; + default: return "unknown"; + } +} + +bool WoweeQuestSortLoader::save(const WoweeQuestSort& 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.sortId); + writeStr(os, e.name); + writeStr(os, e.displayName); + writeStr(os, e.description); + writeStr(os, e.iconPath); + writePOD(os, e.sortKind); + writePOD(os, e.displayPriority); + writePOD(os, e.targetProfessionId); + uint8_t pad = 0; + writePOD(os, pad); + writePOD(os, e.targetClassMask); + writePOD(os, e.targetFactionId); + } + return os.good(); +} + +WoweeQuestSort WoweeQuestSortLoader::load(const std::string& basePath) { + WoweeQuestSort 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.sortId)) { + out.entries.clear(); return out; + } + if (!readStr(is, e.name) || !readStr(is, e.displayName) || + !readStr(is, e.description) || !readStr(is, e.iconPath)) { + out.entries.clear(); return out; + } + if (!readPOD(is, e.sortKind) || + !readPOD(is, e.displayPriority) || + !readPOD(is, e.targetProfessionId)) { + out.entries.clear(); return out; + } + uint8_t pad = 0; + if (!readPOD(is, pad)) { out.entries.clear(); return out; } + if (!readPOD(is, e.targetClassMask) || + !readPOD(is, e.targetFactionId)) { + out.entries.clear(); return out; + } + } + return out; +} + +bool WoweeQuestSortLoader::exists(const std::string& basePath) { + std::ifstream is(normalizePath(basePath), std::ios::binary); + return is.good(); +} + +WoweeQuestSort WoweeQuestSortLoader::makeStarter( + const std::string& catalogName) { + WoweeQuestSort c; + c.name = catalogName; + auto add = [&](uint32_t id, const char* name, const char* display, + uint8_t kind, uint8_t prio, const char* desc) { + WoweeQuestSort::Entry e; + e.sortId = id; e.name = name; e.displayName = display; + e.description = desc; + e.sortKind = kind; + e.displayPriority = prio; + e.iconPath = std::string("Interface/Icons/INV_Misc_QuestionMark_") + + name + ".blp"; + c.entries.push_back(e); + }; + add(1, "General", "General Quests", + WoweeQuestSort::General, 0, + "Default catch-all category for area / story quests."); + add(2, "Daily", "Daily Quests", + WoweeQuestSort::Daily, 10, + "Quests that reset every 24 hours."); + add(3, "Repeatable", "Repeatable Quests", + WoweeQuestSort::Repeatable, 20, + "Non-daily quests that can be repeated infinitely " + "(turn-in tokens, faction repeatables)."); + return c; +} + +WoweeQuestSort WoweeQuestSortLoader::makeClass( + const std::string& catalogName) { + WoweeQuestSort c; + c.name = catalogName; + auto add = [&](uint32_t id, const char* className, + uint32_t classBit) { + WoweeQuestSort::Entry e; + e.sortId = id; + e.name = std::string("Class") + className; + e.displayName = std::string(className) + " Quests"; + e.description = std::string(className) + + "-only quest line (trainer / class trial)."; + e.iconPath = std::string("Interface/Icons/Class_") + + className + ".blp"; + e.sortKind = WoweeQuestSort::ClassQuest; + e.displayPriority = 1; + e.targetClassMask = classBit; + c.entries.push_back(e); + }; + // Class bits match WCHC.classId enum. + add(100, "Warrior", 1u << 1); + add(101, "Paladin", 1u << 2); + add(102, "Hunter", 1u << 3); + add(103, "Rogue", 1u << 4); + add(104, "Priest", 1u << 5); + add(105, "DeathKnight", 1u << 6); + add(106, "Shaman", 1u << 7); + add(107, "Mage", 1u << 8); + add(108, "Warlock", 1u << 9); + add(109, "Druid", 1u << 11); + return c; +} + +WoweeQuestSort WoweeQuestSortLoader::makeProfession( + const std::string& catalogName) { + WoweeQuestSort c; + c.name = catalogName; + auto add = [&](uint32_t id, const char* profName, + uint8_t professionId) { + WoweeQuestSort::Entry e; + e.sortId = id; + e.name = std::string("Prof") + profName; + e.displayName = std::string(profName) + " Quests"; + e.description = std::string(profName) + + "-specific quest (recipe acquisition, " + "trainer reward)."; + e.iconPath = std::string("Interface/Icons/Trade_") + + profName + ".blp"; + e.sortKind = WoweeQuestSort::Profession; + e.displayPriority = 2; + e.targetProfessionId = professionId; + c.entries.push_back(e); + }; + // Profession IDs match WTSK.profession enum. + add(200, "Blacksmithing", 0); + add(201, "Tailoring", 1); + add(202, "Engineering", 2); + add(203, "Alchemy", 3); + add(204, "Enchanting", 4); + add(205, "Leatherworking", 5); + add(206, "Jewelcrafting", 6); + add(207, "Inscription", 7); + return c; +} + +} // namespace pipeline +} // namespace wowee diff --git a/tools/editor/cli_arg_required.cpp b/tools/editor/cli_arg_required.cpp index 464b57cc..bc70219e 100644 --- a/tools/editor/cli_arg_required.cpp +++ b/tools/editor/cli_arg_required.cpp @@ -203,6 +203,8 @@ const char* const kArgRequired[] = { "--gen-umv", "--gen-umv-flight", "--gen-umv-buffs", "--info-wumv", "--validate-wumv", "--export-wumv-json", "--import-wumv-json", + "--gen-qso", "--gen-qso-class", "--gen-qso-profession", + "--info-wqso", "--validate-wqso", "--gen-weather-temperate", "--gen-weather-arctic", "--gen-weather-desert", "--gen-weather-stormy", "--gen-zone-atmosphere", diff --git a/tools/editor/cli_dispatch.cpp b/tools/editor/cli_dispatch.cpp index 2b499f61..f8cfaa9e 100644 --- a/tools/editor/cli_dispatch.cpp +++ b/tools/editor/cli_dispatch.cpp @@ -102,6 +102,7 @@ #include "cli_item_suffixes_catalog.hpp" #include "cli_combat_ratings_catalog.hpp" #include "cli_unit_movement_catalog.hpp" +#include "cli_quest_sorts_catalog.hpp" #include "cli_quest_objective.hpp" #include "cli_quest_reward.hpp" #include "cli_clone.hpp" @@ -245,6 +246,7 @@ constexpr DispatchFn kDispatchTable[] = { handleItemSuffixesCatalog, handleCombatRatingsCatalog, handleUnitMovementCatalog, + handleQuestSortsCatalog, handleQuestObjective, handleQuestReward, handleClone, diff --git a/tools/editor/cli_format_table.cpp b/tools/editor/cli_format_table.cpp index f848feb7..4f5d9530 100644 --- a/tools/editor/cli_format_table.cpp +++ b/tools/editor/cli_format_table.cpp @@ -69,6 +69,7 @@ constexpr FormatMagicEntry kFormats[] = { {{'W','S','U','F'}, ".wsuf", "items", "--info-wsuf", "Item random-suffix catalog"}, {{'W','C','R','R'}, ".wcrr", "stats", "--info-wcrr", "Combat rating conversion catalog"}, {{'W','U','M','V'}, ".wumv", "stats", "--info-wumv", "Unit movement type catalog"}, + {{'W','Q','S','O'}, ".wqso", "quests", "--info-wqso", "Quest sort / category 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 f2aee719..6cc9d2eb 100644 --- a/tools/editor/cli_help.cpp +++ b/tools/editor/cli_help.cpp @@ -1671,6 +1671,16 @@ void printUsage(const char* argv0) { std::printf(" Export binary .wumv to a human-editable JSON sidecar (defaults to .wumv.json)\n"); std::printf(" --import-wumv-json [out-base]\n"); std::printf(" Import a .wumv.json sidecar back into binary .wumv (accepts movementCategory int OR name string; multipliers default to 1.0/1.4)\n"); + std::printf(" --gen-qso [name]\n"); + std::printf(" Emit .wqso starter: 3 generic sorts (General catch-all / Daily reset / Repeatable non-daily)\n"); + std::printf(" --gen-qso-class [name]\n"); + std::printf(" Emit .wqso 10 class-specific sorts (Warrior / Paladin / Hunter / Rogue / Priest / DK / Shaman / Mage / Warlock / Druid)\n"); + std::printf(" --gen-qso-profession [name]\n"); + std::printf(" Emit .wqso 8 profession sorts (Blacksmithing / Tailoring / Engineering / Alchemy / Enchanting / Leatherworking / Jewelcrafting / Inscription)\n"); + std::printf(" --info-wqso [--json]\n"); + std::printf(" Print WQSO entries (id / kind / display priority / classMask / profession / faction / displayName)\n"); + std::printf(" --validate-wqso [--json]\n"); + std::printf(" Static checks: id+name+displayName required, kind 0..11, ClassQuest needs classMask>0, Reputation needs factionId>0\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 dc63fbb9..ddf5ae6a 100644 --- a/tools/editor/cli_list_formats.cpp +++ b/tools/editor/cli_list_formats.cpp @@ -91,6 +91,7 @@ constexpr FormatRow kFormats[] = { {"WSUF", ".wsuf", "items", "ItemRandomProperties + Suffix", "Item random-suffix bonus catalog"}, {"WCRR", ".wcrr", "stats", "gtCombatRatings.dbc + curves", "Combat rating conversion catalog"}, {"WUMV", ".wumv", "stats", "UnitMovement.dbc + speed mods", "Unit movement type / speed catalog"}, + {"WQSO", ".wqso", "quests", "QuestSort.dbc + QuestInfo cats", "Quest sort / category catalog"}, // Additional pipeline catalogs without the alternating // gen/info/validate CLI surface (loaded by the engine diff --git a/tools/editor/cli_quest_sorts_catalog.cpp b/tools/editor/cli_quest_sorts_catalog.cpp new file mode 100644 index 00000000..a05a3757 --- /dev/null +++ b/tools/editor/cli_quest_sorts_catalog.cpp @@ -0,0 +1,249 @@ +#include "cli_quest_sorts_catalog.hpp" +#include "cli_arg_parse.hpp" +#include "cli_box_emitter.hpp" + +#include "pipeline/wowee_quest_sorts.hpp" +#include + +#include +#include +#include +#include +#include +#include + +namespace wowee { +namespace editor { +namespace cli { + +namespace { + +std::string stripWqsoExt(std::string base) { + stripExt(base, ".wqso"); + return base; +} + +bool saveOrError(const wowee::pipeline::WoweeQuestSort& c, + const std::string& base, const char* cmd) { + if (!wowee::pipeline::WoweeQuestSortLoader::save(c, base)) { + std::fprintf(stderr, "%s: failed to save %s.wqso\n", + cmd, base.c_str()); + return false; + } + return true; +} + +void printGenSummary(const wowee::pipeline::WoweeQuestSort& c, + const std::string& base) { + std::printf("Wrote %s.wqso\n", base.c_str()); + std::printf(" catalog : %s\n", c.name.c_str()); + std::printf(" sorts : %zu\n", c.entries.size()); +} + +int handleGenStarter(int& i, int argc, char** argv) { + std::string base = argv[++i]; + std::string name = "StarterQuestSorts"; + if (parseOptArg(i, argc, argv)) name = argv[++i]; + base = stripWqsoExt(base); + auto c = wowee::pipeline::WoweeQuestSortLoader::makeStarter(name); + if (!saveOrError(c, base, "gen-qso")) return 1; + printGenSummary(c, base); + return 0; +} + +int handleGenClass(int& i, int argc, char** argv) { + std::string base = argv[++i]; + std::string name = "ClassQuestSorts"; + if (parseOptArg(i, argc, argv)) name = argv[++i]; + base = stripWqsoExt(base); + auto c = wowee::pipeline::WoweeQuestSortLoader::makeClass(name); + if (!saveOrError(c, base, "gen-qso-class")) return 1; + printGenSummary(c, base); + return 0; +} + +int handleGenProfession(int& i, int argc, char** argv) { + std::string base = argv[++i]; + std::string name = "ProfessionQuestSorts"; + if (parseOptArg(i, argc, argv)) name = argv[++i]; + base = stripWqsoExt(base); + auto c = wowee::pipeline::WoweeQuestSortLoader::makeProfession(name); + if (!saveOrError(c, base, "gen-qso-profession")) 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 = stripWqsoExt(base); + if (!wowee::pipeline::WoweeQuestSortLoader::exists(base)) { + std::fprintf(stderr, "WQSO not found: %s.wqso\n", base.c_str()); + return 1; + } + auto c = wowee::pipeline::WoweeQuestSortLoader::load(base); + if (jsonOut) { + nlohmann::json j; + j["wqso"] = base + ".wqso"; + j["name"] = c.name; + j["count"] = c.entries.size(); + nlohmann::json arr = nlohmann::json::array(); + for (const auto& e : c.entries) { + arr.push_back({ + {"sortId", e.sortId}, + {"name", e.name}, + {"displayName", e.displayName}, + {"description", e.description}, + {"iconPath", e.iconPath}, + {"sortKind", e.sortKind}, + {"sortKindName", wowee::pipeline::WoweeQuestSort::sortKindName(e.sortKind)}, + {"displayPriority", e.displayPriority}, + {"targetProfessionId", e.targetProfessionId}, + {"targetClassMask", e.targetClassMask}, + {"targetFactionId", e.targetFactionId}, + }); + } + j["entries"] = arr; + std::printf("%s\n", j.dump(2).c_str()); + return 0; + } + std::printf("WQSO: %s.wqso\n", base.c_str()); + std::printf(" catalog : %s\n", c.name.c_str()); + std::printf(" sorts : %zu\n", c.entries.size()); + if (c.entries.empty()) return 0; + std::printf(" id kind prio classMask profId factionId displayName\n"); + for (const auto& e : c.entries) { + std::printf(" %4u %-11s %3u 0x%08x %5u %5u %s\n", + e.sortId, + wowee::pipeline::WoweeQuestSort::sortKindName(e.sortKind), + e.displayPriority, + e.targetClassMask, e.targetProfessionId, + e.targetFactionId, + e.displayName.c_str()); + } + return 0; +} + +int handleValidate(int& i, int argc, char** argv) { + std::string base = argv[++i]; + bool jsonOut = consumeJsonFlag(i, argc, argv); + base = stripWqsoExt(base); + if (!wowee::pipeline::WoweeQuestSortLoader::exists(base)) { + std::fprintf(stderr, + "validate-wqso: WQSO not found: %s.wqso\n", base.c_str()); + return 1; + } + auto c = wowee::pipeline::WoweeQuestSortLoader::load(base); + std::vector errors; + std::vector warnings; + if (c.entries.empty()) { + warnings.push_back("catalog has zero entries"); + } + std::vector idsSeen; + 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.sortId); + if (!e.name.empty()) ctx += " " + e.name; + ctx += ")"; + if (e.sortId == 0) + errors.push_back(ctx + ": sortId is 0"); + if (e.name.empty()) + errors.push_back(ctx + ": name is empty"); + if (e.displayName.empty()) + errors.push_back(ctx + + ": displayName is empty (UI would show no header)"); + if (e.sortKind > wowee::pipeline::WoweeQuestSort::Tournament) { + errors.push_back(ctx + ": sortKind " + + std::to_string(e.sortKind) + " not in 0..11"); + } + // ClassQuest sortKind requires a non-zero classMask + // — otherwise it's not actually class-restricted. + if (e.sortKind == wowee::pipeline::WoweeQuestSort::ClassQuest && + e.targetClassMask == 0) { + errors.push_back(ctx + + ": ClassQuest kind with targetClassMask=0 " + "(should pick at least one class bit)"); + } + // Profession sortKind requires a profession ID hint — + // 0 means Blacksmithing in the WTSK enum but having + // it left as zero with non-Blacksmithing kind might + // be a typo. Warn rather than error since 0 IS a + // valid profession value. + if (e.sortKind == wowee::pipeline::WoweeQuestSort::Profession && + e.targetProfessionId == 0 && + e.name.find("Blacksmith") == std::string::npos) { + warnings.push_back(ctx + + ": Profession kind with targetProfessionId=0 " + "(0=Blacksmithing in WTSK; verify intent)"); + } + // Reputation sortKind needs a factionId. + if (e.sortKind == wowee::pipeline::WoweeQuestSort::Reputation && + e.targetFactionId == 0) { + errors.push_back(ctx + + ": Reputation kind with targetFactionId=0 " + "(no faction to grind reputation with)"); + } + for (uint32_t prev : idsSeen) { + if (prev == e.sortId) { + errors.push_back(ctx + ": duplicate sortId"); + break; + } + } + idsSeen.push_back(e.sortId); + } + bool ok = errors.empty(); + if (jsonOut) { + nlohmann::json j; + j["wqso"] = base + ".wqso"; + 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-wqso: %s.wqso\n", base.c_str()); + if (ok && warnings.empty()) { + std::printf(" OK — %zu sorts, all sortIds unique, all kind-target pairings consistent\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 handleQuestSortsCatalog(int& i, int argc, char** argv, + int& outRc) { + if (std::strcmp(argv[i], "--gen-qso") == 0 && i + 1 < argc) { + outRc = handleGenStarter(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--gen-qso-class") == 0 && i + 1 < argc) { + outRc = handleGenClass(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--gen-qso-profession") == 0 && + i + 1 < argc) { + outRc = handleGenProfession(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--info-wqso") == 0 && i + 1 < argc) { + outRc = handleInfo(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--validate-wqso") == 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_quest_sorts_catalog.hpp b/tools/editor/cli_quest_sorts_catalog.hpp new file mode 100644 index 00000000..9060b2b2 --- /dev/null +++ b/tools/editor/cli_quest_sorts_catalog.hpp @@ -0,0 +1,12 @@ +#pragma once + +namespace wowee { +namespace editor { +namespace cli { + +bool handleQuestSortsCatalog(int& i, int argc, char** argv, + int& outRc); + +} // namespace cli +} // namespace editor +} // namespace wowee