feat(editor): add WTBR (Token Reward) open catalog format

Open replacement for AzerothCore's currency_token_reward SQL
table plus the per-vendor token redemption rows in npc_vendor.
Each entry says "spend N copies of token X to receive reward Y",
with reward type polymorphism: Y can be an item, a spell (taught
to the character), a title, a mount, a companion pet, a currency
conversion, an heirloom unlock, or a cosmetic (tabard / pennant /
fluff). The rewardId field's interpretation depends on the
rewardKind enum.

Distinct from WTKN (Token catalog) which defines the token
currency items themselves. WTKN says "the Champion's Seal exists
as item 44990"; WTBR says "spend 25 Champion's Seals at Argent
Tournament for the Squire's Belt (item 45517)".

Eight rewardKind values cover the full reward space (Item / Spell
/ Title / Mount / Pet / Currency / Heirloom / Cosmetic), and an
8-tier requiredFactionStanding gates by reputation
(Hated / Hostile / Unfriendly / Neutral / Friendly / Honored /
Revered / Exalted) when paired with a non-zero requiredFactionId.

Cross-references back to WTKN (spentTokenItemId), WIT (Item
rewards), WSPL (Spell rewards), WTIT (Title rewards), WMOU
(Mount rewards), WCMP (Pet rewards), WCTR (Currency conversion
rewards), and WFAC (faction-rep gating). findByToken(itemId)
is the engine helper used by vendor frames to populate the
"what can I buy with these?" list.

Three preset emitters: --gen-tbr (5 raid tier-token redemptions
consuming Trophy of the Crusade and Emblem of Frost),
--gen-tbr-pvp (5 PvP rewards spanning honor / arena / conquest
plus title and tabard kinds), --gen-tbr-faction (5 faction-
gated rewards demonstrating each standing tier from Honored
through Exalted).

Validation enforces id+name+spentTokenItemId+spentTokenCount
presence, rewardKind 0..7, requiredFactionStanding 0..7, no
duplicate ids; warns on:
  - rewardId=0 (no actual reward, vendor offers entry but
    grants nothing)
  - requiredFactionStanding > Neutral with requiredFactionId=0
    (rep gate has no faction to check)
  - Currency conversion item -> itself (typo / config bug)

Wired through the cross-format table; WTBR appears automatically
in all 18 cross-format utilities. Format count 87 -> 88; CLI
flag count 1034 -> 1039.
This commit is contained in:
Kelsi 2026-05-09 23:26:13 -07:00
parent 69857eea18
commit c1c4b8fa12
10 changed files with 711 additions and 0 deletions

View file

@ -270,6 +270,8 @@ const char* const kArgRequired[] = {
"--gen-bkd", "--gen-bkd-battle", "--gen-bkd-profession",
"--info-wbkd", "--validate-wbkd",
"--export-wbkd-json", "--import-wbkd-json",
"--gen-tbr", "--gen-tbr-pvp", "--gen-tbr-faction",
"--info-wtbr", "--validate-wtbr",
"--gen-weather-temperate", "--gen-weather-arctic",
"--gen-weather-desert", "--gen-weather-stormy",
"--gen-zone-atmosphere",

View file

@ -132,6 +132,7 @@
#include "cli_skill_costs_catalog.hpp"
#include "cli_item_flags_catalog.hpp"
#include "cli_npc_services_catalog.hpp"
#include "cli_token_rewards_catalog.hpp"
#include "cli_quest_objective.hpp"
#include "cli_quest_reward.hpp"
#include "cli_clone.hpp"
@ -305,6 +306,7 @@ constexpr DispatchFn kDispatchTable[] = {
handleSkillCostsCatalog,
handleItemFlagsCatalog,
handleNPCServicesCatalog,
handleTokenRewardsCatalog,
handleQuestObjective,
handleQuestReward,
handleClone,

View file

@ -90,6 +90,7 @@ constexpr FormatMagicEntry kFormats[] = {
{{'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','B','K','D'}, ".wbkd", "npcs", "--info-wbkd", "NPC service definition catalog"},
{{'W','T','B','R'}, ".wtbr", "tokens", "--info-wtbr", "Token reward redemption 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

@ -1985,6 +1985,16 @@ void printUsage(const char* argv0) {
std::printf(" Export binary .wbkd to a human-editable JSON sidecar (defaults to <base>.wbkd.json)\n");
std::printf(" --import-wbkd-json <json-path> [out-base]\n");
std::printf(" Import a .wbkd.json sidecar back into binary .wbkd (accepts serviceKind int OR serviceKindName string)\n");
std::printf(" --gen-tbr <wtbr-base> [name]\n");
std::printf(" Emit .wtbr 5 raid tier-token redemptions (T9 Conqueror's helm / Vanquisher's chest / T10 Protector's legs / Trophy Gloves) consuming Trophy of the Crusade and Emblem of Frost\n");
std::printf(" --gen-tbr-pvp <wtbr-base> [name]\n");
std::printf(" Emit .wtbr 5 PvP token redemptions (BG mount / Arena weapon / Wrathful PvP helm / Combatant title / PvP tabard)\n");
std::printf(" --gen-tbr-faction <wtbr-base> [name]\n");
std::printf(" Emit .wtbr 5 faction-rep-gated rewards (Argent tabard @ Honored / Hodir mammoth @ Exalted / Cenarion ring @ Revered / Argent title @ Exalted / Wintergrasp pet @ Honored)\n");
std::printf(" --info-wtbr <wtbr-base> [--json]\n");
std::printf(" Print WTBR entries (id / spent token x count / reward kind / rewardId / faction@standing gate / name)\n");
std::printf(" --validate-wtbr <wtbr-base> [--json]\n");
std::printf(" Static checks: id+name+spentTokenItemId+count required, rewardKind 0..7, requiredFactionStanding 0..7, no duplicate ids; warns on rewardId=0 (no actual reward), standing>Neutral with factionId=0, Currency conversion item->itself\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

@ -112,6 +112,7 @@ constexpr FormatRow kFormats[] = {
{"WSCS", ".wscs", "skills", "SkillCostsData.dbc + train tiers", "Skill cost / training tier catalog"},
{"WIFS", ".wifs", "items", "Item.dbc Flags bit meanings", "Item flag bit catalog"},
{"WBKD", ".wbkd", "npcs", "npc_vendor + npc_trainer SQL", "NPC service definition catalog"},
{"WTBR", ".wtbr", "tokens", "currency_token_reward SQL", "Token reward redemption catalog"},
// Additional pipeline catalogs without the alternating
// gen/info/validate CLI surface (loaded by the engine

View file

@ -0,0 +1,260 @@
#include "cli_token_rewards_catalog.hpp"
#include "cli_arg_parse.hpp"
#include "cli_box_emitter.hpp"
#include "pipeline/wowee_token_rewards.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 stripWtbrExt(std::string base) {
stripExt(base, ".wtbr");
return base;
}
bool saveOrError(const wowee::pipeline::WoweeTokenReward& c,
const std::string& base, const char* cmd) {
if (!wowee::pipeline::WoweeTokenRewardLoader::save(c, base)) {
std::fprintf(stderr, "%s: failed to save %s.wtbr\n",
cmd, base.c_str());
return false;
}
return true;
}
void printGenSummary(const wowee::pipeline::WoweeTokenReward& c,
const std::string& base) {
std::printf("Wrote %s.wtbr\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" rewards : %zu\n", c.entries.size());
}
int handleGenRaid(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "RaidTokenRewards";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWtbrExt(base);
auto c = wowee::pipeline::WoweeTokenRewardLoader::makeRaidTokens(name);
if (!saveOrError(c, base, "gen-tbr")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenPvP(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "PvPTokenRewards";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWtbrExt(base);
auto c = wowee::pipeline::WoweeTokenRewardLoader::makePvP(name);
if (!saveOrError(c, base, "gen-tbr-pvp")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenFaction(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "FactionTokenRewards";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWtbrExt(base);
auto c = wowee::pipeline::WoweeTokenRewardLoader::makeFaction(name);
if (!saveOrError(c, base, "gen-tbr-faction")) 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 = stripWtbrExt(base);
if (!wowee::pipeline::WoweeTokenRewardLoader::exists(base)) {
std::fprintf(stderr, "WTBR not found: %s.wtbr\n", base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeTokenRewardLoader::load(base);
if (jsonOut) {
nlohmann::json j;
j["wtbr"] = base + ".wtbr";
j["name"] = c.name;
j["count"] = c.entries.size();
nlohmann::json arr = nlohmann::json::array();
for (const auto& e : c.entries) {
arr.push_back({
{"tokenRewardId", e.tokenRewardId},
{"name", e.name},
{"description", e.description},
{"spentTokenItemId", e.spentTokenItemId},
{"spentTokenCount", e.spentTokenCount},
{"rewardKind", e.rewardKind},
{"rewardKindName", wowee::pipeline::WoweeTokenReward::rewardKindName(e.rewardKind)},
{"rewardId", e.rewardId},
{"rewardCount", e.rewardCount},
{"requiredFactionId", e.requiredFactionId},
{"requiredFactionStanding", e.requiredFactionStanding},
{"requiredFactionStandingName", wowee::pipeline::WoweeTokenReward::factionStandingName(e.requiredFactionStanding)},
{"iconColorRGBA", e.iconColorRGBA},
});
}
j["entries"] = arr;
std::printf("%s\n", j.dump(2).c_str());
return 0;
}
std::printf("WTBR: %s.wtbr\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" rewards : %zu\n", c.entries.size());
if (c.entries.empty()) return 0;
std::printf(" id spent(item x count) kind rewardId faction@standing name\n");
for (const auto& e : c.entries) {
char gateBuf[64] = "-";
if (e.requiredFactionId != 0) {
std::snprintf(gateBuf, sizeof(gateBuf), "%u@%s",
e.requiredFactionId,
wowee::pipeline::WoweeTokenReward::factionStandingName(e.requiredFactionStanding));
}
std::printf(" %4u %5u x %5u %-9s %5u %-20s %s\n",
e.tokenRewardId,
e.spentTokenItemId, e.spentTokenCount,
wowee::pipeline::WoweeTokenReward::rewardKindName(e.rewardKind),
e.rewardId, gateBuf,
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 = stripWtbrExt(base);
if (!wowee::pipeline::WoweeTokenRewardLoader::exists(base)) {
std::fprintf(stderr,
"validate-wtbr: WTBR not found: %s.wtbr\n", base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeTokenRewardLoader::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 (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.tokenRewardId);
if (!e.name.empty()) ctx += " " + e.name;
ctx += ")";
if (e.tokenRewardId == 0)
errors.push_back(ctx + ": tokenRewardId is 0");
if (e.name.empty())
errors.push_back(ctx + ": name is empty");
if (e.spentTokenItemId == 0)
errors.push_back(ctx +
": spentTokenItemId is 0 — missing token currency");
if (e.spentTokenCount == 0)
errors.push_back(ctx +
": spentTokenCount is 0 — would grant reward for free");
if (e.rewardKind > wowee::pipeline::WoweeTokenReward::Cosmetic) {
errors.push_back(ctx + ": rewardKind " +
std::to_string(e.rewardKind) + " not in 0..7");
}
if (e.requiredFactionStanding > wowee::pipeline::WoweeTokenReward::Exalted) {
errors.push_back(ctx + ": requiredFactionStanding " +
std::to_string(e.requiredFactionStanding) +
" not in 0..7");
}
if (e.rewardId == 0)
warnings.push_back(ctx +
": rewardId is 0 — no actual reward target, "
"vendor will offer the entry but grant nothing");
// requiredFactionStanding > Neutral with no
// requiredFactionId is contradictory — the gate
// can't apply.
if (e.requiredFactionStanding > wowee::pipeline::WoweeTokenReward::Neutral &&
e.requiredFactionId == 0) {
warnings.push_back(ctx +
": requiredFactionStanding=" +
wowee::pipeline::WoweeTokenReward::factionStandingName(e.requiredFactionStanding) +
" set but requiredFactionId=0 — rep gate "
"has no faction to check, gate will be ignored");
}
// Currency conversion to same item is suspicious
// (1 X -> N X is usually a config bug).
if (e.rewardKind == wowee::pipeline::WoweeTokenReward::Currency &&
e.rewardId == e.spentTokenItemId) {
warnings.push_back(ctx +
": Currency conversion from item " +
std::to_string(e.spentTokenItemId) +
" to itself — usually a typo");
}
for (uint32_t prev : idsSeen) {
if (prev == e.tokenRewardId) {
errors.push_back(ctx + ": duplicate tokenRewardId");
break;
}
}
idsSeen.push_back(e.tokenRewardId);
}
bool ok = errors.empty();
if (jsonOut) {
nlohmann::json j;
j["wtbr"] = base + ".wtbr";
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-wtbr: %s.wtbr\n", base.c_str());
if (ok && warnings.empty()) {
std::printf(" OK — %zu rewards, all tokenRewardIds 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 handleTokenRewardsCatalog(int& i, int argc, char** argv,
int& outRc) {
if (std::strcmp(argv[i], "--gen-tbr") == 0 && i + 1 < argc) {
outRc = handleGenRaid(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-tbr-pvp") == 0 && i + 1 < argc) {
outRc = handleGenPvP(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-tbr-faction") == 0 && i + 1 < argc) {
outRc = handleGenFaction(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--info-wtbr") == 0 && i + 1 < argc) {
outRc = handleInfo(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--validate-wtbr") == 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 handleTokenRewardsCatalog(int& i, int argc, char** argv,
int& outRc);
} // namespace cli
} // namespace editor
} // namespace wowee