feat(pipeline): WCRA crafting recipe catalog (133rd open format)

Novel replacement for the implicit recipe expansion vanilla WoW
carried in SpellReagents.dbc + Spell.dbc effect-24 (CREATE_ITEM)
+ per-trade-skill SkillLineAbility rows. Each WCRA entry binds
one trade-skill recipe spell to its variable-length reagent
list (itemId+count pairs, vanilla cap 8, format cap 32),
produced-item id + count, the trade skill it belongs to, the
minimum skill level to cast, and the source item that teaches
the recipe.

Three presets seeded with canonical vanilla item/spell IDs:
  --gen-cra-alchemy        4 potions (Minor/Lesser Healing+Mana,
                            Greater Healing, Major Mana) using
                            herb itemIds 2447/765/2450/3357/etc
                            and Empty Vial / Crystal Vial
  --gen-cra-engineering    3 recipes including Target Dummy with
                            5 reagents (variable reagent count
                            demonstration); learnedFromItemId
                            references the recipe blueprint
  --gen-cra-blacksmithing  3 recipes covering low/mid/high tiers
                            (skill 1 / 50 / 235) including Heavy
                            Mithril Helm with 4 different bar/ore
                            reagents

Validator catches: id+name+spellId+tradeSkillId+producedItemId+
producedCount required, no duplicate recipeIds, no duplicate
spellIds (cast-handler conflict — two recipes responding to the
same cast), no zero-itemId/zero-count reagents, no duplicate
reagent itemIds within a single recipe (should be merged into
single entry with summed count), no self-reagent (recipe
consuming its own produced item is a perpetual-motion bug).
Warns on requiredSkillLevel > 450 (above WotLK cap) and empty
reagent list (free-to-craft is unusual but allowed for some
alchemy transmutes).

Format count 132 -> 133. CLI flag count 1391 -> 1398.
This commit is contained in:
Kelsi 2026-05-10 04:29:49 -07:00
parent a4ac12dbeb
commit 7df59b1d80
10 changed files with 794 additions and 0 deletions

View file

@ -407,6 +407,8 @@ const char* const kArgRequired[] = {
"--gen-qgr-starter", "--gen-qgr-branched", "--gen-qgr-dailies",
"--info-wqgr", "--validate-wqgr",
"--export-wqgr-json", "--import-wqgr-json",
"--gen-cra-alchemy", "--gen-cra-engineering", "--gen-cra-blacksmithing",
"--info-wcra", "--validate-wcra",
"--gen-weather-temperate", "--gen-weather-arctic",
"--gen-weather-desert", "--gen-weather-stormy",
"--gen-zone-atmosphere",

View file

@ -0,0 +1,332 @@
#include "cli_crafting_recipes_catalog.hpp"
#include "cli_arg_parse.hpp"
#include "cli_box_emitter.hpp"
#include "pipeline/wowee_crafting_recipes.hpp"
#include <nlohmann/json.hpp>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <set>
#include <string>
#include <vector>
namespace wowee {
namespace editor {
namespace cli {
namespace {
std::string stripWcraExt(std::string base) {
stripExt(base, ".wcra");
return base;
}
const char* tradeSkillName(uint16_t s) {
switch (s) {
case 164: return "Blacksmithing";
case 165: return "LeatherWorking";
case 171: return "Alchemy";
case 197: return "Tailoring";
case 202: return "Engineering";
case 333: return "Enchanting";
case 185: return "Cooking";
case 129: return "FirstAid";
default: return "?";
}
}
bool saveOrError(const wowee::pipeline::WoweeCraftingRecipes& c,
const std::string& base, const char* cmd) {
if (!wowee::pipeline::WoweeCraftingRecipesLoader::save(c, base)) {
std::fprintf(stderr, "%s: failed to save %s.wcra\n",
cmd, base.c_str());
return false;
}
return true;
}
void printGenSummary(const wowee::pipeline::WoweeCraftingRecipes& c,
const std::string& base) {
std::printf("Wrote %s.wcra\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" recipes : %zu\n", c.entries.size());
}
int handleGenAlchemy(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "AlchemyPotions";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWcraExt(base);
auto c = wowee::pipeline::WoweeCraftingRecipesLoader::
makeAlchemyPotions(name);
if (!saveOrError(c, base, "gen-cra-alchemy")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenEngineering(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "EngineeringRecipes";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWcraExt(base);
auto c = wowee::pipeline::WoweeCraftingRecipesLoader::
makeEngineering(name);
if (!saveOrError(c, base, "gen-cra-engineering")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenBlacksmithing(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "BlacksmithingRecipes";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWcraExt(base);
auto c = wowee::pipeline::WoweeCraftingRecipesLoader::
makeBlacksmithing(name);
if (!saveOrError(c, base, "gen-cra-blacksmithing")) 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 = stripWcraExt(base);
if (!wowee::pipeline::WoweeCraftingRecipesLoader::exists(base)) {
std::fprintf(stderr, "WCRA not found: %s.wcra\n",
base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeCraftingRecipesLoader::load(base);
if (jsonOut) {
nlohmann::json j;
j["wcra"] = base + ".wcra";
j["name"] = c.name;
j["count"] = c.entries.size();
nlohmann::json arr = nlohmann::json::array();
for (const auto& e : c.entries) {
nlohmann::json reagents = nlohmann::json::array();
for (const auto& r : e.reagents) {
reagents.push_back({
{"itemId", r.itemId},
{"count", r.count},
});
}
arr.push_back({
{"recipeId", e.recipeId},
{"spellId", e.spellId},
{"name", e.name},
{"tradeSkillId", e.tradeSkillId},
{"tradeSkillName",
tradeSkillName(e.tradeSkillId)},
{"requiredSkillLevel", e.requiredSkillLevel},
{"producedItemId", e.producedItemId},
{"producedCount", e.producedCount},
{"categoryId", e.categoryId},
{"learnedFromItemId", e.learnedFromItemId},
{"reagents", reagents},
});
}
j["entries"] = arr;
std::printf("%s\n", j.dump(2).c_str());
return 0;
}
std::printf("WCRA: %s.wcra\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" recipes : %zu\n", c.entries.size());
if (c.entries.empty()) return 0;
std::printf(" id spell trade-skill req produced count reag name\n");
for (const auto& e : c.entries) {
std::printf(" %4u %7u %-15s %3u %8u %5u %4zu %s\n",
e.recipeId, e.spellId,
tradeSkillName(e.tradeSkillId),
e.requiredSkillLevel,
e.producedItemId, e.producedCount,
e.reagents.size(), 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 = stripWcraExt(base);
if (!wowee::pipeline::WoweeCraftingRecipesLoader::exists(base)) {
std::fprintf(stderr,
"validate-wcra: WCRA not found: %s.wcra\n",
base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeCraftingRecipesLoader::load(base);
std::vector<std::string> errors;
std::vector<std::string> warnings;
if (c.entries.empty()) {
warnings.push_back("catalog has zero entries");
}
std::set<uint32_t> idsSeen;
std::set<uint32_t> spellIdsSeen;
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.recipeId);
if (!e.name.empty()) ctx += " " + e.name;
ctx += ")";
if (e.recipeId == 0)
errors.push_back(ctx + ": recipeId is 0");
if (e.spellId == 0)
errors.push_back(ctx +
": spellId is 0 (no cast spell)");
if (e.name.empty())
errors.push_back(ctx + ": name is empty");
if (e.tradeSkillId == 0) {
errors.push_back(ctx +
": tradeSkillId is 0 (recipe must "
"belong to a trade skill)");
}
if (e.producedItemId == 0)
errors.push_back(ctx +
": producedItemId is 0 (recipe produces "
"nothing)");
if (e.producedCount == 0) {
errors.push_back(ctx +
": producedCount is 0 (recipe yields 0 "
"items)");
}
// Vanilla skill cap is 300. Skill > 300 is
// valid for TBC (375) and WotLK (450) — only
// warn if absurdly above all expansions.
if (e.requiredSkillLevel > 450) {
warnings.push_back(ctx +
": requiredSkillLevel=" +
std::to_string(e.requiredSkillLevel) +
" exceeds WotLK cap of 450 (likely typo)");
}
// Empty reagent list: technically valid (some
// alchemy transmutes have only catalysts) but
// unusual. Warn.
if (e.reagents.empty()) {
warnings.push_back(ctx +
": no reagents — recipe is "
"free-to-craft (unusual; verify "
"intentional)");
}
// Per-reagent checks: zero itemId or zero
// count is a typo.
std::set<uint32_t> reagentItems;
for (size_t r = 0; r < e.reagents.size(); ++r) {
const auto& reagent = e.reagents[r];
if (reagent.itemId == 0) {
errors.push_back(ctx +
": reagent[" + std::to_string(r) +
"].itemId is 0");
}
if (reagent.count == 0) {
errors.push_back(ctx +
": reagent[" + std::to_string(r) +
"].count is 0");
}
// Same itemId listed twice in the reagent
// array — should be merged into one
// reagent with summed count.
if (reagent.itemId != 0 &&
!reagentItems.insert(reagent.itemId).second) {
warnings.push_back(ctx +
": reagent itemId " +
std::to_string(reagent.itemId) +
" appears twice — should be merged "
"into single entry with summed count");
}
}
// Self-reagent: a recipe consuming its own
// produced item is a perpetual-motion bug.
for (const auto& reagent : e.reagents) {
if (reagent.itemId == e.producedItemId &&
reagent.itemId != 0) {
errors.push_back(ctx +
": reagent itemId equals "
"producedItemId=" +
std::to_string(e.producedItemId) +
" — recipe consumes what it makes "
"(perpetual-motion bug)");
}
}
// Duplicate spellId — recipe-cast handler
// would resolve ambiguously.
if (e.spellId != 0 &&
!spellIdsSeen.insert(e.spellId).second) {
errors.push_back(ctx +
": duplicate spellId " +
std::to_string(e.spellId) +
" — two recipes would respond to the "
"same cast");
}
if (!idsSeen.insert(e.recipeId).second) {
errors.push_back(ctx + ": duplicate recipeId");
}
}
bool ok = errors.empty();
if (jsonOut) {
nlohmann::json j;
j["wcra"] = base + ".wcra";
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-wcra: %s.wcra\n", base.c_str());
if (ok && warnings.empty()) {
std::printf(" OK — %zu recipes, all recipeIds + "
"spellIds unique, non-zero spellId/"
"tradeSkillId/producedItemId/"
"producedCount, no zero-item/zero-count "
"reagents, no duplicate reagent itemIds "
"in same recipe, no self-reagent\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 handleCraftingRecipesCatalog(int& i, int argc, char** argv,
int& outRc) {
if (std::strcmp(argv[i], "--gen-cra-alchemy") == 0 &&
i + 1 < argc) {
outRc = handleGenAlchemy(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-cra-engineering") == 0 &&
i + 1 < argc) {
outRc = handleGenEngineering(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-cra-blacksmithing") == 0 &&
i + 1 < argc) {
outRc = handleGenBlacksmithing(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--info-wcra") == 0 && i + 1 < argc) {
outRc = handleInfo(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--validate-wcra") == 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 handleCraftingRecipesCatalog(int& i, int argc, char** argv,
int& outRc);
} // namespace cli
} // namespace editor
} // namespace wowee

View file

@ -177,6 +177,7 @@
#include "cli_combat_stats_catalog.hpp"
#include "cli_guild_bank_catalog.hpp"
#include "cli_quest_graph_catalog.hpp"
#include "cli_crafting_recipes_catalog.hpp"
#include "cli_catalog_pluck.hpp"
#include "cli_catalog_find.hpp"
#include "cli_catalog_by_name.hpp"
@ -399,6 +400,7 @@ constexpr DispatchFn kDispatchTable[] = {
handleCombatStatsCatalog,
handleGuildBankCatalog,
handleQuestGraphCatalog,
handleCraftingRecipesCatalog,
handleCatalogPluck,
handleCatalogFind,
handleCatalogByName,

View file

@ -135,6 +135,7 @@ constexpr FormatMagicEntry kFormats[] = {
{{'W','C','S','T'}, ".wcst", "stats", "--info-wcst", "Combat stats baseline catalog"},
{{'W','G','B','K'}, ".wgbk", "guild", "--info-wgbk", "Guild bank tabs catalog"},
{{'W','Q','G','R'}, ".wqgr", "quests", "--info-wqgr", "Quest graph catalog"},
{{'W','C','R','A'}, ".wcra", "crafting", "--info-wcra", "Crafting recipe 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

@ -2615,6 +2615,16 @@ void printUsage(const char* argv0) {
std::printf(" Export binary .wqgr to a human-editable JSON sidecar (defaults to <base>.wqgr.json; emits both questType and factionAccess as int + name string; prevQuestIds/followupQuestIds as JSON int arrays)\n");
std::printf(" --import-wqgr-json <json-path> [out-base]\n");
std::printf(" Import a .wqgr.json sidecar back into binary .wqgr (questType int OR \"normal\"/\"daily\"/\"repeatable\"/\"group\"/\"raid\"; factionAccess int OR \"both\"/\"alliance\"/\"horde\"/\"neutral\"; prereq + followup arrays accept JSON int arrays)\n");
std::printf(" --gen-cra-alchemy <wcra-base> [name]\n");
std::printf(" Emit .wcra 4 vanilla Alchemy potions (Minor/Lesser Healing+Mana, Greater Healing, Major Mana) with canonical herb itemIds + Empty Vial reagents\n");
std::printf(" --gen-cra-engineering <wcra-base> [name]\n");
std::printf(" Emit .wcra 3 vanilla Engineering recipes (Rough Blasting Powder, Mechanical Squirrel Box, Target Dummy with 5 reagents) demonstrating variable reagent count\n");
std::printf(" --gen-cra-blacksmithing <wcra-base> [name]\n");
std::printf(" Emit .wcra 3 Blacksmithing recipes (Rough Sharpening Stone skill 1 / Coarse Grinding Stone skill 50 / Heavy Mithril Helm skill 235) covering low/mid/high tiers\n");
std::printf(" --info-wcra <wcra-base> [--json]\n");
std::printf(" Print WCRA entries (recipeId / spellId / tradeSkillName / requiredSkillLevel / producedItemId / producedCount / reagent count / name)\n");
std::printf(" --validate-wcra <wcra-base> [--json]\n");
std::printf(" Static checks: id+name+spellId+tradeSkillId+producedItemId+producedCount required, no duplicate recipeIds, no duplicate spellIds (cast-handler conflict), no zero-itemId/zero-count reagents, no duplicate reagent itemIds within a single recipe (should be merged), no self-reagent (recipe consuming its own output is a perpetual-motion bug); warns on requiredSkillLevel > 450 (above WotLK cap), empty reagent list (free-to-craft is unusual)\n");
std::printf(" --catalog-pluck <wXXX-file> <id> [--json]\n");
std::printf(" Extract one entry by id from any registered catalog format. Auto-detects magic, dispatches to the per-format --info-* handler internally, then prints just the matching entry. Primary-key field is auto-detected (first *Id field, or first numeric)\n");
std::printf(" --catalog-find <directory> <id> [--magic <WXXX>] [--json]\n");

View file

@ -157,6 +157,7 @@ constexpr FormatRow kFormats[] = {
{"WCST", ".wcst", "stats", "CharBaseInfo + GtChanceTo*.dbc + StatSystem","Combat stats baseline catalog (per-class per-level base stats)"},
{"WGBK", ".wgbk", "guild", "(absent in vanilla, TBC GuildBankTab)","Guild bank tabs catalog (per-rank withdrawal limits)"},
{"WQGR", ".wqgr", "quests", "QuestRelations.dbc + per-quest scripts","Quest graph catalog (chain prereq DAG + cycle detection)"},
{"WCRA", ".wcra", "crafting", "SpellReagents.dbc + Spell.dbc effect-24","Crafting recipe catalog (trade-skill recipe expansion)"},
// Additional pipeline catalogs without the alternating
// gen/info/validate CLI surface (loaded by the engine