mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-11 03:23:51 +00:00
feat(editor): add WSPR (Spell Reagent) — 80th open format milestone
Open replacement for the per-spell reagent fields in Spell.dbc
(Reagent[8] + ReagentCount[8]). Defines the item reagents that a
spell consumes from the caster's inventory each time it's cast —
Mage Portal needs a Rune of Portals, Resurrection needs a Holy
Candle (focused, not consumed), Warlock summons consume Soul
Shards.
One entry per reagent-using spell — most spells have no reagents
and are absent from this catalog. Each entry can list up to 8
(itemId, count) pairs which all must be present for the spell
to cast. Five reagentKind values capture the variety of reagent
semantics:
- Standard — ordinary consumed reagent
- SoulShard — warlock-specific shard tracking
- FocusedItem — required to cast but NOT consumed
(Symbol of Divinity for Resurrection)
- Catalyst — enables a stronger version of the spell
- Tradeable — crafting reagent for trade-skill recipes
Cross-references back to WSPL (every entry references a spellId)
and WIT (every reagent itemId references an item entry).
findBySpell(spellId) is the primary engine lookup.
Three preset emitters: --gen-spr (4 mage portal/teleport
reagents using Rune of Teleportation 17031), --gen-spr-warlock
(4 demon summons each consuming 1 Soul Shard 6265),
--gen-spr-rez (3 resurrection variants demonstrating each
ReagentKind including a no-reagent Druid Rebirth and a
focused-item Priest Resurrection).
Validation enforces id+name+spellId presence, reagentKind 0..4,
no duplicate ids; warns on:
- slot itemId/count mismatch (id without count or vice versa)
- SoulShard kind with non-canonical reagent (not item 6265)
- FocusedItem kind with no reagent slots set (focused-item
gating has nothing to gate)
- duplicate spellId across entries (engine honors only first)
This is the 80th open format milestone. Wired through the
cross-format table; WSPR appears automatically in all 14
cross-format utilities. Format count 79 -> 80; CLI flag count
974 -> 979.
This commit is contained in:
parent
736ec3a1c0
commit
d97f4bf5db
10 changed files with 704 additions and 0 deletions
|
|
@ -668,6 +668,7 @@ set(WOWEE_SOURCES
|
|||
src/pipeline/wowee_player_spawn_profiles.cpp
|
||||
src/pipeline/wowee_talent_tabs.cpp
|
||||
src/pipeline/wowee_currency_types.cpp
|
||||
src/pipeline/wowee_spell_reagents.cpp
|
||||
src/pipeline/custom_zone_discovery.cpp
|
||||
src/pipeline/dbc_layout.cpp
|
||||
|
||||
|
|
@ -1495,6 +1496,7 @@ add_executable(wowee_editor
|
|||
tools/editor/cli_player_spawn_profiles_catalog.cpp
|
||||
tools/editor/cli_talent_tabs_catalog.cpp
|
||||
tools/editor/cli_currency_types_catalog.cpp
|
||||
tools/editor/cli_spell_reagents_catalog.cpp
|
||||
tools/editor/cli_quest_objective.cpp
|
||||
tools/editor/cli_quest_reward.cpp
|
||||
tools/editor/cli_clone.cpp
|
||||
|
|
@ -1641,6 +1643,7 @@ add_executable(wowee_editor
|
|||
src/pipeline/wowee_player_spawn_profiles.cpp
|
||||
src/pipeline/wowee_talent_tabs.cpp
|
||||
src/pipeline/wowee_currency_types.cpp
|
||||
src/pipeline/wowee_spell_reagents.cpp
|
||||
src/pipeline/custom_zone_discovery.cpp
|
||||
src/pipeline/terrain_mesh.cpp
|
||||
|
||||
|
|
|
|||
113
include/pipeline/wowee_spell_reagents.hpp
Normal file
113
include/pipeline/wowee_spell_reagents.hpp
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
||||
// Wowee Open Spell Reagent catalog (.wspr) — novel
|
||||
// replacement for the per-spell reagent fields in
|
||||
// Spell.dbc (Reagent[8] + ReagentCount[8]). Defines the
|
||||
// item reagents that a spell consumes from the caster's
|
||||
// inventory each time it's cast — Mage Portal needs a
|
||||
// Rune of Portals, Resurrection needs an Ash of Eternity,
|
||||
// Warlock summons consume Soul Shards.
|
||||
//
|
||||
// One entry per spell that has reagents — most spells
|
||||
// have none and are absent from this catalog. Each entry
|
||||
// can list up to 8 (itemId, count) pairs which all must
|
||||
// be present for the spell to cast. The engine deducts
|
||||
// them on cast resolution.
|
||||
//
|
||||
// Cross-references with previously-added formats:
|
||||
// WSPL: spellId references the WSPL spell entry.
|
||||
// WIT: every reagentItem*Id references a WIT item
|
||||
// entry. The item's own consumeOnUse flag should
|
||||
// be set (or the engine defaults to consuming
|
||||
// since the spell explicitly references it).
|
||||
//
|
||||
// Binary layout (little-endian):
|
||||
// magic[4] = "WSPR"
|
||||
// version (uint32) = current 1
|
||||
// nameLen + name (catalog label)
|
||||
// entryCount (uint32)
|
||||
// entries (each):
|
||||
// reagentSetId (uint32)
|
||||
// nameLen + name
|
||||
// descLen + description
|
||||
// spellId (uint32)
|
||||
// reagentItemId[8] (uint32 each)
|
||||
// reagentCount[8] (uint32 each)
|
||||
// reagentKind (uint8) / pad[3]
|
||||
// iconColorRGBA (uint32)
|
||||
struct WoweeSpellReagent {
|
||||
enum ReagentKind : uint8_t {
|
||||
Standard = 0, // ordinary item reagent (most spells)
|
||||
SoulShard = 1, // warlock-specific shard consumption
|
||||
FocusedItem = 2, // not consumed; just required to cast
|
||||
// (Symbol of Divinity for Resurrection)
|
||||
Catalyst = 3, // one reagent enables stronger version
|
||||
Tradeable = 4, // crafting reagent (Trade Skill recipes)
|
||||
};
|
||||
|
||||
static constexpr int kMaxReagentSlots = 8;
|
||||
|
||||
struct Entry {
|
||||
uint32_t reagentSetId = 0;
|
||||
std::string name;
|
||||
std::string description;
|
||||
uint32_t spellId = 0;
|
||||
uint32_t reagentItemId[kMaxReagentSlots] = {};
|
||||
uint32_t reagentCount[kMaxReagentSlots] = {};
|
||||
uint8_t reagentKind = Standard;
|
||||
uint8_t pad0 = 0;
|
||||
uint8_t pad1 = 0;
|
||||
uint8_t pad2 = 0;
|
||||
uint32_t iconColorRGBA = 0xFFFFFFFFu;
|
||||
};
|
||||
|
||||
std::string name;
|
||||
std::vector<Entry> entries;
|
||||
|
||||
bool isValid() const { return !entries.empty(); }
|
||||
|
||||
const Entry* findById(uint32_t reagentSetId) const;
|
||||
const Entry* findBySpell(uint32_t spellId) const;
|
||||
|
||||
// Count the slots actually used (slots whose itemId is
|
||||
// non-zero). Most reagent sets use only 1-2 slots.
|
||||
int usedSlotCount(uint32_t reagentSetId) const;
|
||||
|
||||
static const char* reagentKindName(uint8_t k);
|
||||
};
|
||||
|
||||
class WoweeSpellReagentLoader {
|
||||
public:
|
||||
static bool save(const WoweeSpellReagent& cat,
|
||||
const std::string& basePath);
|
||||
static WoweeSpellReagent load(const std::string& basePath);
|
||||
static bool exists(const std::string& basePath);
|
||||
|
||||
// Preset emitters used by --gen-spr* variants.
|
||||
//
|
||||
// makeMage — 4 mage portal/teleport reagents
|
||||
// (Stormwind, Ironforge, Darnassus,
|
||||
// Theramore) consuming Rune of
|
||||
// Teleportation x1.
|
||||
// makeWarlock — 4 warlock summons consuming Soul
|
||||
// Shards (Voidwalker, Imp, Succubus,
|
||||
// Felhunter) — each takes 1 shard.
|
||||
// makeRez — 3 resurrection reagents (Ankh of
|
||||
// Reincarnation, Ash of Eternity for
|
||||
// priest mass-rez, druid Rebirth
|
||||
// no-cost). Mix of Standard,
|
||||
// FocusedItem, and no-reagent kinds.
|
||||
static WoweeSpellReagent makeMage(const std::string& catalogName);
|
||||
static WoweeSpellReagent makeWarlock(const std::string& catalogName);
|
||||
static WoweeSpellReagent makeRez(const std::string& catalogName);
|
||||
};
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace wowee
|
||||
277
src/pipeline/wowee_spell_reagents.cpp
Normal file
277
src/pipeline/wowee_spell_reagents.cpp
Normal file
|
|
@ -0,0 +1,277 @@
|
|||
#include "pipeline/wowee_spell_reagents.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr char kMagic[4] = {'W', 'S', 'P', 'R'};
|
||||
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) != ".wspr") {
|
||||
base += ".wspr";
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
uint32_t packRgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 0xFF) {
|
||||
return (static_cast<uint32_t>(a) << 24) |
|
||||
(static_cast<uint32_t>(b) << 16) |
|
||||
(static_cast<uint32_t>(g) << 8) |
|
||||
static_cast<uint32_t>(r);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const WoweeSpellReagent::Entry*
|
||||
WoweeSpellReagent::findById(uint32_t reagentSetId) const {
|
||||
for (const auto& e : entries)
|
||||
if (e.reagentSetId == reagentSetId) return &e;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const WoweeSpellReagent::Entry*
|
||||
WoweeSpellReagent::findBySpell(uint32_t spellId) const {
|
||||
for (const auto& e : entries)
|
||||
if (e.spellId == spellId) return &e;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int WoweeSpellReagent::usedSlotCount(uint32_t reagentSetId) const {
|
||||
const Entry* e = findById(reagentSetId);
|
||||
if (!e) return 0;
|
||||
int n = 0;
|
||||
for (int s = 0; s < kMaxReagentSlots; ++s) {
|
||||
if (e->reagentItemId[s] != 0) ++n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
const char* WoweeSpellReagent::reagentKindName(uint8_t k) {
|
||||
switch (k) {
|
||||
case Standard: return "standard";
|
||||
case SoulShard: return "soul-shard";
|
||||
case FocusedItem: return "focused-item";
|
||||
case Catalyst: return "catalyst";
|
||||
case Tradeable: return "tradeable";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
bool WoweeSpellReagentLoader::save(const WoweeSpellReagent& 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.reagentSetId);
|
||||
writeStr(os, e.name);
|
||||
writeStr(os, e.description);
|
||||
writePOD(os, e.spellId);
|
||||
for (int s = 0; s < WoweeSpellReagent::kMaxReagentSlots; ++s)
|
||||
writePOD(os, e.reagentItemId[s]);
|
||||
for (int s = 0; s < WoweeSpellReagent::kMaxReagentSlots; ++s)
|
||||
writePOD(os, e.reagentCount[s]);
|
||||
writePOD(os, e.reagentKind);
|
||||
writePOD(os, e.pad0);
|
||||
writePOD(os, e.pad1);
|
||||
writePOD(os, e.pad2);
|
||||
writePOD(os, e.iconColorRGBA);
|
||||
}
|
||||
return os.good();
|
||||
}
|
||||
|
||||
WoweeSpellReagent WoweeSpellReagentLoader::load(
|
||||
const std::string& basePath) {
|
||||
WoweeSpellReagent 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.reagentSetId)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
if (!readStr(is, e.name) || !readStr(is, e.description)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
if (!readPOD(is, e.spellId)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
for (int s = 0; s < WoweeSpellReagent::kMaxReagentSlots; ++s) {
|
||||
if (!readPOD(is, e.reagentItemId[s])) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
}
|
||||
for (int s = 0; s < WoweeSpellReagent::kMaxReagentSlots; ++s) {
|
||||
if (!readPOD(is, e.reagentCount[s])) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
}
|
||||
if (!readPOD(is, e.reagentKind) ||
|
||||
!readPOD(is, e.pad0) ||
|
||||
!readPOD(is, e.pad1) ||
|
||||
!readPOD(is, e.pad2) ||
|
||||
!readPOD(is, e.iconColorRGBA)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool WoweeSpellReagentLoader::exists(const std::string& basePath) {
|
||||
std::ifstream is(normalizePath(basePath), std::ios::binary);
|
||||
return is.good();
|
||||
}
|
||||
|
||||
WoweeSpellReagent WoweeSpellReagentLoader::makeMage(
|
||||
const std::string& catalogName) {
|
||||
using R = WoweeSpellReagent;
|
||||
WoweeSpellReagent c;
|
||||
c.name = catalogName;
|
||||
auto add = [&](uint32_t id, const char* name, uint32_t spellId,
|
||||
uint32_t runeItemId, const char* desc) {
|
||||
R::Entry e;
|
||||
e.reagentSetId = id; e.name = name; e.description = desc;
|
||||
e.spellId = spellId;
|
||||
e.reagentItemId[0] = runeItemId;
|
||||
e.reagentCount[0] = 1;
|
||||
e.reagentKind = R::Standard;
|
||||
e.iconColorRGBA = packRgba(80, 140, 240); // mage blue
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
// Spell ids match WoW 3.3.5a teleport/portal spell ids;
|
||||
// item id 17031 = Rune of Teleportation (single-use
|
||||
// teleport runes), 17032 = Rune of Portals (groups).
|
||||
add(1, "TeleportStormwind", 3565, 17031,
|
||||
"Teleport: Stormwind — consumes 1 Rune of Teleportation.");
|
||||
add(2, "TeleportIronforge", 3562, 17031,
|
||||
"Teleport: Ironforge — consumes 1 Rune of Teleportation.");
|
||||
add(3, "TeleportDarnassus", 3561, 17031,
|
||||
"Teleport: Darnassus — consumes 1 Rune of Teleportation.");
|
||||
add(4, "PortalStormwind", 10059, 17032,
|
||||
"Portal: Stormwind — consumes 1 Rune of Portals.");
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeSpellReagent WoweeSpellReagentLoader::makeWarlock(
|
||||
const std::string& catalogName) {
|
||||
using R = WoweeSpellReagent;
|
||||
WoweeSpellReagent c;
|
||||
c.name = catalogName;
|
||||
auto add = [&](uint32_t id, const char* name, uint32_t spellId,
|
||||
const char* desc) {
|
||||
R::Entry e;
|
||||
e.reagentSetId = id; e.name = name; e.description = desc;
|
||||
e.spellId = spellId;
|
||||
// Item 6265 = Soul Shard.
|
||||
e.reagentItemId[0] = 6265;
|
||||
e.reagentCount[0] = 1;
|
||||
e.reagentKind = R::SoulShard;
|
||||
e.iconColorRGBA = packRgba(140, 60, 200); // warlock purple
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
// Warlock summon spell ids; each consumes 1 Soul Shard.
|
||||
add(100, "SummonImp", 688, "Summon Imp — consumes 1 Soul Shard.");
|
||||
add(101, "SummonVoidwalker", 697, "Summon Voidwalker — consumes 1 Soul Shard.");
|
||||
add(102, "SummonSuccubus", 712, "Summon Succubus — consumes 1 Soul Shard.");
|
||||
add(103, "SummonFelhunter", 691, "Summon Felhunter — consumes 1 Soul Shard.");
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeSpellReagent WoweeSpellReagentLoader::makeRez(
|
||||
const std::string& catalogName) {
|
||||
using R = WoweeSpellReagent;
|
||||
WoweeSpellReagent c;
|
||||
c.name = catalogName;
|
||||
// Mix of three resurrection styles, demonstrating each
|
||||
// ReagentKind. Different presets to show kind variety.
|
||||
R::Entry ankh;
|
||||
ankh.reagentSetId = 200;
|
||||
ankh.name = "ShamanReincarnation";
|
||||
ankh.description = "Reincarnation — consumes 1 Ankh of Reincarnation.";
|
||||
ankh.spellId = 20608;
|
||||
ankh.reagentItemId[0] = 17030; // Ankh
|
||||
ankh.reagentCount[0] = 1;
|
||||
ankh.reagentKind = R::Standard;
|
||||
ankh.iconColorRGBA = packRgba(220, 200, 100);
|
||||
c.entries.push_back(ankh);
|
||||
|
||||
R::Entry priestRez;
|
||||
priestRez.reagentSetId = 201;
|
||||
priestRez.name = "PriestResurrection";
|
||||
priestRez.description = "Resurrection — requires Holy Candle "
|
||||
"(focused, NOT consumed on cast).";
|
||||
priestRez.spellId = 2006;
|
||||
priestRez.reagentItemId[0] = 17029; // Holy Candle
|
||||
priestRez.reagentCount[0] = 1;
|
||||
priestRez.reagentKind = R::FocusedItem;
|
||||
priestRez.iconColorRGBA = packRgba(240, 240, 200);
|
||||
c.entries.push_back(priestRez);
|
||||
|
||||
R::Entry druidRebirth;
|
||||
druidRebirth.reagentSetId = 202;
|
||||
druidRebirth.name = "DruidRebirth";
|
||||
druidRebirth.description = "Rebirth — combat rez, no reagent in "
|
||||
"WotLK+ (legacy entry kept for migration).";
|
||||
druidRebirth.spellId = 20484;
|
||||
// Empty reagent slots — Rebirth is reagent-free in
|
||||
// 3.3.5a but the entry is kept so the engine has a
|
||||
// consistent lookup point.
|
||||
druidRebirth.reagentKind = R::Standard;
|
||||
druidRebirth.iconColorRGBA = packRgba(100, 200, 100);
|
||||
c.entries.push_back(druidRebirth);
|
||||
return c;
|
||||
}
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace wowee
|
||||
|
|
@ -244,6 +244,8 @@ const char* const kArgRequired[] = {
|
|||
"--gen-ctr", "--gen-ctr-pve", "--gen-ctr-faction",
|
||||
"--info-wctr", "--validate-wctr",
|
||||
"--export-wctr-json", "--import-wctr-json",
|
||||
"--gen-spr", "--gen-spr-warlock", "--gen-spr-rez",
|
||||
"--info-wspr", "--validate-wspr",
|
||||
"--gen-weather-temperate", "--gen-weather-arctic",
|
||||
"--gen-weather-desert", "--gen-weather-stormy",
|
||||
"--gen-zone-atmosphere",
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@
|
|||
#include "cli_player_spawn_profiles_catalog.hpp"
|
||||
#include "cli_talent_tabs_catalog.hpp"
|
||||
#include "cli_currency_types_catalog.hpp"
|
||||
#include "cli_spell_reagents_catalog.hpp"
|
||||
#include "cli_quest_objective.hpp"
|
||||
#include "cli_quest_reward.hpp"
|
||||
#include "cli_clone.hpp"
|
||||
|
|
@ -281,6 +282,7 @@ constexpr DispatchFn kDispatchTable[] = {
|
|||
handlePlayerSpawnProfilesCatalog,
|
||||
handleTalentTabsCatalog,
|
||||
handleCurrencyTypesCatalog,
|
||||
handleSpellReagentsCatalog,
|
||||
handleQuestObjective,
|
||||
handleQuestReward,
|
||||
handleClone,
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ constexpr FormatMagicEntry kFormats[] = {
|
|||
{{'W','P','S','P'}, ".wpsp", "chars", "--info-wpsp", "Player spawn profile catalog"},
|
||||
{{'W','T','L','E'}, ".wtle", "talents", "--info-wtle", "Talent tab / tree catalog"},
|
||||
{{'W','C','T','R'}, ".wctr", "currency", "--info-wctr", "Currency type catalog"},
|
||||
{{'W','S','P','R'}, ".wspr", "spells", "--info-wspr", "Spell reagent set 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"},
|
||||
|
|
|
|||
|
|
@ -1865,6 +1865,16 @@ void printUsage(const char* argv0) {
|
|||
std::printf(" Export binary .wctr to a human-editable JSON sidecar (defaults to <base>.wctr.json)\n");
|
||||
std::printf(" --import-wctr-json <json-path> [out-base]\n");
|
||||
std::printf(" Import a .wctr.json sidecar back into binary .wctr (accepts currencyKind int OR currencyKindName string; isAccountWide bool OR int)\n");
|
||||
std::printf(" --gen-spr <wspr-base> [name]\n");
|
||||
std::printf(" Emit .wspr 4 mage portal/teleport reagents (Stormwind/Ironforge/Darnassus/Theramore) consuming Rune of Teleportation\n");
|
||||
std::printf(" --gen-spr-warlock <wspr-base> [name]\n");
|
||||
std::printf(" Emit .wspr 4 warlock summons (Imp / Voidwalker / Succubus / Felhunter) each consuming 1 Soul Shard\n");
|
||||
std::printf(" --gen-spr-rez <wspr-base> [name]\n");
|
||||
std::printf(" Emit .wspr 3 resurrection variants (Shaman Reincarnation / Priest Resurrection focused / Druid Rebirth no-cost) demonstrating each ReagentKind\n");
|
||||
std::printf(" --info-wspr <wspr-base> [--json]\n");
|
||||
std::printf(" Print WSPR entries (id / spellId / kind / used slot count / item x count list / name)\n");
|
||||
std::printf(" --validate-wspr <wspr-base> [--json]\n");
|
||||
std::printf(" Static checks: id+name+spellId required, reagentKind 0..4, no duplicate ids; warns on slot id/count mismatch, SoulShard kind with non-canonical reagent, FocusedItem kind with no slots, duplicate spellId\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");
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ constexpr FormatRow kFormats[] = {
|
|||
{"WPSP", ".wpsp", "chars", "playercreateinfo SQL + StartOutfit","Player spawn profile catalog"},
|
||||
{"WTLE", ".wtle", "talents", "TalentTab.dbc", "Talent tab / tree catalog"},
|
||||
{"WCTR", ".wctr", "currency", "CurrencyTypes.dbc + caps", "Currency type catalog"},
|
||||
{"WSPR", ".wspr", "spells", "Spell.dbc Reagent[8]+Count[8]", "Spell reagent set catalog"},
|
||||
|
||||
// Additional pipeline catalogs without the alternating
|
||||
// gen/info/validate CLI surface (loaded by the engine
|
||||
|
|
|
|||
283
tools/editor/cli_spell_reagents_catalog.cpp
Normal file
283
tools/editor/cli_spell_reagents_catalog.cpp
Normal file
|
|
@ -0,0 +1,283 @@
|
|||
#include "cli_spell_reagents_catalog.hpp"
|
||||
#include "cli_arg_parse.hpp"
|
||||
#include "cli_box_emitter.hpp"
|
||||
|
||||
#include "pipeline/wowee_spell_reagents.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 stripWsprExt(std::string base) {
|
||||
stripExt(base, ".wspr");
|
||||
return base;
|
||||
}
|
||||
|
||||
bool saveOrError(const wowee::pipeline::WoweeSpellReagent& c,
|
||||
const std::string& base, const char* cmd) {
|
||||
if (!wowee::pipeline::WoweeSpellReagentLoader::save(c, base)) {
|
||||
std::fprintf(stderr, "%s: failed to save %s.wspr\n",
|
||||
cmd, base.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void printGenSummary(const wowee::pipeline::WoweeSpellReagent& c,
|
||||
const std::string& base) {
|
||||
std::printf("Wrote %s.wspr\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" sets : %zu\n", c.entries.size());
|
||||
}
|
||||
|
||||
int handleGenMage(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "MageReagents";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWsprExt(base);
|
||||
auto c = wowee::pipeline::WoweeSpellReagentLoader::makeMage(name);
|
||||
if (!saveOrError(c, base, "gen-spr")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenWarlock(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "WarlockReagents";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWsprExt(base);
|
||||
auto c = wowee::pipeline::WoweeSpellReagentLoader::makeWarlock(name);
|
||||
if (!saveOrError(c, base, "gen-spr-warlock")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenRez(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "ResurrectionReagents";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWsprExt(base);
|
||||
auto c = wowee::pipeline::WoweeSpellReagentLoader::makeRez(name);
|
||||
if (!saveOrError(c, base, "gen-spr-rez")) 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 = stripWsprExt(base);
|
||||
if (!wowee::pipeline::WoweeSpellReagentLoader::exists(base)) {
|
||||
std::fprintf(stderr, "WSPR not found: %s.wspr\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeSpellReagentLoader::load(base);
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wspr"] = base + ".wspr";
|
||||
j["name"] = c.name;
|
||||
j["count"] = c.entries.size();
|
||||
nlohmann::json arr = nlohmann::json::array();
|
||||
for (const auto& e : c.entries) {
|
||||
nlohmann::json items = nlohmann::json::array();
|
||||
nlohmann::json counts = nlohmann::json::array();
|
||||
for (int s = 0; s < wowee::pipeline::WoweeSpellReagent::kMaxReagentSlots; ++s) {
|
||||
items.push_back(e.reagentItemId[s]);
|
||||
counts.push_back(e.reagentCount[s]);
|
||||
}
|
||||
arr.push_back({
|
||||
{"reagentSetId", e.reagentSetId},
|
||||
{"name", e.name},
|
||||
{"description", e.description},
|
||||
{"spellId", e.spellId},
|
||||
{"reagentItemId", items},
|
||||
{"reagentCount", counts},
|
||||
{"reagentKind", e.reagentKind},
|
||||
{"reagentKindName", wowee::pipeline::WoweeSpellReagent::reagentKindName(e.reagentKind)},
|
||||
{"iconColorRGBA", e.iconColorRGBA},
|
||||
});
|
||||
}
|
||||
j["entries"] = arr;
|
||||
std::printf("%s\n", j.dump(2).c_str());
|
||||
return 0;
|
||||
}
|
||||
std::printf("WSPR: %s.wspr\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" sets : %zu\n", c.entries.size());
|
||||
if (c.entries.empty()) return 0;
|
||||
std::printf(" id spellId kind slots reagents (item x count) name\n");
|
||||
for (const auto& e : c.entries) {
|
||||
std::string slots;
|
||||
int used = 0;
|
||||
for (int s = 0; s < wowee::pipeline::WoweeSpellReagent::kMaxReagentSlots; ++s) {
|
||||
if (e.reagentItemId[s] == 0) continue;
|
||||
if (!slots.empty()) slots += ", ";
|
||||
slots += std::to_string(e.reagentItemId[s]) + " x " +
|
||||
std::to_string(e.reagentCount[s]);
|
||||
++used;
|
||||
}
|
||||
if (slots.empty()) slots = "(none)";
|
||||
std::printf(" %4u %5u %-12s %d %-35s %s\n",
|
||||
e.reagentSetId, e.spellId,
|
||||
wowee::pipeline::WoweeSpellReagent::reagentKindName(e.reagentKind),
|
||||
used, slots.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 = stripWsprExt(base);
|
||||
if (!wowee::pipeline::WoweeSpellReagentLoader::exists(base)) {
|
||||
std::fprintf(stderr,
|
||||
"validate-wspr: WSPR not found: %s.wspr\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeSpellReagentLoader::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;
|
||||
std::vector<uint32_t> spellsSeen;
|
||||
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.reagentSetId);
|
||||
if (!e.name.empty()) ctx += " " + e.name;
|
||||
ctx += ")";
|
||||
if (e.reagentSetId == 0)
|
||||
errors.push_back(ctx + ": reagentSetId is 0");
|
||||
if (e.name.empty())
|
||||
errors.push_back(ctx + ": name is empty");
|
||||
if (e.spellId == 0)
|
||||
errors.push_back(ctx +
|
||||
": spellId is 0 — missing WSPL cross-ref");
|
||||
if (e.reagentKind > wowee::pipeline::WoweeSpellReagent::Tradeable) {
|
||||
errors.push_back(ctx + ": reagentKind " +
|
||||
std::to_string(e.reagentKind) + " not in 0..4");
|
||||
}
|
||||
// Per-slot checks: itemId+count must be both set or both clear
|
||||
int usedSlots = 0;
|
||||
for (int s = 0; s < wowee::pipeline::WoweeSpellReagent::kMaxReagentSlots; ++s) {
|
||||
uint32_t it = e.reagentItemId[s];
|
||||
uint32_t cnt = e.reagentCount[s];
|
||||
if (it != 0 && cnt == 0) {
|
||||
warnings.push_back(ctx +
|
||||
": slot " + std::to_string(s) +
|
||||
" has itemId=" + std::to_string(it) +
|
||||
" but count=0 — reagent will not be consumed");
|
||||
} else if (it == 0 && cnt != 0) {
|
||||
warnings.push_back(ctx +
|
||||
": slot " + std::to_string(s) +
|
||||
" has count=" + std::to_string(cnt) +
|
||||
" but itemId=0 — count is unreachable");
|
||||
}
|
||||
if (it != 0) ++usedSlots;
|
||||
}
|
||||
// SoulShard kind should reference item 6265 in slot 0.
|
||||
// Other shard ids are server-custom but the canonical
|
||||
// case is worth flagging.
|
||||
if (e.reagentKind == wowee::pipeline::WoweeSpellReagent::SoulShard &&
|
||||
e.reagentItemId[0] != 6265 && e.reagentItemId[0] != 0) {
|
||||
warnings.push_back(ctx +
|
||||
": SoulShard kind with non-canonical reagent " +
|
||||
"id " + std::to_string(e.reagentItemId[0]) +
|
||||
" in slot 0 (canonical Soul Shard is item 6265)");
|
||||
}
|
||||
// FocusedItem kind: reagent is required to cast but
|
||||
// not consumed. Should still have an itemId set.
|
||||
if (e.reagentKind == wowee::pipeline::WoweeSpellReagent::FocusedItem &&
|
||||
usedSlots == 0) {
|
||||
warnings.push_back(ctx +
|
||||
": FocusedItem kind with no reagent slots set " +
|
||||
"— focused-item gating has nothing to gate");
|
||||
}
|
||||
for (uint32_t prev : idsSeen) {
|
||||
if (prev == e.reagentSetId) {
|
||||
errors.push_back(ctx + ": duplicate reagentSetId");
|
||||
break;
|
||||
}
|
||||
}
|
||||
idsSeen.push_back(e.reagentSetId);
|
||||
// Two reagent sets for the same spell collide —
|
||||
// engine would honor only the first.
|
||||
if (e.spellId != 0) {
|
||||
for (uint32_t prevSpell : spellsSeen) {
|
||||
if (prevSpell == e.spellId) {
|
||||
warnings.push_back(ctx +
|
||||
": duplicate spellId " +
|
||||
std::to_string(e.spellId) +
|
||||
" — only first reagent set will be used");
|
||||
break;
|
||||
}
|
||||
}
|
||||
spellsSeen.push_back(e.spellId);
|
||||
}
|
||||
}
|
||||
bool ok = errors.empty();
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wspr"] = base + ".wspr";
|
||||
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-wspr: %s.wspr\n", base.c_str());
|
||||
if (ok && warnings.empty()) {
|
||||
std::printf(" OK — %zu reagent sets, all reagentSetIds unique, all spell ids set\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 handleSpellReagentsCatalog(int& i, int argc, char** argv,
|
||||
int& outRc) {
|
||||
if (std::strcmp(argv[i], "--gen-spr") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenMage(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-spr-warlock") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenWarlock(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-spr-rez") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenRez(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--info-wspr") == 0 && i + 1 < argc) {
|
||||
outRc = handleInfo(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--validate-wspr") == 0 && i + 1 < argc) {
|
||||
outRc = handleValidate(i, argc, argv); return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace editor
|
||||
} // namespace wowee
|
||||
12
tools/editor/cli_spell_reagents_catalog.hpp
Normal file
12
tools/editor/cli_spell_reagents_catalog.hpp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
namespace cli {
|
||||
|
||||
bool handleSpellReagentsCatalog(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