mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 02:53:51 +00:00
feat(pipeline): add WTKN (Wowee Token catalog) format
Novel open replacement for Blizzard's Currency.dbc +
CurrencyCategory.dbc + CurrencyTypes.dbc + the AzerothCore-
style player_currency SQL tables. The 28th open format
added to the editor.
Defines secondary currency tokens beyond gold: Honor Points
(PvP), Arena Points (rated PvP), Marks of Honor (per
battleground), faction reputation tokens, holiday-event
currencies. Each token has a balance cap, optional weekly
cap (regenerating earnings limit), and a category for
grouping in the player's currency tab.
Cross-references:
WTRN.item.extendedCost -> WTKN.entry.tokenId
(vendors can charge in tokens
instead of copper — when
extendedCost > 0 the runtime
looks up the matching token)
Format:
• magic "WTKN", version 1, little-endian
• per token: tokenId / name / description / iconPath /
category / maxBalance / weeklyCap / flags
Enums:
• Category (6): Misc / Pvp / Reputation / Crafting /
Seasonal / Holiday
• Flags: AccountWide / Tradeable / HiddenUntilEarned /
ResetsOnLogout / ConvertsToGold
API: WoweeTokenLoader::save / load / exists / findById.
Three preset emitters showcase typical token shapes:
• makeStarter — 3 tokens (Honor / Marks / Stormwind Guard
rep) covering Pvp + Reputation categories
• makePvp — full PvP set: Honor (75k) + Arena (5k +
weekly 1500) + 6 BG marks of honor for
classic + TBC + WotLK battlegrounds
• makeSeasonal — 4 holiday tokens (Tricky Treats /
Brewfest / Coin of Ancestry / Stranger's
Gift) all flagged ResetsOnLogout to make
them event-bound
CLI added (5 flags, 592 documented total now):
--gen-tokens / --gen-tokens-pvp / --gen-tokens-seasonal
--info-wtkn / --validate-wtkn
Validator catches: tokenId=0 + duplicates, empty name,
unknown category, weeklyCap > maxBalance (cap unreachable),
ResetsOnLogout + AccountWide combo (incoherent — account
state survives logout by definition).
This commit is contained in:
parent
68812b6c41
commit
b632554b5b
8 changed files with 606 additions and 0 deletions
|
|
@ -615,6 +615,7 @@ set(WOWEE_SOURCES
|
|||
src/pipeline/wowee_talents.cpp
|
||||
src/pipeline/wowee_maps.cpp
|
||||
src/pipeline/wowee_chars.cpp
|
||||
src/pipeline/wowee_tokens.cpp
|
||||
src/pipeline/custom_zone_discovery.cpp
|
||||
src/pipeline/dbc_layout.cpp
|
||||
|
||||
|
|
@ -1376,6 +1377,7 @@ add_executable(wowee_editor
|
|||
tools/editor/cli_talents_catalog.cpp
|
||||
tools/editor/cli_maps_catalog.cpp
|
||||
tools/editor/cli_chars_catalog.cpp
|
||||
tools/editor/cli_tokens_catalog.cpp
|
||||
tools/editor/cli_quest_objective.cpp
|
||||
tools/editor/cli_quest_reward.cpp
|
||||
tools/editor/cli_clone.cpp
|
||||
|
|
@ -1469,6 +1471,7 @@ add_executable(wowee_editor
|
|||
src/pipeline/wowee_talents.cpp
|
||||
src/pipeline/wowee_maps.cpp
|
||||
src/pipeline/wowee_chars.cpp
|
||||
src/pipeline/wowee_tokens.cpp
|
||||
src/pipeline/custom_zone_discovery.cpp
|
||||
src/pipeline/terrain_mesh.cpp
|
||||
|
||||
|
|
|
|||
107
include/pipeline/wowee_tokens.hpp
Normal file
107
include/pipeline/wowee_tokens.hpp
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
||||
// Wowee Open Token / Currency catalog (.wtkn) — novel
|
||||
// replacement for Blizzard's Currency.dbc +
|
||||
// CurrencyCategory.dbc + CurrencyTypes.dbc + the
|
||||
// AzerothCore-style player_currency SQL tables. The 28th
|
||||
// open format added to the editor.
|
||||
//
|
||||
// Defines secondary currency tokens beyond gold: Honor
|
||||
// Points (PvP), Arena Points (rated PvP), Marks of Honor
|
||||
// (per battleground), faction reputation tokens, etc. Each
|
||||
// token has a balance cap, optional weekly cap (regenerating
|
||||
// per-week limit on earnings), and a category for grouping
|
||||
// in the player's currency tab.
|
||||
//
|
||||
// Cross-references with previously-added formats:
|
||||
// WTRN.item.extendedCost → WTKN.entry.tokenId
|
||||
// (vendors can charge in tokens
|
||||
// instead of copper — when
|
||||
// extendedCost > 0 the runtime
|
||||
// looks up the corresponding token)
|
||||
//
|
||||
// Binary layout (little-endian):
|
||||
// magic[4] = "WTKN"
|
||||
// version (uint32) = current 1
|
||||
// nameLen + name (catalog label)
|
||||
// entryCount (uint32)
|
||||
// entries (each):
|
||||
// tokenId (uint32)
|
||||
// nameLen + name
|
||||
// descLen + description
|
||||
// iconLen + iconPath
|
||||
// category (uint8) + flags_byte (uint8) + pad[2]
|
||||
// maxBalance (uint32) -- 0 = unlimited
|
||||
// weeklyCap (uint32) -- 0 = no weekly cap
|
||||
// flags (uint32)
|
||||
struct WoweeToken {
|
||||
enum Category : uint8_t {
|
||||
Misc = 0,
|
||||
Pvp = 1, // Honor / Arena / Marks
|
||||
Reputation = 2, // faction-specific tokens
|
||||
Crafting = 3, // profession turn-in tokens
|
||||
Seasonal = 4, // event-only currencies
|
||||
Holiday = 5,
|
||||
};
|
||||
|
||||
enum Flags : uint32_t {
|
||||
AccountWide = 0x01,
|
||||
Tradeable = 0x02,
|
||||
HiddenUntilEarned = 0x04,
|
||||
ResetsOnLogout = 0x08,
|
||||
ConvertsToGold = 0x10,
|
||||
};
|
||||
|
||||
struct Entry {
|
||||
uint32_t tokenId = 0;
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::string iconPath;
|
||||
uint8_t category = Misc;
|
||||
uint32_t maxBalance = 0; // 0 = unlimited
|
||||
uint32_t weeklyCap = 0; // 0 = no cap
|
||||
uint32_t flags = 0;
|
||||
};
|
||||
|
||||
std::string name;
|
||||
std::vector<Entry> entries;
|
||||
|
||||
bool isValid() const { return !entries.empty(); }
|
||||
|
||||
const Entry* findById(uint32_t tokenId) const;
|
||||
|
||||
static const char* categoryName(uint8_t c);
|
||||
};
|
||||
|
||||
class WoweeTokenLoader {
|
||||
public:
|
||||
static bool save(const WoweeToken& cat,
|
||||
const std::string& basePath);
|
||||
static WoweeToken load(const std::string& basePath);
|
||||
static bool exists(const std::string& basePath);
|
||||
|
||||
// Preset emitters used by --gen-tokens* variants.
|
||||
//
|
||||
// makeStarter — 3 tokens covering Pvp / Reputation /
|
||||
// Misc categories with realistic caps.
|
||||
// makePvp — full PvP currency set: Honor (75k cap)
|
||||
// + Arena Points (5k cap, weekly) + Marks
|
||||
// of Honor for 6 classic battlegrounds.
|
||||
// makeSeasonal — 4 holiday-event tokens (Hallow's End
|
||||
// masks, Brewfest tokens, Winter's Veil
|
||||
// coins, etc.) all flagged ResetsOnLogout
|
||||
// to be event-bound.
|
||||
static WoweeToken makeStarter(const std::string& catalogName);
|
||||
static WoweeToken makePvp(const std::string& catalogName);
|
||||
static WoweeToken makeSeasonal(const std::string& catalogName);
|
||||
};
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace wowee
|
||||
235
src/pipeline/wowee_tokens.cpp
Normal file
235
src/pipeline/wowee_tokens.cpp
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
#include "pipeline/wowee_tokens.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr char kMagic[4] = {'W', 'T', 'K', 'N'};
|
||||
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) != ".wtkn") {
|
||||
base += ".wtkn";
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const WoweeToken::Entry* WoweeToken::findById(uint32_t tokenId) const {
|
||||
for (const auto& e : entries) if (e.tokenId == tokenId) return &e;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* WoweeToken::categoryName(uint8_t c) {
|
||||
switch (c) {
|
||||
case Misc: return "misc";
|
||||
case Pvp: return "pvp";
|
||||
case Reputation: return "rep";
|
||||
case Crafting: return "crafting";
|
||||
case Seasonal: return "seasonal";
|
||||
case Holiday: return "holiday";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
bool WoweeTokenLoader::save(const WoweeToken& 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.tokenId);
|
||||
writeStr(os, e.name);
|
||||
writeStr(os, e.description);
|
||||
writeStr(os, e.iconPath);
|
||||
writePOD(os, e.category);
|
||||
uint8_t pad[3] = {0, 0, 0};
|
||||
os.write(reinterpret_cast<const char*>(pad), 3);
|
||||
writePOD(os, e.maxBalance);
|
||||
writePOD(os, e.weeklyCap);
|
||||
writePOD(os, e.flags);
|
||||
}
|
||||
return os.good();
|
||||
}
|
||||
|
||||
WoweeToken WoweeTokenLoader::load(const std::string& basePath) {
|
||||
WoweeToken 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.tokenId)) { out.entries.clear(); return out; }
|
||||
if (!readStr(is, e.name) || !readStr(is, e.description) ||
|
||||
!readStr(is, e.iconPath)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
if (!readPOD(is, e.category)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
uint8_t pad[3];
|
||||
is.read(reinterpret_cast<char*>(pad), 3);
|
||||
if (is.gcount() != 3) { out.entries.clear(); return out; }
|
||||
if (!readPOD(is, e.maxBalance) ||
|
||||
!readPOD(is, e.weeklyCap) ||
|
||||
!readPOD(is, e.flags)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool WoweeTokenLoader::exists(const std::string& basePath) {
|
||||
std::ifstream is(normalizePath(basePath), std::ios::binary);
|
||||
return is.good();
|
||||
}
|
||||
|
||||
WoweeToken WoweeTokenLoader::makeStarter(const std::string& catalogName) {
|
||||
WoweeToken c;
|
||||
c.name = catalogName;
|
||||
{
|
||||
WoweeToken::Entry e;
|
||||
e.tokenId = 1; e.name = "Honor Points";
|
||||
e.description = "Earned by participating in PvP combat.";
|
||||
e.category = WoweeToken::Pvp;
|
||||
e.maxBalance = 75000;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
{
|
||||
WoweeToken::Entry e;
|
||||
e.tokenId = 2; e.name = "Marks of Honor";
|
||||
e.description = "Awarded for a battleground victory.";
|
||||
e.category = WoweeToken::Pvp;
|
||||
e.maxBalance = 100;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
{
|
||||
WoweeToken::Entry e;
|
||||
e.tokenId = 3; e.name = "Stormwind Guard Token";
|
||||
e.description = "Earned by serving the Stormwind militia.";
|
||||
e.category = WoweeToken::Reputation;
|
||||
e.maxBalance = 5000;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeToken WoweeTokenLoader::makePvp(const std::string& catalogName) {
|
||||
WoweeToken c;
|
||||
c.name = catalogName;
|
||||
{
|
||||
WoweeToken::Entry e;
|
||||
e.tokenId = 100; e.name = "Honor Points";
|
||||
e.description = "Earned in any PvP combat.";
|
||||
e.category = WoweeToken::Pvp;
|
||||
e.maxBalance = 75000;
|
||||
e.flags = WoweeToken::HiddenUntilEarned;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
{
|
||||
WoweeToken::Entry e;
|
||||
e.tokenId = 101; e.name = "Arena Points";
|
||||
e.description = "Awarded weekly based on arena rating.";
|
||||
e.category = WoweeToken::Pvp;
|
||||
e.maxBalance = 5000;
|
||||
e.weeklyCap = 1500;
|
||||
e.flags = WoweeToken::HiddenUntilEarned;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
// Marks of Honor for 6 classic battlegrounds.
|
||||
auto addMark = [&](uint32_t id, const char* bgName) {
|
||||
WoweeToken::Entry e;
|
||||
e.tokenId = id;
|
||||
e.name = std::string("Mark of Honor: ") + bgName;
|
||||
e.description =
|
||||
std::string("Awarded for a victory in ") + bgName + ".";
|
||||
e.category = WoweeToken::Pvp;
|
||||
e.maxBalance = 100;
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
addMark(102, "Warsong Gulch");
|
||||
addMark(103, "Arathi Basin");
|
||||
addMark(104, "Alterac Valley");
|
||||
addMark(105, "Eye of the Storm");
|
||||
addMark(106, "Strand of the Ancients");
|
||||
addMark(107, "Isle of Conquest");
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeToken WoweeTokenLoader::makeSeasonal(const std::string& catalogName) {
|
||||
WoweeToken c;
|
||||
c.name = catalogName;
|
||||
auto addSeasonal = [&](uint32_t id, const char* name, const char* desc) {
|
||||
WoweeToken::Entry e;
|
||||
e.tokenId = id; e.name = name; e.description = desc;
|
||||
e.category = WoweeToken::Holiday;
|
||||
e.maxBalance = 1000;
|
||||
// Seasonal tokens vanish when the event ends; flag
|
||||
// ResetsOnLogout makes the runtime drop the balance
|
||||
// on the next login if the event is no longer active.
|
||||
e.flags = WoweeToken::ResetsOnLogout;
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
addSeasonal(200, "Tricky Treats",
|
||||
"Hallow's End candy currency. Spent at Headless Horseman vendors.");
|
||||
addSeasonal(201, "Brewfest Tokens",
|
||||
"Brewfest event currency from boss runs and goblin races.");
|
||||
addSeasonal(202, "Coin of Ancestry",
|
||||
"Lunar Festival elder reward; spent on holiday gear.");
|
||||
addSeasonal(203, "Stranger's Gift",
|
||||
"Winter's Veil snowball-fight reward.");
|
||||
return c;
|
||||
}
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace wowee
|
||||
|
|
@ -79,6 +79,8 @@ const char* const kArgRequired[] = {
|
|||
"--export-wms-json", "--import-wms-json",
|
||||
"--gen-chars", "--gen-chars-alliance", "--gen-chars-allraces",
|
||||
"--info-wchc", "--validate-wchc",
|
||||
"--gen-tokens", "--gen-tokens-pvp", "--gen-tokens-seasonal",
|
||||
"--info-wtkn", "--validate-wtkn",
|
||||
"--gen-weather-temperate", "--gen-weather-arctic",
|
||||
"--gen-weather-desert", "--gen-weather-stormy",
|
||||
"--gen-zone-atmosphere",
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@
|
|||
#include "cli_talents_catalog.hpp"
|
||||
#include "cli_maps_catalog.hpp"
|
||||
#include "cli_chars_catalog.hpp"
|
||||
#include "cli_tokens_catalog.hpp"
|
||||
#include "cli_quest_objective.hpp"
|
||||
#include "cli_quest_reward.hpp"
|
||||
#include "cli_clone.hpp"
|
||||
|
|
@ -151,6 +152,7 @@ constexpr DispatchFn kDispatchTable[] = {
|
|||
handleTalentsCatalog,
|
||||
handleMapsCatalog,
|
||||
handleCharsCatalog,
|
||||
handleTokensCatalog,
|
||||
handleQuestObjective,
|
||||
handleQuestReward,
|
||||
handleClone,
|
||||
|
|
|
|||
|
|
@ -1089,6 +1089,16 @@ void printUsage(const char* argv0) {
|
|||
std::printf(" Print WCHC classes (id / power / hp scaling) + races (faction / starting zone) + outfit item lists\n");
|
||||
std::printf(" --validate-wchc <wchc-base> [--json]\n");
|
||||
std::printf(" Static checks: class+race ids unique, baseHealth>0, faction availability set, outfit refs resolve\n");
|
||||
std::printf(" --gen-tokens <wtkn-base> [name]\n");
|
||||
std::printf(" Emit .wtkn starter: 3 tokens (Honor / Marks / Stormwind Guard) covering Pvp + Reputation categories\n");
|
||||
std::printf(" --gen-tokens-pvp <wtkn-base> [name]\n");
|
||||
std::printf(" Emit .wtkn full PvP set: Honor (75k cap) + Arena (5k cap, weekly 1500) + 6 BG marks of honor\n");
|
||||
std::printf(" --gen-tokens-seasonal <wtkn-base> [name]\n");
|
||||
std::printf(" Emit .wtkn 4 holiday tokens (Tricky Treats / Brewfest / Coin of Ancestry / Stranger's Gift) — ResetsOnLogout\n");
|
||||
std::printf(" --info-wtkn <wtkn-base> [--json]\n");
|
||||
std::printf(" Print WTKN entries (id / category / max balance / weekly cap / flags / name)\n");
|
||||
std::printf(" --validate-wtkn <wtkn-base> [--json]\n");
|
||||
std::printf(" Static checks: tokenId>0+unique, name not empty, weeklyCap<=maxBalance, no Resets+AccountWide conflict\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");
|
||||
|
|
|
|||
236
tools/editor/cli_tokens_catalog.cpp
Normal file
236
tools/editor/cli_tokens_catalog.cpp
Normal file
|
|
@ -0,0 +1,236 @@
|
|||
#include "cli_tokens_catalog.hpp"
|
||||
#include "cli_arg_parse.hpp"
|
||||
#include "cli_box_emitter.hpp"
|
||||
|
||||
#include "pipeline/wowee_tokens.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 stripWtknExt(std::string base) {
|
||||
stripExt(base, ".wtkn");
|
||||
return base;
|
||||
}
|
||||
|
||||
void appendTknFlagsStr(std::string& s, uint32_t flags) {
|
||||
if (flags & wowee::pipeline::WoweeToken::AccountWide) s += "account ";
|
||||
if (flags & wowee::pipeline::WoweeToken::Tradeable) s += "trade ";
|
||||
if (flags & wowee::pipeline::WoweeToken::HiddenUntilEarned) s += "hidden ";
|
||||
if (flags & wowee::pipeline::WoweeToken::ResetsOnLogout) s += "resets ";
|
||||
if (flags & wowee::pipeline::WoweeToken::ConvertsToGold) s += "to-gold ";
|
||||
if (s.empty()) s = "-";
|
||||
else if (s.back() == ' ') s.pop_back();
|
||||
}
|
||||
|
||||
bool saveOrError(const wowee::pipeline::WoweeToken& c,
|
||||
const std::string& base, const char* cmd) {
|
||||
if (!wowee::pipeline::WoweeTokenLoader::save(c, base)) {
|
||||
std::fprintf(stderr, "%s: failed to save %s.wtkn\n",
|
||||
cmd, base.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void printGenSummary(const wowee::pipeline::WoweeToken& c,
|
||||
const std::string& base) {
|
||||
std::printf("Wrote %s.wtkn\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" tokens : %zu\n", c.entries.size());
|
||||
}
|
||||
|
||||
int handleGenStarter(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "StarterTokens";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWtknExt(base);
|
||||
auto c = wowee::pipeline::WoweeTokenLoader::makeStarter(name);
|
||||
if (!saveOrError(c, base, "gen-tokens")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenPvp(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "PvpTokens";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWtknExt(base);
|
||||
auto c = wowee::pipeline::WoweeTokenLoader::makePvp(name);
|
||||
if (!saveOrError(c, base, "gen-tokens-pvp")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenSeasonal(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "SeasonalTokens";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWtknExt(base);
|
||||
auto c = wowee::pipeline::WoweeTokenLoader::makeSeasonal(name);
|
||||
if (!saveOrError(c, base, "gen-tokens-seasonal")) 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 = stripWtknExt(base);
|
||||
if (!wowee::pipeline::WoweeTokenLoader::exists(base)) {
|
||||
std::fprintf(stderr, "WTKN not found: %s.wtkn\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeTokenLoader::load(base);
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wtkn"] = base + ".wtkn";
|
||||
j["name"] = c.name;
|
||||
j["count"] = c.entries.size();
|
||||
nlohmann::json arr = nlohmann::json::array();
|
||||
for (const auto& e : c.entries) {
|
||||
std::string fs;
|
||||
appendTknFlagsStr(fs, e.flags);
|
||||
arr.push_back({
|
||||
{"tokenId", e.tokenId},
|
||||
{"name", e.name},
|
||||
{"description", e.description},
|
||||
{"iconPath", e.iconPath},
|
||||
{"category", e.category},
|
||||
{"categoryName", wowee::pipeline::WoweeToken::categoryName(e.category)},
|
||||
{"maxBalance", e.maxBalance},
|
||||
{"weeklyCap", e.weeklyCap},
|
||||
{"flags", e.flags},
|
||||
{"flagsStr", fs},
|
||||
});
|
||||
}
|
||||
j["entries"] = arr;
|
||||
std::printf("%s\n", j.dump(2).c_str());
|
||||
return 0;
|
||||
}
|
||||
std::printf("WTKN: %s.wtkn\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" tokens : %zu\n", c.entries.size());
|
||||
if (c.entries.empty()) return 0;
|
||||
std::printf(" id category maxBal weekly flags name\n");
|
||||
for (const auto& e : c.entries) {
|
||||
std::string fs;
|
||||
appendTknFlagsStr(fs, e.flags);
|
||||
std::printf(" %4u %-9s %7u %5u %-12s %s\n",
|
||||
e.tokenId,
|
||||
wowee::pipeline::WoweeToken::categoryName(e.category),
|
||||
e.maxBalance, e.weeklyCap, fs.c_str(),
|
||||
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 = stripWtknExt(base);
|
||||
if (!wowee::pipeline::WoweeTokenLoader::exists(base)) {
|
||||
std::fprintf(stderr,
|
||||
"validate-wtkn: WTKN not found: %s.wtkn\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeTokenLoader::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.tokenId);
|
||||
if (!e.name.empty()) ctx += " " + e.name;
|
||||
ctx += ")";
|
||||
if (e.tokenId == 0) errors.push_back(ctx + ": tokenId is 0");
|
||||
if (e.name.empty()) errors.push_back(ctx + ": name is empty");
|
||||
if (e.category > wowee::pipeline::WoweeToken::Holiday) {
|
||||
errors.push_back(ctx + ": category " +
|
||||
std::to_string(e.category) + " not in 0..5");
|
||||
}
|
||||
if (e.weeklyCap > 0 && e.maxBalance > 0 &&
|
||||
e.weeklyCap > e.maxBalance) {
|
||||
warnings.push_back(ctx +
|
||||
": weeklyCap exceeds maxBalance (cap is unreachable)");
|
||||
}
|
||||
if ((e.flags & wowee::pipeline::WoweeToken::ResetsOnLogout) &&
|
||||
(e.flags & wowee::pipeline::WoweeToken::AccountWide)) {
|
||||
errors.push_back(ctx +
|
||||
": ResetsOnLogout and AccountWide both set (incoherent)");
|
||||
}
|
||||
for (uint32_t prev : idsSeen) {
|
||||
if (prev == e.tokenId) {
|
||||
errors.push_back(ctx + ": duplicate tokenId");
|
||||
break;
|
||||
}
|
||||
}
|
||||
idsSeen.push_back(e.tokenId);
|
||||
}
|
||||
bool ok = errors.empty();
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wtkn"] = base + ".wtkn";
|
||||
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-wtkn: %s.wtkn\n", base.c_str());
|
||||
if (ok && warnings.empty()) {
|
||||
std::printf(" OK — %zu tokens, all tokenIds 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 handleTokensCatalog(int& i, int argc, char** argv, int& outRc) {
|
||||
if (std::strcmp(argv[i], "--gen-tokens") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenStarter(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-tokens-pvp") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenPvp(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-tokens-seasonal") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenSeasonal(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--info-wtkn") == 0 && i + 1 < argc) {
|
||||
outRc = handleInfo(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--validate-wtkn") == 0 && i + 1 < argc) {
|
||||
outRc = handleValidate(i, argc, argv); return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace editor
|
||||
} // namespace wowee
|
||||
11
tools/editor/cli_tokens_catalog.hpp
Normal file
11
tools/editor/cli_tokens_catalog.hpp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
namespace cli {
|
||||
|
||||
bool handleTokensCatalog(int& i, int argc, char** argv, int& outRc);
|
||||
|
||||
} // namespace cli
|
||||
} // namespace editor
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue