From d547de61f51e9bb432eb622f5169d6127995490d Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sat, 9 May 2026 21:05:49 -0700 Subject: [PATCH] feat(pipeline): add WSUF (Wowee Item Random Suffix) catalog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 64th open format — replaces ItemRandomProperties.dbc + ItemRandomSuffix.dbc plus the AzerothCore-style suffix-roll tables. Defines random "of the X" suffixes that roll on green and blue items at world drop ("Sturdy Cloth Cap of the Bear" = base item + STR + STA suffix). 5 suffix categories (Generic / Elemental / Defensive / PvPSuffix / Crafted), per-suffix item-quality bracket gating (only blue+ items can roll PvPSuffix), restricted-slot mask that limits which equipment slots a suffix can apply to (15 slot bits matching WCEQ slot enum), and up to 5 stat bonus slots per suffix matching WoW canonical max. statValuePoints isn't an absolute number — it's a scaling base that the runtime multiplies by an item-level coefficient to compute the final per-item bonus, so "of the Bear" gives proportionally more strength on a level-60 item than on a level-20 item. Cross-references with prior formats — statKind values match WIT.statType enum (STR=4, AGI=3, INT=5, SPI=6, STA=7) so item generators roll consistent stats with base items. CLI: --gen-suf (3 generic stat triads — Bear STR+STA, Eagle INT+SPI, Tiger STR+AGI), --gen-suf-magical (4 elemental spell-power suffixes restricted to caster-eligible slots), --gen-suf-pvp (3 PvPSuffix entries with resilience + offensive stats, blue+ quality only), --info-wsuf, --validate-wsuf with --json variants. Validator catches id+name required, category 0..4, quality range valid (0..7 covers heirloom), itemQuality floor<=ceiling, stat-kind/value pairing (kind=0 with value!=0 is a typo, vice versa), and no-stats warning (suffix renames item without changing it). Format graph: 63 → 64 binary formats. CLI flag count: 854 → 861. --- CMakeLists.txt | 3 + include/pipeline/wowee_item_suffixes.hpp | 128 ++++++++++ src/pipeline/wowee_item_suffixes.cpp | 244 ++++++++++++++++++ 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_item_suffixes_catalog.cpp | 274 +++++++++++++++++++++ tools/editor/cli_item_suffixes_catalog.hpp | 12 + tools/editor/cli_list_formats.cpp | 1 + 10 files changed, 677 insertions(+) create mode 100644 include/pipeline/wowee_item_suffixes.hpp create mode 100644 src/pipeline/wowee_item_suffixes.cpp create mode 100644 tools/editor/cli_item_suffixes_catalog.cpp create mode 100644 tools/editor/cli_item_suffixes_catalog.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index cb52e07e..b42175dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -652,6 +652,7 @@ set(WOWEE_SOURCES src/pipeline/wowee_bags.cpp src/pipeline/wowee_runes.cpp src/pipeline/wowee_loading_screens.cpp + src/pipeline/wowee_item_suffixes.cpp src/pipeline/custom_zone_discovery.cpp src/pipeline/dbc_layout.cpp @@ -1458,6 +1459,7 @@ add_executable(wowee_editor tools/editor/cli_bags_catalog.cpp tools/editor/cli_runes_catalog.cpp tools/editor/cli_loading_screens_catalog.cpp + tools/editor/cli_item_suffixes_catalog.cpp tools/editor/cli_quest_objective.cpp tools/editor/cli_quest_reward.cpp tools/editor/cli_clone.cpp @@ -1588,6 +1590,7 @@ add_executable(wowee_editor src/pipeline/wowee_bags.cpp src/pipeline/wowee_runes.cpp src/pipeline/wowee_loading_screens.cpp + src/pipeline/wowee_item_suffixes.cpp src/pipeline/custom_zone_discovery.cpp src/pipeline/terrain_mesh.cpp diff --git a/include/pipeline/wowee_item_suffixes.hpp b/include/pipeline/wowee_item_suffixes.hpp new file mode 100644 index 00000000..853a309c --- /dev/null +++ b/include/pipeline/wowee_item_suffixes.hpp @@ -0,0 +1,128 @@ +#pragma once + +#include +#include +#include + +namespace wowee { +namespace pipeline { + +// Wowee Open Item Random Suffix catalog (.wsuf) — novel +// replacement for Blizzard's ItemRandomProperties.dbc + +// ItemRandomSuffix.dbc plus the AzerothCore-style suffix- +// roll tables. Defines the random "of the X" suffixes and +// "Y of the Z" prefixes that randomly roll on green and +// blue items at world drop, e.g. "Sturdy Cloth Cap of the +// Bear" = base item + Strength + Stamina suffix. +// +// Each entry binds a suffix name to up to 5 stat bonuses +// (matches WoW canonical max). statValuePoints isn't an +// absolute number — it's a scaling base that the runtime +// multiplies by an item-level coefficient to compute the +// final per-item bonus. This way "of the Bear" gives +// proportionally more strength on a level-60 item than on +// a level-20 item. +// +// Cross-references with previously-added formats: +// WSUF.entry.statKind values match the WIT.entry.statType +// enum (Strength=4, Intellect=5, +// Stamina=7 etc.) so item generators +// roll consistent stats with base items. +// WSUF.entry.restrictedSlotMask uses the same equipment +// slot bit positions as WCEQ. +// +// Binary layout (little-endian): +// magic[4] = "WSUF" +// version (uint32) = current 1 +// nameLen + name (catalog label) +// entryCount (uint32) +// entries (each): +// suffixId (uint32) +// nameLen + name +// descLen + description +// itemQualityFloor (uint8) / itemQualityCeiling (uint8) / +// suffixCategory (uint8) / pad[1] +// restrictedSlotMask (uint32) +// statKind1..5 (uint8) [5 bytes] / pad[3] +// statValuePoints1..5 (uint16) [10 bytes] +struct WoweeItemSuffix { + static constexpr size_t kMaxStats = 5; + + enum SuffixCategory : uint8_t { + Generic = 0, // canonical "of the X" stat suffix + Elemental = 1, // "of Fire" / "of Frost" — magic damage + Defensive = 2, // "of Defense" / "of Toughness" + PvPSuffix = 3, // PvP-themed (resilience, honor) + Crafted = 4, // tradeskill-applied (jewelcrafting socket) + }; + + // Equipment slot bits for restrictedSlotMask. 0 = no + // restriction (suffix can apply to any slot). + static constexpr uint32_t kSlotHead = 1u << 0; + static constexpr uint32_t kSlotNeck = 1u << 1; + static constexpr uint32_t kSlotShoulder = 1u << 2; + static constexpr uint32_t kSlotChest = 1u << 3; + static constexpr uint32_t kSlotWaist = 1u << 4; + static constexpr uint32_t kSlotLegs = 1u << 5; + static constexpr uint32_t kSlotFeet = 1u << 6; + static constexpr uint32_t kSlotWrist = 1u << 7; + static constexpr uint32_t kSlotHands = 1u << 8; + static constexpr uint32_t kSlotFinger = 1u << 9; + static constexpr uint32_t kSlotTrinket = 1u << 10; + static constexpr uint32_t kSlotWeapon = 1u << 11; + static constexpr uint32_t kSlotShield = 1u << 12; + static constexpr uint32_t kSlotRanged = 1u << 13; + static constexpr uint32_t kSlotCloak = 1u << 14; + static constexpr uint32_t kSlotAny = 0; + + struct Entry { + uint32_t suffixId = 0; + std::string name; + std::string description; + uint8_t itemQualityFloor = 0; // 0 = poor, 4 = epic + uint8_t itemQualityCeiling = 4; + uint8_t suffixCategory = Generic; + uint32_t restrictedSlotMask = kSlotAny; + uint8_t statKind[kMaxStats] = {0, 0, 0, 0, 0}; + uint16_t statValuePoints[kMaxStats] = {0, 0, 0, 0, 0}; + }; + + std::string name; + std::vector entries; + + bool isValid() const { return !entries.empty(); } + + const Entry* findById(uint32_t suffixId) const; + + static const char* suffixCategoryName(uint8_t c); +}; + +class WoweeItemSuffixLoader { +public: + static bool save(const WoweeItemSuffix& cat, + const std::string& basePath); + static WoweeItemSuffix load(const std::string& basePath); + static bool exists(const std::string& basePath); + + // Preset emitters used by --gen-suf* variants. + // + // makeStarter — 3 common Generic stat suffixes + // ("of the Bear" STR+STA, "of the + // Eagle" INT+SPI, "of the Tiger" + // STR+AGI) covering the canonical + // greens-tier stat triads. + // makeMagical — 4 Elemental suffixes ("of Fire", + // "of Frost", "of Shadow", "of + // Arcane") — flat spell power into a + // single school for caster gear. + // makePvP — 3 PvPSuffix-category suffixes ("of + // the Champion", "of the Gladiator", + // "of Resilience") combining + // resilience with offensive stats. + static WoweeItemSuffix makeStarter(const std::string& catalogName); + static WoweeItemSuffix makeMagical(const std::string& catalogName); + static WoweeItemSuffix makePvP(const std::string& catalogName); +}; + +} // namespace pipeline +} // namespace wowee diff --git a/src/pipeline/wowee_item_suffixes.cpp b/src/pipeline/wowee_item_suffixes.cpp new file mode 100644 index 00000000..81b3bf5a --- /dev/null +++ b/src/pipeline/wowee_item_suffixes.cpp @@ -0,0 +1,244 @@ +#include "pipeline/wowee_item_suffixes.hpp" + +#include +#include +#include + +namespace wowee { +namespace pipeline { + +namespace { + +constexpr char kMagic[4] = {'W', 'S', 'U', '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) != ".wsuf") { + base += ".wsuf"; + } + return base; +} + +} // namespace + +const WoweeItemSuffix::Entry* +WoweeItemSuffix::findById(uint32_t suffixId) const { + for (const auto& e : entries) + if (e.suffixId == suffixId) return &e; + return nullptr; +} + +const char* WoweeItemSuffix::suffixCategoryName(uint8_t c) { + switch (c) { + case Generic: return "generic"; + case Elemental: return "elemental"; + case Defensive: return "defensive"; + case PvPSuffix: return "pvp"; + case Crafted: return "crafted"; + default: return "unknown"; + } +} + +bool WoweeItemSuffixLoader::save(const WoweeItemSuffix& 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.suffixId); + writeStr(os, e.name); + writeStr(os, e.description); + writePOD(os, e.itemQualityFloor); + writePOD(os, e.itemQualityCeiling); + writePOD(os, e.suffixCategory); + uint8_t pad = 0; + writePOD(os, pad); + writePOD(os, e.restrictedSlotMask); + for (size_t k = 0; k < WoweeItemSuffix::kMaxStats; ++k) { + writePOD(os, e.statKind[k]); + } + uint8_t pad3[3] = {0, 0, 0}; + os.write(reinterpret_cast(pad3), 3); + for (size_t k = 0; k < WoweeItemSuffix::kMaxStats; ++k) { + writePOD(os, e.statValuePoints[k]); + } + } + return os.good(); +} + +WoweeItemSuffix WoweeItemSuffixLoader::load(const std::string& basePath) { + WoweeItemSuffix 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.suffixId)) { + out.entries.clear(); return out; + } + if (!readStr(is, e.name) || !readStr(is, e.description)) { + out.entries.clear(); return out; + } + if (!readPOD(is, e.itemQualityFloor) || + !readPOD(is, e.itemQualityCeiling) || + !readPOD(is, e.suffixCategory)) { + out.entries.clear(); return out; + } + uint8_t pad = 0; + if (!readPOD(is, pad)) { out.entries.clear(); return out; } + if (!readPOD(is, e.restrictedSlotMask)) { + out.entries.clear(); return out; + } + for (size_t k = 0; k < WoweeItemSuffix::kMaxStats; ++k) { + if (!readPOD(is, e.statKind[k])) { + out.entries.clear(); return out; + } + } + uint8_t pad3[3]; + is.read(reinterpret_cast(pad3), 3); + if (is.gcount() != 3) { out.entries.clear(); return out; } + for (size_t k = 0; k < WoweeItemSuffix::kMaxStats; ++k) { + if (!readPOD(is, e.statValuePoints[k])) { + out.entries.clear(); return out; + } + } + } + return out; +} + +bool WoweeItemSuffixLoader::exists(const std::string& basePath) { + std::ifstream is(normalizePath(basePath), std::ios::binary); + return is.good(); +} + +WoweeItemSuffix WoweeItemSuffixLoader::makeStarter( + const std::string& catalogName) { + WoweeItemSuffix c; + c.name = catalogName; + auto add = [&](uint32_t id, const char* name, uint8_t s1, + uint16_t v1, uint8_t s2, uint16_t v2, + const char* desc) { + WoweeItemSuffix::Entry e; + e.suffixId = id; e.name = name; e.description = desc; + e.itemQualityFloor = 2; // green minimum + e.itemQualityCeiling = 3; // blue maximum + e.suffixCategory = WoweeItemSuffix::Generic; + e.statKind[0] = s1; e.statValuePoints[0] = v1; + e.statKind[1] = s2; e.statValuePoints[1] = v2; + c.entries.push_back(e); + }; + // statKind values match WIT.statType: + // 4 = STR, 3 = AGI, 5 = INT, 6 = SPI, 7 = STA. + add(1, "of the Bear", 4, 100, 7, 80, + "Strength + Stamina — favored by tanks."); + add(2, "of the Eagle", 5, 100, 6, 60, + "Intellect + Spirit — favored by casters."); + add(3, "of the Tiger", 4, 100, 3, 80, + "Strength + Agility — favored by physical DPS."); + return c; +} + +WoweeItemSuffix WoweeItemSuffixLoader::makeMagical( + const std::string& catalogName) { + WoweeItemSuffix c; + c.name = catalogName; + auto add = [&](uint32_t id, const char* name, uint8_t schoolStat, + uint16_t value, const char* desc) { + WoweeItemSuffix::Entry e; + e.suffixId = id; e.name = name; e.description = desc; + e.itemQualityFloor = 2; + e.itemQualityCeiling = 4; + e.suffixCategory = WoweeItemSuffix::Elemental; + // schoolStat values 30..36 represent per-school spell + // power — Fire=30, Frost=31, Shadow=32, Arcane=33, + // Holy=34, Nature=35, Healing=36 (engine-internal + // mapping outside the WIT canonical set). + e.statKind[0] = schoolStat; + e.statValuePoints[0] = value; + e.restrictedSlotMask = + WoweeItemSuffix::kSlotHead | WoweeItemSuffix::kSlotChest | + WoweeItemSuffix::kSlotShoulder | WoweeItemSuffix::kSlotLegs | + WoweeItemSuffix::kSlotHands | WoweeItemSuffix::kSlotWeapon; + c.entries.push_back(e); + }; + add(100, "of Fire", 30, 150, "+ Fire spell power."); + add(101, "of Frost", 31, 150, "+ Frost spell power."); + add(102, "of Shadow", 32, 150, "+ Shadow spell power."); + add(103, "of Arcane", 33, 150, "+ Arcane spell power."); + return c; +} + +WoweeItemSuffix WoweeItemSuffixLoader::makePvP( + const std::string& catalogName) { + WoweeItemSuffix c; + c.name = catalogName; + auto add = [&](uint32_t id, const char* name, uint8_t s1, + uint16_t v1, uint8_t s2, uint16_t v2, + uint8_t s3, uint16_t v3, const char* desc) { + WoweeItemSuffix::Entry e; + e.suffixId = id; e.name = name; e.description = desc; + e.itemQualityFloor = 3; // PvP suffixes only on blues+ + e.itemQualityCeiling = 4; + e.suffixCategory = WoweeItemSuffix::PvPSuffix; + // statKind 50 = Resilience (engine-internal, outside + // the WIT canonical set). + e.statKind[0] = s1; e.statValuePoints[0] = v1; + e.statKind[1] = s2; e.statValuePoints[1] = v2; + e.statKind[2] = s3; e.statValuePoints[2] = v3; + c.entries.push_back(e); + }; + add(200, "of the Champion", 50, 80, 4, 60, 7, 60, + "Resilience + Strength + Stamina — melee PvP."); + add(201, "of the Gladiator", 50, 80, 5, 60, 6, 40, + "Resilience + Intellect + Spirit — caster PvP."); + add(202, "of Resilience", 50, 120, 7, 80, 0, 0, + "Pure resilience + extra Stamina — peak PvP defense."); + return c; +} + +} // namespace pipeline +} // namespace wowee diff --git a/tools/editor/cli_arg_required.cpp b/tools/editor/cli_arg_required.cpp index 40ea9942..58e3230a 100644 --- a/tools/editor/cli_arg_required.cpp +++ b/tools/editor/cli_arg_required.cpp @@ -194,6 +194,8 @@ const char* const kArgRequired[] = { "--gen-lds", "--gen-lds-instances", "--gen-lds-raid", "--info-wlds", "--validate-wlds", "--export-wlds-json", "--import-wlds-json", + "--gen-suf", "--gen-suf-magical", "--gen-suf-pvp", + "--info-wsuf", "--validate-wsuf", "--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 8eee0453..2d1522f5 100644 --- a/tools/editor/cli_dispatch.cpp +++ b/tools/editor/cli_dispatch.cpp @@ -99,6 +99,7 @@ #include "cli_bags_catalog.hpp" #include "cli_runes_catalog.hpp" #include "cli_loading_screens_catalog.hpp" +#include "cli_item_suffixes_catalog.hpp" #include "cli_quest_objective.hpp" #include "cli_quest_reward.hpp" #include "cli_clone.hpp" @@ -239,6 +240,7 @@ constexpr DispatchFn kDispatchTable[] = { handleBagsCatalog, handleRunesCatalog, handleLoadingScreensCatalog, + handleItemSuffixesCatalog, handleQuestObjective, handleQuestReward, handleClone, diff --git a/tools/editor/cli_format_table.cpp b/tools/editor/cli_format_table.cpp index 6e0b55bc..2788062b 100644 --- a/tools/editor/cli_format_table.cpp +++ b/tools/editor/cli_format_table.cpp @@ -66,6 +66,7 @@ constexpr FormatMagicEntry kFormats[] = { {{'W','B','N','K'}, ".wbnk", "items", "--info-wbnk", "Bag / bank slot catalog"}, {{'W','R','U','N'}, ".wrun", "spells", "--info-wrun", "Death Knight rune cost catalog"}, {{'W','L','D','S'}, ".wlds", "ui", "--info-wlds", "Loading screen catalog"}, + {{'W','S','U','F'}, ".wsuf", "items", "--info-wsuf", "Item random-suffix 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 ac06ec85..28f46664 100644 --- a/tools/editor/cli_help.cpp +++ b/tools/editor/cli_help.cpp @@ -1629,6 +1629,16 @@ void printUsage(const char* argv0) { std::printf(" Export binary .wlds to a human-editable JSON sidecar (defaults to .wlds.json)\n"); std::printf(" --import-wlds-json [out-base]\n"); std::printf(" Import a .wlds.json sidecar back into binary .wlds (accepts expansionRequired int OR name string)\n"); + std::printf(" --gen-suf [name]\n"); + std::printf(" Emit .wsuf starter: 3 stat-suffix entries (of the Bear STR+STA / of the Eagle INT+SPI / of the Tiger STR+AGI)\n"); + std::printf(" --gen-suf-magical [name]\n"); + std::printf(" Emit .wsuf 4 elemental suffixes (of Fire / of Frost / of Shadow / of Arcane) — flat per-school spell power\n"); + std::printf(" --gen-suf-pvp [name]\n"); + std::printf(" Emit .wsuf 3 PvPSuffix-category entries (of the Champion / of the Gladiator / of Resilience) blue+ only\n"); + std::printf(" --info-wsuf [--json]\n"); + std::printf(" Print WSUF entries (id / category / quality range / restricted slot mask / # populated stat slots / name)\n"); + std::printf(" --validate-wsuf [--json]\n"); + std::printf(" Static checks: id+name required, category 0..4, quality range valid (0..7), stat-kind/value pairing, no-stats warning\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_item_suffixes_catalog.cpp b/tools/editor/cli_item_suffixes_catalog.cpp new file mode 100644 index 00000000..24d5f95a --- /dev/null +++ b/tools/editor/cli_item_suffixes_catalog.cpp @@ -0,0 +1,274 @@ +#include "cli_item_suffixes_catalog.hpp" +#include "cli_arg_parse.hpp" +#include "cli_box_emitter.hpp" + +#include "pipeline/wowee_item_suffixes.hpp" +#include + +#include +#include +#include +#include +#include +#include + +namespace wowee { +namespace editor { +namespace cli { + +namespace { + +std::string stripWsufExt(std::string base) { + stripExt(base, ".wsuf"); + return base; +} + +bool saveOrError(const wowee::pipeline::WoweeItemSuffix& c, + const std::string& base, const char* cmd) { + if (!wowee::pipeline::WoweeItemSuffixLoader::save(c, base)) { + std::fprintf(stderr, "%s: failed to save %s.wsuf\n", + cmd, base.c_str()); + return false; + } + return true; +} + +void printGenSummary(const wowee::pipeline::WoweeItemSuffix& c, + const std::string& base) { + std::printf("Wrote %s.wsuf\n", base.c_str()); + std::printf(" catalog : %s\n", c.name.c_str()); + std::printf(" suffixes : %zu\n", c.entries.size()); +} + +int handleGenStarter(int& i, int argc, char** argv) { + std::string base = argv[++i]; + std::string name = "StarterSuffixes"; + if (parseOptArg(i, argc, argv)) name = argv[++i]; + base = stripWsufExt(base); + auto c = wowee::pipeline::WoweeItemSuffixLoader::makeStarter(name); + if (!saveOrError(c, base, "gen-suf")) return 1; + printGenSummary(c, base); + return 0; +} + +int handleGenMagical(int& i, int argc, char** argv) { + std::string base = argv[++i]; + std::string name = "MagicalSuffixes"; + if (parseOptArg(i, argc, argv)) name = argv[++i]; + base = stripWsufExt(base); + auto c = wowee::pipeline::WoweeItemSuffixLoader::makeMagical(name); + if (!saveOrError(c, base, "gen-suf-magical")) return 1; + printGenSummary(c, base); + return 0; +} + +int handleGenPvP(int& i, int argc, char** argv) { + std::string base = argv[++i]; + std::string name = "PvPSuffixes"; + if (parseOptArg(i, argc, argv)) name = argv[++i]; + base = stripWsufExt(base); + auto c = wowee::pipeline::WoweeItemSuffixLoader::makePvP(name); + if (!saveOrError(c, base, "gen-suf-pvp")) return 1; + printGenSummary(c, base); + return 0; +} + +void appendEntryJson(nlohmann::json& arr, + const wowee::pipeline::WoweeItemSuffix::Entry& e) { + nlohmann::json stats = nlohmann::json::array(); + for (size_t k = 0; + k < wowee::pipeline::WoweeItemSuffix::kMaxStats; ++k) { + if (e.statKind[k] == 0 && e.statValuePoints[k] == 0) continue; + stats.push_back({ + {"statKind", e.statKind[k]}, + {"statValuePoints", e.statValuePoints[k]}, + }); + } + arr.push_back({ + {"suffixId", e.suffixId}, + {"name", e.name}, + {"description", e.description}, + {"itemQualityFloor", e.itemQualityFloor}, + {"itemQualityCeiling", e.itemQualityCeiling}, + {"suffixCategory", e.suffixCategory}, + {"suffixCategoryName", wowee::pipeline::WoweeItemSuffix::suffixCategoryName(e.suffixCategory)}, + {"restrictedSlotMask", e.restrictedSlotMask}, + {"stats", stats}, + }); +} + +int handleInfo(int& i, int argc, char** argv) { + std::string base = argv[++i]; + bool jsonOut = consumeJsonFlag(i, argc, argv); + base = stripWsufExt(base); + if (!wowee::pipeline::WoweeItemSuffixLoader::exists(base)) { + std::fprintf(stderr, "WSUF not found: %s.wsuf\n", base.c_str()); + return 1; + } + auto c = wowee::pipeline::WoweeItemSuffixLoader::load(base); + if (jsonOut) { + nlohmann::json j; + j["wsuf"] = base + ".wsuf"; + j["name"] = c.name; + j["count"] = c.entries.size(); + nlohmann::json arr = nlohmann::json::array(); + for (const auto& e : c.entries) appendEntryJson(arr, e); + j["entries"] = arr; + std::printf("%s\n", j.dump(2).c_str()); + return 0; + } + std::printf("WSUF: %s.wsuf\n", base.c_str()); + std::printf(" catalog : %s\n", c.name.c_str()); + std::printf(" suffixes : %zu\n", c.entries.size()); + if (c.entries.empty()) return 0; + std::printf(" id category quality slotMask stats name\n"); + for (const auto& e : c.entries) { + size_t statCount = 0; + for (size_t k = 0; + k < wowee::pipeline::WoweeItemSuffix::kMaxStats; ++k) { + if (e.statKind[k] != 0 || e.statValuePoints[k] != 0) + ++statCount; + } + std::printf(" %4u %-10s %u-%u 0x%08x %zu/%zu %s\n", + e.suffixId, + wowee::pipeline::WoweeItemSuffix::suffixCategoryName(e.suffixCategory), + e.itemQualityFloor, e.itemQualityCeiling, + e.restrictedSlotMask, statCount, + wowee::pipeline::WoweeItemSuffix::kMaxStats, + 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 = stripWsufExt(base); + if (!wowee::pipeline::WoweeItemSuffixLoader::exists(base)) { + std::fprintf(stderr, + "validate-wsuf: WSUF not found: %s.wsuf\n", base.c_str()); + return 1; + } + auto c = wowee::pipeline::WoweeItemSuffixLoader::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.suffixId); + if (!e.name.empty()) ctx += " " + e.name; + ctx += ")"; + if (e.suffixId == 0) + errors.push_back(ctx + ": suffixId is 0"); + if (e.name.empty()) + errors.push_back(ctx + ": name is empty"); + if (e.suffixCategory > wowee::pipeline::WoweeItemSuffix::Crafted) { + errors.push_back(ctx + ": suffixCategory " + + std::to_string(e.suffixCategory) + " not in 0..4"); + } + if (e.itemQualityFloor > e.itemQualityCeiling) { + errors.push_back(ctx + ": itemQualityFloor " + + std::to_string(e.itemQualityFloor) + + " > itemQualityCeiling " + + std::to_string(e.itemQualityCeiling)); + } + if (e.itemQualityCeiling > 7) { + errors.push_back(ctx + ": itemQualityCeiling " + + std::to_string(e.itemQualityCeiling) + + " not in 0..7 (poor / common / uncommon / rare / " + "epic / legendary / artifact / heirloom)"); + } + // A suffix with no stats is mechanically meaningless — + // it would just rename the item without changing it. + bool anyStat = false; + for (size_t s = 0; + s < wowee::pipeline::WoweeItemSuffix::kMaxStats; ++s) { + if (e.statKind[s] != 0 || e.statValuePoints[s] != 0) { + anyStat = true; + // statKind must be paired with non-zero + // statValuePoints (and vice versa). + if (e.statKind[s] != 0 && e.statValuePoints[s] == 0) { + errors.push_back(ctx + ": stat slot " + + std::to_string(s) + " has statKind=" + + std::to_string(e.statKind[s]) + + " but statValuePoints=0"); + } + if (e.statKind[s] == 0 && e.statValuePoints[s] != 0) { + errors.push_back(ctx + ": stat slot " + + std::to_string(s) + + " has statValuePoints=" + + std::to_string(e.statValuePoints[s]) + + " but statKind=0"); + } + } + } + if (!anyStat) { + warnings.push_back(ctx + + ": no stats — suffix renames item but adds nothing"); + } + for (uint32_t prev : idsSeen) { + if (prev == e.suffixId) { + errors.push_back(ctx + ": duplicate suffixId"); + break; + } + } + idsSeen.push_back(e.suffixId); + } + bool ok = errors.empty(); + if (jsonOut) { + nlohmann::json j; + j["wsuf"] = base + ".wsuf"; + 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-wsuf: %s.wsuf\n", base.c_str()); + if (ok && warnings.empty()) { + std::printf(" OK — %zu suffixes, all suffixIds unique, all stat slots paired\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 handleItemSuffixesCatalog(int& i, int argc, char** argv, + int& outRc) { + if (std::strcmp(argv[i], "--gen-suf") == 0 && i + 1 < argc) { + outRc = handleGenStarter(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--gen-suf-magical") == 0 && i + 1 < argc) { + outRc = handleGenMagical(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--gen-suf-pvp") == 0 && i + 1 < argc) { + outRc = handleGenPvP(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--info-wsuf") == 0 && i + 1 < argc) { + outRc = handleInfo(i, argc, argv); return true; + } + if (std::strcmp(argv[i], "--validate-wsuf") == 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_item_suffixes_catalog.hpp b/tools/editor/cli_item_suffixes_catalog.hpp new file mode 100644 index 00000000..49fec999 --- /dev/null +++ b/tools/editor/cli_item_suffixes_catalog.hpp @@ -0,0 +1,12 @@ +#pragma once + +namespace wowee { +namespace editor { +namespace cli { + +bool handleItemSuffixesCatalog(int& i, int argc, char** argv, + int& outRc); + +} // namespace cli +} // namespace editor +} // namespace wowee diff --git a/tools/editor/cli_list_formats.cpp b/tools/editor/cli_list_formats.cpp index 30d98565..7f48d898 100644 --- a/tools/editor/cli_list_formats.cpp +++ b/tools/editor/cli_list_formats.cpp @@ -88,6 +88,7 @@ constexpr FormatRow kFormats[] = { {"WBNK", ".wbnk", "items", "ItemBag.dbc + bank slots", "Bag / bank / special slot catalog"}, {"WRUN", ".wrun", "spells", "RuneCost.dbc + ChrPowerType DK", "Death Knight rune cost catalog"}, {"WLDS", ".wlds", "ui", "LoadingScreens.dbc", "Per-zone loading screen catalog"}, + {"WSUF", ".wsuf", "items", "ItemRandomProperties + Suffix", "Item random-suffix bonus catalog"}, // Additional pipeline catalogs without the alternating // gen/info/validate CLI surface (loaded by the engine