feat(editor): add WIFS (Item Flag Set) open catalog format

Open replacement for the bit-flag meanings used in Item.dbc /
item_template.Flags. Documents every individual bit of the
32-bit item flags field with a human-readable name, description,
kind classification, and is-positive hint.

WoW's Item.dbc Flags field packs ~25 bits of metadata like
Heroic, Lootable, NoLoot, Conjured, BindOnPickup, BindOnEquip —
each controlling a specific gameplay behavior. The hardcoded
client knows what each bit means via a switch statement; this
catalog exposes that table to data-driven editors so:
  - server admins can document custom flag bits
  - tooltip generators can decode "why is this item soulbound?"
    via flag-name lookup (decode(0x40240000) returns
    ["Heroic", "BindOnPickup", "Unique"])
  - validators can warn about contradictory flag combinations

Seven flagKind values classify the bit families (Quality / Drop
/ Trade / Magic / Account / Server / Misc), and an isPositive
hint tells UIs whether the flag enhances the item (green) or
restricts it (red).

Cross-references back to WIT (decodes WIT.flags into the
matching named flag list) and WIQR (validators can pair Heroic
flag with WIQR Epic+ quality requirement).

Three preset emitters: --gen-ifs (8 canonical Item.dbc bits
matching the standard 3.3.5a constants), --gen-ifs-binding (5
binding-related flags BindOnPickup / BindOnEquip / etc — all
restrictive so isPositive=0), --gen-ifs-server (5 server-custom
bits in the upper range demonstrating how to overlay extra
metadata without colliding with Blizzard's bits).

Validation enforces id+name+bitMask presence, flagKind 0..6, no
duplicate ids, no duplicate bitMasks (collision means engine
would only honor first matching name when decoding); warns on
multi-bit masks (unusual — usually want individual bits).

decode(flagsValue) is the engine helper that expands a raw
flags integer into its named flag list — used directly by the
tooltip generator and item info renderers. Wired through the
cross-format table; WIFS appears automatically in all 16
cross-format utilities. Format count 85 -> 86; CLI flag count
1018 -> 1023.
This commit is contained in:
Kelsi 2026-05-09 23:10:35 -07:00
parent f43b444056
commit 0ceb70f3e7
10 changed files with 655 additions and 0 deletions

View file

@ -674,6 +674,7 @@ set(WOWEE_SOURCES
src/pipeline/wowee_spell_aura_types.cpp
src/pipeline/wowee_item_qualities.cpp
src/pipeline/wowee_skill_costs.cpp
src/pipeline/wowee_item_flags.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/dbc_layout.cpp
@ -1509,6 +1510,7 @@ add_executable(wowee_editor
tools/editor/cli_spell_aura_types_catalog.cpp
tools/editor/cli_item_qualities_catalog.cpp
tools/editor/cli_skill_costs_catalog.cpp
tools/editor/cli_item_flags_catalog.cpp
tools/editor/cli_quest_objective.cpp
tools/editor/cli_quest_reward.cpp
tools/editor/cli_clone.cpp
@ -1661,6 +1663,7 @@ add_executable(wowee_editor
src/pipeline/wowee_spell_aura_types.cpp
src/pipeline/wowee_item_qualities.cpp
src/pipeline/wowee_skill_costs.cpp
src/pipeline/wowee_item_flags.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/terrain_mesh.cpp

View file

@ -0,0 +1,120 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
namespace wowee {
namespace pipeline {
// Wowee Open Item Flag Set catalog (.wifs) — novel
// replacement for the bit-flag meanings used in
// Item.dbc / item_template.Flags. Documents every
// individual bit of the 32-bit item flags field with a
// human-readable name, description, kind classification,
// and is-positive hint.
//
// WoW's Item.dbc Flags field packs ~25 bits of metadata
// like Heroic, Lootable, NoLoot, Conjured, Unique,
// AccountBound, BindOnPickup, BindOnEquip — each
// controlling a specific gameplay behavior. The hardcoded
// client knows what each bit means via a switch
// statement; this catalog exposes that table to
// data-driven editors so:
// - server admins can document custom flag bits
// - tooltip generators can explain "why is this item
// soulbound?" by flag-name lookup
// - validators can warn about contradictory flag
// combinations (Heroic + non-Epic quality, etc.)
//
// Cross-references with previously-added formats:
// WIT: every WIT item entry's flags field is decoded
// via this catalog. Item editors can show "Item
// Foo has flags: Heroic, BindOnPickup, Unique"
// instead of raw 0x40240000.
// WIQR: validators can pair Heroic flag with WIQR Epic+
// quality requirement.
//
// Binary layout (little-endian):
// magic[4] = "WIFS"
// version (uint32) = current 1
// nameLen + name (catalog label)
// entryCount (uint32)
// entries (each):
// flagId (uint32)
// nameLen + name
// descLen + description
// bitMask (uint32)
// flagKind (uint8) / isPositive (uint8) / pad[2]
// iconColorRGBA (uint32)
struct WoweeItemFlags {
enum FlagKind : uint8_t {
Quality = 0, // affects quality presentation (Heroic)
Drop = 1, // affects drop / loot behavior
Trade = 2, // bind / soul / trade restrictions
Magic = 3, // magical properties (Conjured, Unique)
Account = 4, // account / heirloom rules
Server = 5, // server-custom flag
Misc = 6, // catch-all
};
struct Entry {
uint32_t flagId = 0;
std::string name;
std::string description;
uint32_t bitMask = 0; // typically 1 << N
uint8_t flagKind = Misc;
uint8_t isPositive = 0; // 0/1 bool
uint8_t pad0 = 0;
uint8_t pad1 = 0;
uint32_t iconColorRGBA = 0xFFFFFFFFu;
};
std::string name;
std::vector<Entry> entries;
bool isValid() const { return !entries.empty(); }
const Entry* findById(uint32_t flagId) const;
const Entry* findByBit(uint32_t bitMask) const;
// Decode an item.flags integer into the list of
// matching entries. Returns the entries whose bitMask
// is set in the input. Used by tooltip generators
// to expand 0x40240000 -> ["Heroic", "BindOnPickup",
// "Unique"].
std::vector<const Entry*> decode(uint32_t flagsValue) const;
static const char* flagKindName(uint8_t k);
};
class WoweeItemFlagsLoader {
public:
static bool save(const WoweeItemFlags& cat,
const std::string& basePath);
static WoweeItemFlags load(const std::string& basePath);
static bool exists(const std::string& basePath);
// Preset emitters used by --gen-ifs* variants.
//
// makeStandard — 8 canonical Item.dbc flag bits
// (NoLoot / Conjured / Lootable /
// Wrapped / Heroic / Deprecated /
// NoUserDestroy / NoEquipCooldown).
// makeBinding — 5 binding-related flags
// (BindOnPickup / BindOnEquip /
// BindOnUse / BindToAccount /
// Soulbound) with isPositive=0
// (these flags restrict trading).
// makeServer — 5 server-custom flag bits in the
// high range (Donator / EventReward
// / Anniversary / Honored /
// Heroic25man) demonstrating
// custom-flag conventions.
static WoweeItemFlags makeStandard(const std::string& catalogName);
static WoweeItemFlags makeBinding(const std::string& catalogName);
static WoweeItemFlags makeServer(const std::string& catalogName);
};
} // namespace pipeline
} // namespace wowee

View file

@ -0,0 +1,261 @@
#include "pipeline/wowee_item_flags.hpp"
#include <cstdio>
#include <cstring>
#include <fstream>
namespace wowee {
namespace pipeline {
namespace {
constexpr char kMagic[4] = {'W', 'I', 'F', 'S'};
constexpr uint32_t kVersion = 1;
template <typename T>
void writePOD(std::ofstream& os, const T& v) {
os.write(reinterpret_cast<const char*>(&v), sizeof(T));
}
template <typename T>
bool readPOD(std::ifstream& is, T& v) {
is.read(reinterpret_cast<char*>(&v), sizeof(T));
return is.gcount() == static_cast<std::streamsize>(sizeof(T));
}
void writeStr(std::ofstream& os, const std::string& s) {
uint32_t n = static_cast<uint32_t>(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<std::streamsize>(n)) {
s.clear();
return false;
}
}
return true;
}
std::string normalizePath(std::string base) {
if (base.size() < 5 || base.substr(base.size() - 5) != ".wifs") {
base += ".wifs";
}
return base;
}
uint32_t packRgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 0xFF) {
return (static_cast<uint32_t>(a) << 24) |
(static_cast<uint32_t>(b) << 16) |
(static_cast<uint32_t>(g) << 8) |
static_cast<uint32_t>(r);
}
} // namespace
const WoweeItemFlags::Entry*
WoweeItemFlags::findById(uint32_t flagId) const {
for (const auto& e : entries)
if (e.flagId == flagId) return &e;
return nullptr;
}
const WoweeItemFlags::Entry*
WoweeItemFlags::findByBit(uint32_t bitMask) const {
for (const auto& e : entries)
if (e.bitMask == bitMask) return &e;
return nullptr;
}
std::vector<const WoweeItemFlags::Entry*>
WoweeItemFlags::decode(uint32_t flagsValue) const {
std::vector<const Entry*> out;
for (const auto& e : entries) {
if (e.bitMask == 0) continue;
if ((flagsValue & e.bitMask) == e.bitMask) {
out.push_back(&e);
}
}
return out;
}
const char* WoweeItemFlags::flagKindName(uint8_t k) {
switch (k) {
case Quality: return "quality";
case Drop: return "drop";
case Trade: return "trade";
case Magic: return "magic";
case Account: return "account";
case Server: return "server";
case Misc: return "misc";
default: return "unknown";
}
}
bool WoweeItemFlagsLoader::save(const WoweeItemFlags& 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<uint32_t>(cat.entries.size());
writePOD(os, entryCount);
for (const auto& e : cat.entries) {
writePOD(os, e.flagId);
writeStr(os, e.name);
writeStr(os, e.description);
writePOD(os, e.bitMask);
writePOD(os, e.flagKind);
writePOD(os, e.isPositive);
writePOD(os, e.pad0);
writePOD(os, e.pad1);
writePOD(os, e.iconColorRGBA);
}
return os.good();
}
WoweeItemFlags WoweeItemFlagsLoader::load(const std::string& basePath) {
WoweeItemFlags 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.flagId)) {
out.entries.clear(); return out;
}
if (!readStr(is, e.name) || !readStr(is, e.description)) {
out.entries.clear(); return out;
}
if (!readPOD(is, e.bitMask) ||
!readPOD(is, e.flagKind) ||
!readPOD(is, e.isPositive) ||
!readPOD(is, e.pad0) ||
!readPOD(is, e.pad1) ||
!readPOD(is, e.iconColorRGBA)) {
out.entries.clear(); return out;
}
}
return out;
}
bool WoweeItemFlagsLoader::exists(const std::string& basePath) {
std::ifstream is(normalizePath(basePath), std::ios::binary);
return is.good();
}
WoweeItemFlags WoweeItemFlagsLoader::makeStandard(
const std::string& catalogName) {
using F = WoweeItemFlags;
WoweeItemFlags c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name, uint32_t bit,
uint8_t kind, uint8_t positive, const char* desc) {
F::Entry e;
e.flagId = id; e.name = name; e.description = desc;
e.bitMask = bit;
e.flagKind = kind;
e.isPositive = positive;
e.iconColorRGBA = positive ? packRgba(100, 220, 100)
: packRgba(220, 100, 100);
c.entries.push_back(e);
};
// Canonical Item.dbc flag bits — values match the
// standard 3.3.5a Item.dbc Flags constants.
add(1, "NoLoot", 0x00000001u, F::Drop, 0,
"Item never appears in random loot tables.");
add(2, "Conjured", 0x00000002u, F::Magic, 1,
"Item is mage-conjured (vanishes on death/logout).");
add(3, "Lootable", 0x00000004u, F::Drop, 1,
"Item shows the 'right-click to open' container icon.");
add(4, "Wrapped", 0x00000008u, F::Magic, 1,
"Item is gift-wrapped (opens to reveal contents).");
add(5, "Heroic", 0x00000010u, F::Quality, 1,
"Heroic-mode raid drop (heroic tooltip / quality border).");
add(6, "Deprecated", 0x00000020u, F::Misc, 0,
"Item is deprecated by the engine; should not drop.");
add(7, "NoUserDestroy", 0x00000040u, F::Trade, 0,
"Cannot be destroyed via right-click context menu.");
add(8, "NoEquipCooldown",0x00000080u, F::Trade, 1,
"Equipping does not trigger the on-equip use cooldown.");
return c;
}
WoweeItemFlags WoweeItemFlagsLoader::makeBinding(
const std::string& catalogName) {
using F = WoweeItemFlags;
WoweeItemFlags c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name, uint32_t bit,
uint8_t positive, const char* desc) {
F::Entry e;
e.flagId = id; e.name = name; e.description = desc;
e.bitMask = bit;
e.flagKind = F::Trade;
e.isPositive = positive;
e.iconColorRGBA = packRgba(180, 180, 240); // binding blue
c.entries.push_back(e);
};
// Binding flags — restrictive, isPositive=0 since they
// limit trading.
add(100, "BindOnPickup", 0x00000100u, 0,
"Soulbound on pickup — cannot be traded.");
add(101, "BindOnEquip", 0x00000200u, 0,
"Soulbound on equip — tradeable in inventory only.");
add(102, "BindOnUse", 0x00000400u, 0,
"Soulbound on use — tradeable until first use.");
add(103, "BindToAccount", 0x00000800u, 0,
"Account-bound — tradeable across own characters only.");
add(104, "Soulbound", 0x00001000u, 0,
"Already soulbound (combined state, after pickup/equip/use).");
return c;
}
WoweeItemFlags WoweeItemFlagsLoader::makeServer(
const std::string& catalogName) {
using F = WoweeItemFlags;
WoweeItemFlags c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name, uint32_t bit,
const char* desc) {
F::Entry e;
e.flagId = id; e.name = name; e.description = desc;
e.bitMask = bit;
e.flagKind = F::Server;
e.isPositive = 1;
e.iconColorRGBA = packRgba(240, 100, 240); // custom magenta
c.entries.push_back(e);
};
// Server-custom flags in the upper bits (typically
// unused by Blizzard so safe for server overlays).
add(200, "Donator", 0x01000000u,
"Server-custom: donator-only item, special tooltip.");
add(201, "EventReward", 0x02000000u,
"Server-custom: event-only drop (Hallow's End / Brewfest).");
add(202, "Anniversary", 0x04000000u,
"Server-custom: server anniversary commemorative item.");
add(203, "Honored", 0x08000000u,
"Server-custom: bonus stats for honored players.");
add(204, "Heroic25man", 0x10000000u,
"Server-custom: dropped from 25-Heroic raids only.");
return c;
}
} // namespace pipeline
} // namespace wowee

View file

@ -263,6 +263,8 @@ const char* const kArgRequired[] = {
"--gen-scs", "--gen-scs-weapon", "--gen-scs-riding",
"--info-wscs", "--validate-wscs",
"--export-wscs-json", "--import-wscs-json",
"--gen-ifs", "--gen-ifs-binding", "--gen-ifs-server",
"--info-wifs", "--validate-wifs",
"--gen-weather-temperate", "--gen-weather-arctic",
"--gen-weather-desert", "--gen-weather-stormy",
"--gen-zone-atmosphere",

View file

@ -128,6 +128,7 @@
#include "cli_spell_aura_types_catalog.hpp"
#include "cli_item_qualities_catalog.hpp"
#include "cli_skill_costs_catalog.hpp"
#include "cli_item_flags_catalog.hpp"
#include "cli_quest_objective.hpp"
#include "cli_quest_reward.hpp"
#include "cli_clone.hpp"
@ -297,6 +298,7 @@ constexpr DispatchFn kDispatchTable[] = {
handleSpellAuraTypesCatalog,
handleItemQualitiesCatalog,
handleSkillCostsCatalog,
handleItemFlagsCatalog,
handleQuestObjective,
handleQuestReward,
handleClone,

View file

@ -88,6 +88,7 @@ constexpr FormatMagicEntry kFormats[] = {
{{'W','A','U','R'}, ".waur", "spells", "--info-waur", "Spell aura type catalog"},
{{'W','I','Q','R'}, ".wiqr", "items", "--info-wiqr", "Item quality tier catalog"},
{{'W','S','C','S'}, ".wscs", "skills", "--info-wscs", "Skill cost / training tier catalog"},
{{'W','I','F','S'}, ".wifs", "items", "--info-wifs", "Item flag bit 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"},

View file

@ -1953,6 +1953,16 @@ void printUsage(const char* argv0) {
std::printf(" Export binary .wscs to a human-editable JSON sidecar (defaults to <base>.wscs.json)\n");
std::printf(" --import-wscs-json <json-path> [out-base]\n");
std::printf(" Import a .wscs.json sidecar back into binary .wscs (accepts costKind int OR costKindName string)\n");
std::printf(" --gen-ifs <wifs-base> [name]\n");
std::printf(" Emit .wifs 8 canonical Item.dbc flag bits (NoLoot / Conjured / Lootable / Wrapped / Heroic / Deprecated / NoUserDestroy / NoEquipCooldown)\n");
std::printf(" --gen-ifs-binding <wifs-base> [name]\n");
std::printf(" Emit .wifs 5 binding-related flags (BindOnPickup / BindOnEquip / BindOnUse / BindToAccount / Soulbound) — all isPositive=0 (restrict trading)\n");
std::printf(" --gen-ifs-server <wifs-base> [name]\n");
std::printf(" Emit .wifs 5 server-custom flag bits in upper range (Donator / EventReward / Anniversary / Honored / Heroic25man)\n");
std::printf(" --info-wifs <wifs-base> [--json]\n");
std::printf(" Print WIFS entries (id / bitMask hex / kind / +/- positivity / name) — handy for decoding raw item.flags integers\n");
std::printf(" --validate-wifs <wifs-base> [--json]\n");
std::printf(" Static checks: id+name+bitMask required, flagKind 0..6, no duplicate ids, no duplicate bitMasks (collision); warns on multi-bit masks (unusual, usually want a single bit)\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");

View file

@ -0,0 +1,243 @@
#include "cli_item_flags_catalog.hpp"
#include "cli_arg_parse.hpp"
#include "cli_box_emitter.hpp"
#include "pipeline/wowee_item_flags.hpp"
#include <nlohmann/json.hpp>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <string>
#include <vector>
namespace wowee {
namespace editor {
namespace cli {
namespace {
std::string stripWifsExt(std::string base) {
stripExt(base, ".wifs");
return base;
}
bool saveOrError(const wowee::pipeline::WoweeItemFlags& c,
const std::string& base, const char* cmd) {
if (!wowee::pipeline::WoweeItemFlagsLoader::save(c, base)) {
std::fprintf(stderr, "%s: failed to save %s.wifs\n",
cmd, base.c_str());
return false;
}
return true;
}
void printGenSummary(const wowee::pipeline::WoweeItemFlags& c,
const std::string& base) {
std::printf("Wrote %s.wifs\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" flags : %zu\n", c.entries.size());
}
int handleGenStandard(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "StandardItemFlags";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWifsExt(base);
auto c = wowee::pipeline::WoweeItemFlagsLoader::makeStandard(name);
if (!saveOrError(c, base, "gen-ifs")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenBinding(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "BindingItemFlags";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWifsExt(base);
auto c = wowee::pipeline::WoweeItemFlagsLoader::makeBinding(name);
if (!saveOrError(c, base, "gen-ifs-binding")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenServer(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "ServerCustomItemFlags";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWifsExt(base);
auto c = wowee::pipeline::WoweeItemFlagsLoader::makeServer(name);
if (!saveOrError(c, base, "gen-ifs-server")) 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 = stripWifsExt(base);
if (!wowee::pipeline::WoweeItemFlagsLoader::exists(base)) {
std::fprintf(stderr, "WIFS not found: %s.wifs\n", base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeItemFlagsLoader::load(base);
if (jsonOut) {
nlohmann::json j;
j["wifs"] = base + ".wifs";
j["name"] = c.name;
j["count"] = c.entries.size();
nlohmann::json arr = nlohmann::json::array();
for (const auto& e : c.entries) {
arr.push_back({
{"flagId", e.flagId},
{"name", e.name},
{"description", e.description},
{"bitMask", e.bitMask},
{"flagKind", e.flagKind},
{"flagKindName", wowee::pipeline::WoweeItemFlags::flagKindName(e.flagKind)},
{"isPositive", e.isPositive != 0},
{"iconColorRGBA", e.iconColorRGBA},
});
}
j["entries"] = arr;
std::printf("%s\n", j.dump(2).c_str());
return 0;
}
std::printf("WIFS: %s.wifs\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" flags : %zu\n", c.entries.size());
if (c.entries.empty()) return 0;
std::printf(" id bitMask kind +/- name\n");
for (const auto& e : c.entries) {
std::printf(" %4u 0x%08x %-9s %s %s\n",
e.flagId, e.bitMask,
wowee::pipeline::WoweeItemFlags::flagKindName(e.flagKind),
e.isPositive ? "+" : "-",
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 = stripWifsExt(base);
if (!wowee::pipeline::WoweeItemFlagsLoader::exists(base)) {
std::fprintf(stderr,
"validate-wifs: WIFS not found: %s.wifs\n", base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeItemFlagsLoader::load(base);
std::vector<std::string> errors;
std::vector<std::string> warnings;
if (c.entries.empty()) {
warnings.push_back("catalog has zero entries");
}
std::vector<uint32_t> idsSeen;
std::vector<uint32_t> bitsSeen;
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.flagId);
if (!e.name.empty()) ctx += " " + e.name;
ctx += ")";
if (e.flagId == 0)
errors.push_back(ctx + ": flagId is 0");
if (e.name.empty())
errors.push_back(ctx + ": name is empty");
if (e.flagKind > wowee::pipeline::WoweeItemFlags::Misc) {
errors.push_back(ctx + ": flagKind " +
std::to_string(e.flagKind) + " not in 0..6");
}
if (e.bitMask == 0) {
errors.push_back(ctx +
": bitMask is 0 — flag will never match anything");
}
// bitMask should typically be a single bit (power
// of 2). Multi-bit masks are valid but unusual —
// warn so author can confirm.
if (e.bitMask != 0 && (e.bitMask & (e.bitMask - 1)) != 0) {
warnings.push_back(ctx +
": bitMask 0x" + std::to_string(e.bitMask) +
" is not a single bit (multi-bit flags are "
"unusual; usually you want one of the "
"individual bits)");
}
for (uint32_t prev : idsSeen) {
if (prev == e.flagId) {
errors.push_back(ctx + ": duplicate flagId");
break;
}
}
idsSeen.push_back(e.flagId);
// Two flags claiming the same bit is a serious
// collision — engine would only match the first
// entry's name when decoding.
if (e.bitMask != 0) {
for (uint32_t prevBit : bitsSeen) {
if (prevBit == e.bitMask) {
errors.push_back(ctx +
": duplicate bitMask 0x" +
std::to_string(e.bitMask) +
" — collides with another entry");
break;
}
}
bitsSeen.push_back(e.bitMask);
}
}
bool ok = errors.empty();
if (jsonOut) {
nlohmann::json j;
j["wifs"] = base + ".wifs";
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-wifs: %s.wifs\n", base.c_str());
if (ok && warnings.empty()) {
std::printf(" OK — %zu flags, all flagIds + bitMasks unique\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 handleItemFlagsCatalog(int& i, int argc, char** argv,
int& outRc) {
if (std::strcmp(argv[i], "--gen-ifs") == 0 && i + 1 < argc) {
outRc = handleGenStandard(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-ifs-binding") == 0 && i + 1 < argc) {
outRc = handleGenBinding(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-ifs-server") == 0 && i + 1 < argc) {
outRc = handleGenServer(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--info-wifs") == 0 && i + 1 < argc) {
outRc = handleInfo(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--validate-wifs") == 0 && i + 1 < argc) {
outRc = handleValidate(i, argc, argv); return true;
}
return false;
}
} // namespace cli
} // namespace editor
} // namespace wowee

View file

@ -0,0 +1,12 @@
#pragma once
namespace wowee {
namespace editor {
namespace cli {
bool handleItemFlagsCatalog(int& i, int argc, char** argv,
int& outRc);
} // namespace cli
} // namespace editor
} // namespace wowee

View file

@ -110,6 +110,7 @@ constexpr FormatRow kFormats[] = {
{"WAUR", ".waur", "spells", "SpellEffect.EffectAuraType", "Spell aura type catalog"},
{"WIQR", ".wiqr", "items", "Item quality tier colors+rules", "Item quality tier catalog"},
{"WSCS", ".wscs", "skills", "SkillCostsData.dbc + train tiers", "Skill cost / training tier catalog"},
{"WIFS", ".wifs", "items", "Item.dbc Flags bit meanings", "Item flag bit catalog"},
// Additional pipeline catalogs without the alternating
// gen/info/validate CLI surface (loaded by the engine