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

@ -721,6 +721,7 @@ set(WOWEE_SOURCES
src/pipeline/wowee_combat_stats.cpp
src/pipeline/wowee_guild_bank.cpp
src/pipeline/wowee_quest_graph.cpp
src/pipeline/wowee_crafting_recipes.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/dbc_layout.cpp
@ -1605,6 +1606,7 @@ add_executable(wowee_editor
tools/editor/cli_combat_stats_catalog.cpp
tools/editor/cli_guild_bank_catalog.cpp
tools/editor/cli_quest_graph_catalog.cpp
tools/editor/cli_crafting_recipes_catalog.cpp
tools/editor/cli_catalog_pluck.cpp
tools/editor/cli_catalog_find.cpp
tools/editor/cli_catalog_by_name.cpp
@ -1808,6 +1810,7 @@ add_executable(wowee_editor
src/pipeline/wowee_combat_stats.cpp
src/pipeline/wowee_guild_bank.cpp
src/pipeline/wowee_quest_graph.cpp
src/pipeline/wowee_crafting_recipes.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/terrain_mesh.cpp

View file

@ -0,0 +1,136 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
namespace wowee {
namespace pipeline {
// Wowee Open Crafting Recipe catalog (.wcra) —
// novel replacement for the implicit recipe
// expansion that 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 reagent list (variable-
// length itemId+count pairs), produced-item id +
// count, the trade skill it belongs to, the
// minimum skill level to cast, and the source
// item that teaches the recipe.
//
// Cross-references with previously-added formats:
// WSPL: spellId references the WSPL spell catalog
// (the actual spell-to-cast — Brilliant
// Mana Oil is spellId 25127, etc.).
// WIT: every reagent[i].itemId, producedItemId,
// and learnedFromItemId references the WIT
// item catalog.
// WSKL: tradeSkillId references the WSKL skill
// catalog (Alchemy=171, Blacksmithing=164,
// Engineering=202, etc.).
// WCAT: categoryId references the trade-skill
// category catalog (within a skill, the
// subcategory tab — "Potion / Elixir /
// Transmute" for Alchemy).
//
// Binary layout (little-endian):
// magic[4] = "WCRA"
// version (uint32) = current 1
// nameLen + name (catalog label)
// entryCount (uint32)
// entries (each):
// recipeId (uint32)
// spellId (uint32) — WSPL cast
// spell
// nameLen + name — display label
// tradeSkillId (uint16) — WSKL ref
// requiredSkillLevel (uint16) — 0..300 vanilla
// producedItemId (uint32)
// producedCount (uint16)
// categoryId (uint16) — within-skill
// tab
// learnedFromItemId (uint32) — recipe scroll
// (0 = trainer-
// learned)
// reagentCount (uint32)
// reagents (each: uint32 itemId + uint32 count)
struct WoweeCraftingRecipes {
struct Reagent {
uint32_t itemId = 0;
uint32_t count = 0;
};
struct Entry {
uint32_t recipeId = 0;
uint32_t spellId = 0;
std::string name;
uint16_t tradeSkillId = 0;
uint16_t requiredSkillLevel = 0;
uint32_t producedItemId = 0;
uint16_t producedCount = 1;
uint16_t categoryId = 0;
uint32_t learnedFromItemId = 0;
std::vector<Reagent> reagents;
};
std::string name;
std::vector<Entry> entries;
bool isValid() const { return !entries.empty(); }
const Entry* findById(uint32_t recipeId) const;
// Returns the recipe for a given cast spellId —
// the lookup the trade-skill cast handler uses
// to resolve which item to produce + which
// reagents to consume.
const Entry* findBySpellId(uint32_t spellId) const;
// Returns all recipes belonging to a trade
// skill. Used by the trade-skill window UI to
// populate the per-skill recipe list.
std::vector<const Entry*> findByTradeSkill(uint16_t tradeSkillId) const;
// Returns all recipes that produce a given
// itemId — useful for "how do I make this?"
// tooltip-link queries.
std::vector<const Entry*> findByProducedItem(uint32_t itemId) const;
};
class WoweeCraftingRecipesLoader {
public:
static bool save(const WoweeCraftingRecipes& cat,
const std::string& basePath);
static WoweeCraftingRecipes load(const std::string& basePath);
static bool exists(const std::string& basePath);
// Preset emitters used by --gen-cra* variants.
//
// makeAlchemyPotions — 4 vanilla Alchemy
// potions (Healing /
// Mana / Greater Healing
// / Major Mana). Each
// uses 2 herb reagents +
// 1 vial.
// makeEngineering — 3 vanilla Engineering
// recipes (Rough Blasting
// Powder / Mechanical
// Squirrel Box / Target
// Dummy). Demonstrates
// variable reagent count
// (Target Dummy needs 5
// reagents).
// makeBlacksmithing — 3 Blacksmithing recipes
// (Rough Sharpening Stone
// / Coarse Grinding Stone
// / Heavy Mithril Helm)
// covering low/mid/high
// skill tiers.
static WoweeCraftingRecipes makeAlchemyPotions(const std::string& catalogName);
static WoweeCraftingRecipes makeEngineering(const std::string& catalogName);
static WoweeCraftingRecipes makeBlacksmithing(const std::string& catalogName);
};
} // namespace pipeline
} // namespace wowee

View file

@ -0,0 +1,295 @@
#include "pipeline/wowee_crafting_recipes.hpp"
#include <cstdio>
#include <cstring>
#include <fstream>
namespace wowee {
namespace pipeline {
namespace {
constexpr char kMagic[4] = {'W', 'C', 'R', 'A'};
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) != ".wcra") {
base += ".wcra";
}
return base;
}
} // namespace
const WoweeCraftingRecipes::Entry*
WoweeCraftingRecipes::findById(uint32_t recipeId) const {
for (const auto& e : entries)
if (e.recipeId == recipeId) return &e;
return nullptr;
}
const WoweeCraftingRecipes::Entry*
WoweeCraftingRecipes::findBySpellId(uint32_t spellId) const {
for (const auto& e : entries)
if (e.spellId == spellId) return &e;
return nullptr;
}
std::vector<const WoweeCraftingRecipes::Entry*>
WoweeCraftingRecipes::findByTradeSkill(uint16_t tradeSkillId) const {
std::vector<const Entry*> out;
for (const auto& e : entries)
if (e.tradeSkillId == tradeSkillId) out.push_back(&e);
return out;
}
std::vector<const WoweeCraftingRecipes::Entry*>
WoweeCraftingRecipes::findByProducedItem(uint32_t itemId) const {
std::vector<const Entry*> out;
for (const auto& e : entries)
if (e.producedItemId == itemId) out.push_back(&e);
return out;
}
bool WoweeCraftingRecipesLoader::save(
const WoweeCraftingRecipes& 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.recipeId);
writePOD(os, e.spellId);
writeStr(os, e.name);
writePOD(os, e.tradeSkillId);
writePOD(os, e.requiredSkillLevel);
writePOD(os, e.producedItemId);
writePOD(os, e.producedCount);
writePOD(os, e.categoryId);
writePOD(os, e.learnedFromItemId);
uint32_t reagentCount =
static_cast<uint32_t>(e.reagents.size());
writePOD(os, reagentCount);
for (const auto& r : e.reagents) {
writePOD(os, r.itemId);
writePOD(os, r.count);
}
}
return os.good();
}
WoweeCraftingRecipes WoweeCraftingRecipesLoader::load(
const std::string& basePath) {
WoweeCraftingRecipes 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.recipeId) ||
!readPOD(is, e.spellId)) {
out.entries.clear(); return out;
}
if (!readStr(is, e.name)) {
out.entries.clear(); return out;
}
if (!readPOD(is, e.tradeSkillId) ||
!readPOD(is, e.requiredSkillLevel) ||
!readPOD(is, e.producedItemId) ||
!readPOD(is, e.producedCount) ||
!readPOD(is, e.categoryId) ||
!readPOD(is, e.learnedFromItemId)) {
out.entries.clear(); return out;
}
uint32_t reagentCount = 0;
if (!readPOD(is, reagentCount)) {
out.entries.clear(); return out;
}
// Sanity cap — no recipe should have more than
// 32 reagents; vanilla cap is 8.
if (reagentCount > 32) {
out.entries.clear(); return out;
}
e.reagents.resize(reagentCount);
for (auto& r : e.reagents) {
if (!readPOD(is, r.itemId) ||
!readPOD(is, r.count)) {
out.entries.clear(); return out;
}
}
}
return out;
}
bool WoweeCraftingRecipesLoader::exists(
const std::string& basePath) {
std::ifstream is(normalizePath(basePath), std::ios::binary);
return is.good();
}
namespace {
// Vanilla trade-skill IDs from SkillLine.dbc:
// Alchemy=171, Blacksmithing=164,
// Engineering=202, Enchanting=333,
// LeatherWorking=165, Tailoring=197,
// Cooking=185, FirstAid=129.
constexpr uint16_t kAlchemy = 171;
constexpr uint16_t kEngineering = 202;
constexpr uint16_t kBlacksmithing = 164;
WoweeCraftingRecipes::Entry makeRecipe(
uint32_t recipeId, uint32_t spellId, const char* name,
uint16_t tradeSkillId, uint16_t requiredSkill,
uint32_t producedItemId, uint16_t producedCount,
uint16_t categoryId, uint32_t learnedFromItemId,
std::vector<WoweeCraftingRecipes::Reagent> reagents) {
WoweeCraftingRecipes::Entry e;
e.recipeId = recipeId; e.spellId = spellId;
e.name = name;
e.tradeSkillId = tradeSkillId;
e.requiredSkillLevel = requiredSkill;
e.producedItemId = producedItemId;
e.producedCount = producedCount;
e.categoryId = categoryId;
e.learnedFromItemId = learnedFromItemId;
e.reagents = std::move(reagents);
return e;
}
} // namespace
WoweeCraftingRecipes WoweeCraftingRecipesLoader::makeAlchemyPotions(
const std::string& catalogName) {
using R = WoweeCraftingRecipes;
WoweeCraftingRecipes c;
c.name = catalogName;
// Vanilla Alchemy potions. Reagent itemIds are
// canonical: Peacebloom=2447, Silverleaf=765,
// Briarthorn=2450, Mageroyal=785,
// Bruiseweed=2453, Stranglekelp=3820,
// Liferoot=3357, Goldthorn=3821, Khadgar's
// Whisker=3358, Empty Vial=3371.
c.entries.push_back(makeRecipe(
1, 2330, "Minor Healing Potion", kAlchemy, 1,
118, 1, 1, 0,
{{2447, 1}, {765, 1}, {3371, 1}}));
// Lesser Mana Potion: Mageroyal + Stranglekelp.
c.entries.push_back(makeRecipe(
2, 2331, "Lesser Mana Potion", kAlchemy, 100,
3385, 1, 1, 0,
{{785, 1}, {3820, 1}, {3371, 1}}));
// Greater Healing Potion: Liferoot + Khadgar's
// Whisker.
c.entries.push_back(makeRecipe(
3, 11457, "Greater Healing Potion", kAlchemy, 155,
3928, 1, 1, 0,
{{3357, 1}, {3358, 1}, {3371, 1}}));
// Major Mana Potion: Sungrass=8838 + Blindweed
// =8839 + Crystal Vial=8766 (uses larger vial).
c.entries.push_back(makeRecipe(
4, 17580, "Major Mana Potion", kAlchemy, 295,
13444, 1, 1, 0,
{{8838, 3}, {8839, 3}, {8766, 1}}));
return c;
}
WoweeCraftingRecipes WoweeCraftingRecipesLoader::makeEngineering(
const std::string& catalogName) {
using R = WoweeCraftingRecipes;
WoweeCraftingRecipes c;
c.name = catalogName;
// Rough Blasting Powder: 1 Rough Stone (2835)
// for 1 powder. Lowest-skill engineering recipe.
c.entries.push_back(makeRecipe(
10, 3918, "Rough Blasting Powder", kEngineering, 1,
4357, 1, 1, 0,
{{2835, 1}}));
// Mechanical Squirrel Box: rough copper-bar
// recipe — 4 reagents.
c.entries.push_back(makeRecipe(
11, 4413, "Mechanical Squirrel Box", kEngineering, 75,
4401, 1, 1, 0,
{{2840, 2}, {4399, 1}, {2589, 1}, {4357, 1}}));
// Target Dummy: 5 reagents — demonstrates
// variable reagent count within the recipe
// catalog. Blueprint is itemId 4406.
c.entries.push_back(makeRecipe(
12, 4079, "Target Dummy", kEngineering, 75,
2092, 1, 1, 4406,
{{2840, 4}, {4361, 2}, {2997, 2}, {2589, 4}, {4357, 1}}));
return c;
}
WoweeCraftingRecipes WoweeCraftingRecipesLoader::makeBlacksmithing(
const std::string& catalogName) {
using R = WoweeCraftingRecipes;
WoweeCraftingRecipes c;
c.name = catalogName;
// Rough Sharpening Stone: 1 Rough Stone -> 1
// sharpening stone. Skill 1 (default).
c.entries.push_back(makeRecipe(
20, 2660, "Rough Sharpening Stone", kBlacksmithing, 1,
2862, 1, 1, 0,
{{2835, 1}}));
// Coarse Grinding Stone: 2 Coarse Stone (2836).
// Skill 50.
c.entries.push_back(makeRecipe(
21, 3326, "Coarse Grinding Stone", kBlacksmithing, 50,
3486, 1, 1, 0,
{{2836, 2}}));
// Heavy Mithril Helm: high-skill plate piece
// requiring multiple bar types. Skill 235.
c.entries.push_back(makeRecipe(
22, 9938, "Heavy Mithril Helm", kBlacksmithing, 235,
7909, 1, 2, 11163,
{{3860, 8}, {3859, 1}, {3864, 4}, {3866, 2}}));
return c;
}
} // namespace pipeline
} // namespace wowee

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