feat(pipeline): add WPCN (Wowee Player Condition) catalog

49th open format — replaces PlayerCondition.dbc plus the
AzerothCore-style condition resolver. Defines reusable
boolean checks that other catalogs reference by conditionId
to gate gossip options, vendor items, quest availability,
achievement criteria, spell trainer offerings.

16 condition kinds (Always, Race, Class, Level, Zone, Map,
Reputation, AchievementWon, QuestComplete, QuestActive,
SpellKnown, ItemEquipped, Faction, InCombat, Mounted,
Resting), 8 comparison ops (==, !=, >, >=, <, <=, in-set,
not-in-set), and 4 chain ops (none, and, or, not) — chain
multiple conditions via chainNextId to express arbitrary
boolean trees.

Cross-references with prior formats — targetIdA is
polymorphic by conditionKind: resolves to WCHC raceId/classId,
WMS areaId/mapId, WFAC factionId, WACH achievementId, WQT
questId, WSPL spellId, or WIT itemId. chainNextId resolves
within the same WPCN catalog.

CLI: --gen-pcn (3 single-check starters), --gen-pcn-quest-gates
(4 cross-format quest gates with real WQT/WFAC/WACH/WMS IDs),
--gen-pcn-composite (3 leaves + 3 chained roots showing AND/
OR/NOT). Validator catches id=0/duplicates, kind/op out of
range, chain self-loop (infinite recursion), chainOp set
without chainNextId (dangling chain), chainNextId set without
chainOp (dead pointer warning), and unresolved chainNextId
references.
This commit is contained in:
Kelsi 2026-05-09 19:36:56 -07:00
parent 30de6f56cd
commit b983ef6d48
10 changed files with 762 additions and 0 deletions

View file

@ -144,6 +144,8 @@ const char* const kArgRequired[] = {
"--gen-wsui", "--gen-wsui-wintergrasp", "--gen-wsui-dungeon",
"--info-wwui", "--validate-wwui",
"--export-wwui-json", "--import-wwui-json",
"--gen-pcn", "--gen-pcn-quest-gates", "--gen-pcn-composite",
"--info-wpcn", "--validate-wpcn",
"--gen-weather-temperate", "--gen-weather-arctic",
"--gen-weather-desert", "--gen-weather-stormy",
"--gen-zone-atmosphere",

View file

@ -80,6 +80,7 @@
#include "cli_summary_dir.hpp"
#include "cli_rename_magic.hpp"
#include "cli_world_state_ui_catalog.hpp"
#include "cli_player_conditions_catalog.hpp"
#include "cli_quest_objective.hpp"
#include "cli_quest_reward.hpp"
#include "cli_clone.hpp"
@ -201,6 +202,7 @@ constexpr DispatchFn kDispatchTable[] = {
handleSummaryDir,
handleRenameMagic,
handleWorldStateUICatalog,
handlePlayerConditionsCatalog,
handleQuestObjective,
handleQuestReward,
handleClone,

View file

@ -50,6 +50,7 @@ constexpr FormatMagicEntry kFormats[] = {
{{'W','A','N','I'}, ".wani", "anim", "--info-wani", "Animation catalog"},
{{'W','S','V','K'}, ".wsvk", "spellfx", "--info-wsvk", "Spell visual kit catalog"},
{{'W','W','U','I'}, ".wwui", "ui", "--info-wwui", "World-state UI catalog"},
{{'W','P','C','N'}, ".wpcn", "logic", "--info-wpcn", "Player condition 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

@ -1397,6 +1397,16 @@ void printUsage(const char* argv0) {
std::printf(" Export binary .wwui to a human-editable JSON sidecar (defaults to <base>.wwui.json)\n");
std::printf(" --import-wwui-json <json-path> [out-base]\n");
std::printf(" Import a .wwui.json sidecar back into binary .wwui (accepts displayKind/panelPosition int OR name string)\n");
std::printf(" --gen-pcn <wpcn-base> [name]\n");
std::printf(" Emit .wpcn starter: 3 single-check conditions (level>=60 / race=Human / class=Warrior)\n");
std::printf(" --gen-pcn-quest-gates <wpcn-base> [name]\n");
std::printf(" Emit .wpcn 4 quest-style gates (quest complete, reputation, achievement, zone presence) with cross-refs\n");
std::printf(" --gen-pcn-composite <wpcn-base> [name]\n");
std::printf(" Emit .wpcn 6 entries (3 leaves + 3 chained roots) exercising AND/OR/NOT chainOps for boolean trees\n");
std::printf(" --info-wpcn <wpcn-base> [--json]\n");
std::printf(" Print WPCN entries (id / kind / op / target IDs / int values / chainOp / chainNextId / name)\n");
std::printf(" --validate-wpcn <wpcn-base> [--json]\n");
std::printf(" Static checks: id>0+unique, name not empty, kind 0..15, op 0..7, chainOp 0..3, chain self-loop, dangling chainNextId warning\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

@ -72,6 +72,7 @@ constexpr FormatRow kFormats[] = {
{"WANI", ".wani", "anim", "AnimationData.dbc", "Animation ID + fallback + weapon-flag catalog"},
{"WSVK", ".wsvk", "spellfx", "SpellVisualKit.dbc + SpellVisFx", "Spell visual kit (cast/proj/impact effects)"},
{"WWUI", ".wwui", "ui", "WorldStateUI.dbc + world_state", "World-state UI (BG scoreboards / siege counters)"},
{"WPCN", ".wpcn", "logic", "PlayerCondition.dbc + conditions", "Player condition (gates, AND/OR/NOT chains)"},
// Additional pipeline catalogs without the alternating
// gen/info/validate CLI surface (loaded by the engine

View file

@ -0,0 +1,265 @@
#include "cli_player_conditions_catalog.hpp"
#include "cli_arg_parse.hpp"
#include "cli_box_emitter.hpp"
#include "pipeline/wowee_player_conditions.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 stripWpcnExt(std::string base) {
stripExt(base, ".wpcn");
return base;
}
bool saveOrError(const wowee::pipeline::WoweePlayerCondition& c,
const std::string& base, const char* cmd) {
if (!wowee::pipeline::WoweePlayerConditionLoader::save(c, base)) {
std::fprintf(stderr, "%s: failed to save %s.wpcn\n",
cmd, base.c_str());
return false;
}
return true;
}
void printGenSummary(const wowee::pipeline::WoweePlayerCondition& c,
const std::string& base) {
std::printf("Wrote %s.wpcn\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" conditions : %zu\n", c.entries.size());
}
int handleGenStarter(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "StarterConditions";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWpcnExt(base);
auto c = wowee::pipeline::WoweePlayerConditionLoader::makeStarter(name);
if (!saveOrError(c, base, "gen-pcn")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenQuestGates(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "QuestGateConditions";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWpcnExt(base);
auto c = wowee::pipeline::WoweePlayerConditionLoader::makeQuestGates(name);
if (!saveOrError(c, base, "gen-pcn-quest-gates")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenComposite(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "CompositeConditions";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWpcnExt(base);
auto c = wowee::pipeline::WoweePlayerConditionLoader::makeComposite(name);
if (!saveOrError(c, base, "gen-pcn-composite")) 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 = stripWpcnExt(base);
if (!wowee::pipeline::WoweePlayerConditionLoader::exists(base)) {
std::fprintf(stderr, "WPCN not found: %s.wpcn\n", base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweePlayerConditionLoader::load(base);
if (jsonOut) {
nlohmann::json j;
j["wpcn"] = base + ".wpcn";
j["name"] = c.name;
j["count"] = c.entries.size();
nlohmann::json arr = nlohmann::json::array();
for (const auto& e : c.entries) {
arr.push_back({
{"conditionId", e.conditionId},
{"name", e.name},
{"description", e.description},
{"conditionKind", e.conditionKind},
{"conditionKindName", wowee::pipeline::WoweePlayerCondition::conditionKindName(e.conditionKind)},
{"comparisonOp", e.comparisonOp},
{"comparisonOpName", wowee::pipeline::WoweePlayerCondition::comparisonOpName(e.comparisonOp)},
{"chainOp", e.chainOp},
{"chainOpName", wowee::pipeline::WoweePlayerCondition::chainOpName(e.chainOp)},
{"targetIdA", e.targetIdA},
{"targetIdB", e.targetIdB},
{"intValueA", e.intValueA},
{"intValueB", e.intValueB},
{"chainNextId", e.chainNextId},
{"failMessage", e.failMessage},
});
}
j["entries"] = arr;
std::printf("%s\n", j.dump(2).c_str());
return 0;
}
std::printf("WPCN: %s.wpcn\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" conditions : %zu\n", c.entries.size());
if (c.entries.empty()) return 0;
std::printf(" id kind op tgtA tgtB intA intB chain next name\n");
for (const auto& e : c.entries) {
std::printf(" %4u %-14s %-10s %4u %4u %5d %5d %-5s %4u %s\n",
e.conditionId,
wowee::pipeline::WoweePlayerCondition::conditionKindName(e.conditionKind),
wowee::pipeline::WoweePlayerCondition::comparisonOpName(e.comparisonOp),
e.targetIdA, e.targetIdB,
e.intValueA, e.intValueB,
wowee::pipeline::WoweePlayerCondition::chainOpName(e.chainOp),
e.chainNextId, 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 = stripWpcnExt(base);
if (!wowee::pipeline::WoweePlayerConditionLoader::exists(base)) {
std::fprintf(stderr,
"validate-wpcn: WPCN not found: %s.wpcn\n", base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweePlayerConditionLoader::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;
for (const auto& e : c.entries) idsSeen.push_back(e.conditionId);
auto idExists = [&](uint32_t id) {
for (uint32_t a : idsSeen) if (a == id) return true;
return false;
};
std::vector<uint32_t> dupCheck;
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.conditionId);
if (!e.name.empty()) ctx += " " + e.name;
ctx += ")";
if (e.conditionId == 0)
errors.push_back(ctx + ": conditionId is 0");
if (e.name.empty())
errors.push_back(ctx + ": name is empty");
if (e.conditionKind > wowee::pipeline::WoweePlayerCondition::Resting) {
errors.push_back(ctx + ": conditionKind " +
std::to_string(e.conditionKind) + " not in 0..15");
}
if (e.comparisonOp > wowee::pipeline::WoweePlayerCondition::NotInSet) {
errors.push_back(ctx + ": comparisonOp " +
std::to_string(e.comparisonOp) + " not in 0..7");
}
if (e.chainOp > wowee::pipeline::WoweePlayerCondition::ChainNot) {
errors.push_back(ctx + ": chainOp " +
std::to_string(e.chainOp) + " not in 0..3");
}
// chainOp != ChainNone requires a non-zero chainNextId
// — and that ID must point at another condition in
// this catalog.
if (e.chainOp != wowee::pipeline::WoweePlayerCondition::ChainNone) {
if (e.chainNextId == 0) {
errors.push_back(ctx + ": chainOp '" +
wowee::pipeline::WoweePlayerCondition::chainOpName(e.chainOp) +
"' set but chainNextId=0 (chain has no tail)");
} else if (e.chainNextId == e.conditionId) {
errors.push_back(ctx +
": chainNextId equals conditionId "
"(infinite loop)");
} else if (!idExists(e.chainNextId)) {
warnings.push_back(ctx + ": chainNextId=" +
std::to_string(e.chainNextId) +
" not found in this catalog (resolved at runtime)");
}
}
// chainOp == ChainNone and chainNextId != 0 is dead
// pointer — chainNextId is silently unused.
if (e.chainOp == wowee::pipeline::WoweePlayerCondition::ChainNone &&
e.chainNextId != 0) {
warnings.push_back(ctx +
": chainNextId set but chainOp=none "
"(silently ignored at runtime)");
}
// duplicates
for (size_t m = 0; m < k; ++m) {
if (c.entries[m].conditionId == e.conditionId) {
errors.push_back(ctx + ": duplicate conditionId");
break;
}
}
}
bool ok = errors.empty();
if (jsonOut) {
nlohmann::json j;
j["wpcn"] = base + ".wpcn";
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-wpcn: %s.wpcn\n", base.c_str());
if (ok && warnings.empty()) {
std::printf(" OK — %zu conditions, all conditionIds unique, all chains resolved\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 handlePlayerConditionsCatalog(int& i, int argc, char** argv,
int& outRc) {
if (std::strcmp(argv[i], "--gen-pcn") == 0 && i + 1 < argc) {
outRc = handleGenStarter(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-pcn-quest-gates") == 0 &&
i + 1 < argc) {
outRc = handleGenQuestGates(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-pcn-composite") == 0 &&
i + 1 < argc) {
outRc = handleGenComposite(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--info-wpcn") == 0 && i + 1 < argc) {
outRc = handleInfo(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--validate-wpcn") == 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 handlePlayerConditionsCatalog(int& i, int argc, char** argv,
int& outRc);
} // namespace cli
} // namespace editor
} // namespace wowee