mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 02:53:51 +00:00
feat(pipeline): add WSKL (Wowee Skill Catalog) format
Novel open replacement for Blizzard's SkillLine.dbc +
SkillLineCategory.dbc + the AzerothCore-style player skill
base tables. The 19th open format added to the editor.
Defines every player-trackable skill: weapon proficiencies
(Swords, Axes, Bows), professions (Mining, Alchemy,
Cooking), languages (Common, Dwarvish), class
specializations (Fire, Frost, Holy, Protection), armor
proficiencies (Mail, Plate), and secondary skills (First
Aid, Lockpicking, Riding).
Cross-references with previously-added formats:
WLCK.channel.targetId (kind=Lockpick) -> WSKL.entry.skillId
WGOT.entry.requiredSkill -> WSKL.entry.skillId
The starter preset's skillIds 186 (Mining) and 633
(Lockpicking) deliberately match the canonical IDs already
referenced by WGOT.makeGather and WLCK.makeDungeon —
so the demo content stack now wires together end-to-end:
WGOT herb-node requires skill 186 -> WSKL Mining at rank 1+;
WLCK bandit-strongbox channel requires skill 633 -> WSKL
Lockpicking at rank 1+.
Format:
• magic "WSKL", version 1, little-endian
• per skill: skillId / name / description / categoryId /
canTrain / maxRank / rankPerLevel / iconPath
Enums:
• CategoryId (8): Weapon / Class / Profession /
SecondaryProfession / Language / ArmorProficiency /
Riding / WeaponSpec
API: WoweeSkillLoader::save / load / exists / findById;
presets makeStarter (5-skill demo with cross-referenced
canonical IDs), makeProfessions (12 classic professions:
9 primary + 3 secondary), makeWeapons (16 weapon skills
with canonical SkillLine IDs and rankPerLevel=5 auto-grow).
CLI added (5 flags, 528 documented total now):
--gen-skills / --gen-skills-professions / --gen-skills-weapons
--info-wskl / --validate-wskl
Validator catches: skillId=0 + duplicates, empty name,
maxRank=0, unknown categoryId, suspicious maxRank=1 on
non-Language skill (only languages cap at 1), weapon skill
with rankPerLevel=0 (won't auto-grow on use).
This commit is contained in:
parent
dda7933df9
commit
95e593e59c
8 changed files with 581 additions and 0 deletions
|
|
@ -606,6 +606,7 @@ set(WOWEE_SOURCES
|
|||
src/pipeline/wowee_objects.cpp
|
||||
src/pipeline/wowee_factions.cpp
|
||||
src/pipeline/wowee_locks.cpp
|
||||
src/pipeline/wowee_skills.cpp
|
||||
src/pipeline/custom_zone_discovery.cpp
|
||||
src/pipeline/dbc_layout.cpp
|
||||
|
||||
|
|
@ -1358,6 +1359,7 @@ add_executable(wowee_editor
|
|||
tools/editor/cli_objects_catalog.cpp
|
||||
tools/editor/cli_factions_catalog.cpp
|
||||
tools/editor/cli_locks_catalog.cpp
|
||||
tools/editor/cli_skills_catalog.cpp
|
||||
tools/editor/cli_quest_objective.cpp
|
||||
tools/editor/cli_quest_reward.cpp
|
||||
tools/editor/cli_clone.cpp
|
||||
|
|
@ -1442,6 +1444,7 @@ add_executable(wowee_editor
|
|||
src/pipeline/wowee_objects.cpp
|
||||
src/pipeline/wowee_factions.cpp
|
||||
src/pipeline/wowee_locks.cpp
|
||||
src/pipeline/wowee_skills.cpp
|
||||
src/pipeline/custom_zone_discovery.cpp
|
||||
src/pipeline/terrain_mesh.cpp
|
||||
|
||||
|
|
|
|||
95
include/pipeline/wowee_skills.hpp
Normal file
95
include/pipeline/wowee_skills.hpp
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
||||
// Wowee Open Skill Catalog (.wskl) — novel replacement for
|
||||
// Blizzard's SkillLine.dbc + SkillLineCategory.dbc + the
|
||||
// AzerothCore-style player_classlevelstats / skill base
|
||||
// tables. The 19th open format added to the editor.
|
||||
//
|
||||
// Defines every player-trackable skill: weapon proficiencies
|
||||
// (Swords, Axes, Bows), professions (Mining, Alchemy,
|
||||
// Cooking), languages (Common, Dwarvish), class
|
||||
// specializations (Fire, Frost, Holy, Protection),
|
||||
// armor proficiencies (Mail, Plate), and secondary skills
|
||||
// (First Aid, Lockpicking, Riding).
|
||||
//
|
||||
// Cross-references with previously-added formats:
|
||||
// WLCK.channel.targetId (kind=Lockpick) → WSKL.entry.skillId
|
||||
// WGOT.entry.requiredSkill → WSKL.entry.skillId
|
||||
//
|
||||
// Binary layout (little-endian):
|
||||
// magic[4] = "WSKL"
|
||||
// version (uint32) = current 1
|
||||
// nameLen + name (catalog label)
|
||||
// entryCount (uint32)
|
||||
// entries (each):
|
||||
// skillId (uint32)
|
||||
// nameLen + name
|
||||
// descLen + description
|
||||
// categoryId (uint8) / canTrain (uint8) / pad[2]
|
||||
// maxRank (uint16) / rankPerLevel (uint16)
|
||||
// iconLen + iconPath
|
||||
struct WoweeSkill {
|
||||
enum CategoryId : uint8_t {
|
||||
Weapon = 0,
|
||||
Class = 1, // class spec trees (Fire, Holy, ...)
|
||||
Profession = 2, // primary: Mining, Alchemy
|
||||
SecondaryProfession = 3, // First Aid, Cooking, Fishing
|
||||
Language = 4,
|
||||
ArmorProficiency = 5, // Mail, Plate, Shields
|
||||
Riding = 6,
|
||||
WeaponSpec = 7, // class weapon-specialization talents
|
||||
};
|
||||
|
||||
struct Entry {
|
||||
uint32_t skillId = 0;
|
||||
std::string name;
|
||||
std::string description;
|
||||
uint8_t categoryId = Profession;
|
||||
uint8_t canTrain = 1; // 1 = requires trainer
|
||||
uint16_t maxRank = 300; // typical classic profession cap
|
||||
uint16_t rankPerLevel = 0; // weapon skills auto-grow
|
||||
std::string iconPath;
|
||||
};
|
||||
|
||||
std::string name;
|
||||
std::vector<Entry> entries;
|
||||
|
||||
bool isValid() const { return !entries.empty(); }
|
||||
|
||||
// Lookup by skillId — nullptr if not present.
|
||||
const Entry* findById(uint32_t skillId) const;
|
||||
|
||||
static const char* categoryName(uint8_t c);
|
||||
};
|
||||
|
||||
class WoweeSkillLoader {
|
||||
public:
|
||||
static bool save(const WoweeSkill& cat,
|
||||
const std::string& basePath);
|
||||
static WoweeSkill load(const std::string& basePath);
|
||||
static bool exists(const std::string& basePath);
|
||||
|
||||
// Preset emitters used by --gen-skills* variants.
|
||||
//
|
||||
// makeStarter — minimal: Swords + Lockpicking + Mining +
|
||||
// First Aid + Common (one per category that
|
||||
// the runtime uses immediately).
|
||||
// makeProfessions — full primary + secondary profession
|
||||
// set (the 12 classic gathering /
|
||||
// crafting professions).
|
||||
// makeWeapons — every weapon-skill slot with WoW's
|
||||
// canonical max-rank scaling (rankPerLevel=5).
|
||||
static WoweeSkill makeStarter(const std::string& catalogName);
|
||||
static WoweeSkill makeProfessions(const std::string& catalogName);
|
||||
static WoweeSkill makeWeapons(const std::string& catalogName);
|
||||
};
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace wowee
|
||||
225
src/pipeline/wowee_skills.cpp
Normal file
225
src/pipeline/wowee_skills.cpp
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
#include "pipeline/wowee_skills.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr char kMagic[4] = {'W', 'S', 'K', 'L'};
|
||||
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) != ".wskl") {
|
||||
base += ".wskl";
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const WoweeSkill::Entry* WoweeSkill::findById(uint32_t skillId) const {
|
||||
for (const auto& e : entries) {
|
||||
if (e.skillId == skillId) return &e;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* WoweeSkill::categoryName(uint8_t c) {
|
||||
switch (c) {
|
||||
case Weapon: return "weapon";
|
||||
case Class: return "class";
|
||||
case Profession: return "profession";
|
||||
case SecondaryProfession: return "secondary";
|
||||
case Language: return "language";
|
||||
case ArmorProficiency: return "armor";
|
||||
case Riding: return "riding";
|
||||
case WeaponSpec: return "weapon-spec";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
bool WoweeSkillLoader::save(const WoweeSkill& 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.skillId);
|
||||
writeStr(os, e.name);
|
||||
writeStr(os, e.description);
|
||||
writePOD(os, e.categoryId);
|
||||
writePOD(os, e.canTrain);
|
||||
uint8_t pad[2] = {0, 0};
|
||||
os.write(reinterpret_cast<const char*>(pad), 2);
|
||||
writePOD(os, e.maxRank);
|
||||
writePOD(os, e.rankPerLevel);
|
||||
writeStr(os, e.iconPath);
|
||||
}
|
||||
return os.good();
|
||||
}
|
||||
|
||||
WoweeSkill WoweeSkillLoader::load(const std::string& basePath) {
|
||||
WoweeSkill 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.skillId)) { out.entries.clear(); return out; }
|
||||
if (!readStr(is, e.name) || !readStr(is, e.description)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
if (!readPOD(is, e.categoryId) ||
|
||||
!readPOD(is, e.canTrain)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
uint8_t pad[2];
|
||||
is.read(reinterpret_cast<char*>(pad), 2);
|
||||
if (is.gcount() != 2) { out.entries.clear(); return out; }
|
||||
if (!readPOD(is, e.maxRank) ||
|
||||
!readPOD(is, e.rankPerLevel)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
if (!readStr(is, e.iconPath)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool WoweeSkillLoader::exists(const std::string& basePath) {
|
||||
std::ifstream is(normalizePath(basePath), std::ios::binary);
|
||||
return is.good();
|
||||
}
|
||||
|
||||
WoweeSkill WoweeSkillLoader::makeStarter(const std::string& catalogName) {
|
||||
WoweeSkill c;
|
||||
c.name = catalogName;
|
||||
auto add = [&](uint32_t id, const char* name, uint8_t cat,
|
||||
uint16_t maxRank, uint16_t perLevel,
|
||||
uint8_t train) {
|
||||
WoweeSkill::Entry e;
|
||||
e.skillId = id; e.name = name;
|
||||
e.categoryId = cat; e.maxRank = maxRank;
|
||||
e.rankPerLevel = perLevel; e.canTrain = train;
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
add(43, "Swords", WoweeSkill::Weapon, 300, 5, 1);
|
||||
add(98, "Common", WoweeSkill::Language, 1, 0, 0);
|
||||
add(129, "First Aid", WoweeSkill::SecondaryProfession, 300, 0, 1);
|
||||
// SkillId 186 = Mining, 633 = Lockpicking — the canonical
|
||||
// values that WGOT.makeGather and WLCK.makeDungeon already
|
||||
// reference.
|
||||
add(186, "Mining", WoweeSkill::Profession, 300, 0, 1);
|
||||
add(633, "Lockpicking", WoweeSkill::SecondaryProfession, 300, 0, 1);
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeSkill WoweeSkillLoader::makeProfessions(const std::string& catalogName) {
|
||||
WoweeSkill c;
|
||||
c.name = catalogName;
|
||||
auto add = [&](uint32_t id, const char* name, uint8_t cat) {
|
||||
WoweeSkill::Entry e;
|
||||
e.skillId = id; e.name = name;
|
||||
e.categoryId = cat; e.maxRank = 300; e.canTrain = 1;
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
// Primary professions (canonical SkillLine IDs).
|
||||
add(164, "Blacksmithing", WoweeSkill::Profession);
|
||||
add(165, "Leatherworking", WoweeSkill::Profession);
|
||||
add(171, "Alchemy", WoweeSkill::Profession);
|
||||
add(182, "Herbalism", WoweeSkill::Profession);
|
||||
add(186, "Mining", WoweeSkill::Profession);
|
||||
add(197, "Tailoring", WoweeSkill::Profession);
|
||||
add(202, "Engineering", WoweeSkill::Profession);
|
||||
add(333, "Enchanting", WoweeSkill::Profession);
|
||||
add(393, "Skinning", WoweeSkill::Profession);
|
||||
// Secondary professions.
|
||||
add(129, "First Aid", WoweeSkill::SecondaryProfession);
|
||||
add(185, "Cooking", WoweeSkill::SecondaryProfession);
|
||||
add(356, "Fishing", WoweeSkill::SecondaryProfession);
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeSkill WoweeSkillLoader::makeWeapons(const std::string& catalogName) {
|
||||
WoweeSkill c;
|
||||
c.name = catalogName;
|
||||
auto add = [&](uint32_t id, const char* name) {
|
||||
WoweeSkill::Entry e;
|
||||
e.skillId = id; e.name = name;
|
||||
e.categoryId = WoweeSkill::Weapon;
|
||||
e.maxRank = 300; // matches character-level cap × 5
|
||||
e.rankPerLevel = 5; // weapon skill auto-grows by 5/level
|
||||
e.canTrain = 0; // weapons train via use, not trainer
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
// Canonical SkillLine IDs from WoW classic.
|
||||
add( 43, "Swords");
|
||||
add( 44, "Axes");
|
||||
add( 45, "Bows");
|
||||
add( 46, "Guns");
|
||||
add( 54, "Maces");
|
||||
add( 55, "Two-Handed Swords");
|
||||
add( 95, "Defense");
|
||||
add(118, "Daggers");
|
||||
add(136, "Staves");
|
||||
add(160, "Two-Handed Maces");
|
||||
add(172, "Two-Handed Axes");
|
||||
add(173, "Polearms");
|
||||
add(176, "Thrown");
|
||||
add(226, "Crossbows");
|
||||
add(228, "Wands");
|
||||
add(473, "Fist Weapons");
|
||||
return c;
|
||||
}
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace wowee
|
||||
|
|
@ -52,6 +52,8 @@ const char* const kArgRequired[] = {
|
|||
"--export-wfac-json", "--import-wfac-json",
|
||||
"--gen-locks", "--gen-locks-dungeon", "--gen-locks-professions",
|
||||
"--info-wlck", "--validate-wlck",
|
||||
"--gen-skills", "--gen-skills-professions", "--gen-skills-weapons",
|
||||
"--info-wskl", "--validate-wskl",
|
||||
"--gen-weather-temperate", "--gen-weather-arctic",
|
||||
"--gen-weather-desert", "--gen-weather-stormy",
|
||||
"--gen-zone-atmosphere",
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
#include "cli_objects_catalog.hpp"
|
||||
#include "cli_factions_catalog.hpp"
|
||||
#include "cli_locks_catalog.hpp"
|
||||
#include "cli_skills_catalog.hpp"
|
||||
#include "cli_quest_objective.hpp"
|
||||
#include "cli_quest_reward.hpp"
|
||||
#include "cli_clone.hpp"
|
||||
|
|
@ -133,6 +134,7 @@ constexpr DispatchFn kDispatchTable[] = {
|
|||
handleObjectsCatalog,
|
||||
handleFactionsCatalog,
|
||||
handleLocksCatalog,
|
||||
handleSkillsCatalog,
|
||||
handleQuestObjective,
|
||||
handleQuestReward,
|
||||
handleClone,
|
||||
|
|
|
|||
|
|
@ -961,6 +961,16 @@ void printUsage(const char* argv0) {
|
|||
std::printf(" Print WLCK lock entries with per-channel detail (kind / target / required skill rank)\n");
|
||||
std::printf(" --validate-wlck <wlck-base> [--json]\n");
|
||||
std::printf(" Static checks: lockId>0+unique, at least 1 active channel, item/spell/lockpick need targetId\n");
|
||||
std::printf(" --gen-skills <wskl-base> [name]\n");
|
||||
std::printf(" Emit .wskl starter: Swords + Common + First Aid + Mining (id=186) + Lockpicking (id=633) — matches WGOT/WLCK\n");
|
||||
std::printf(" --gen-skills-professions <wskl-base> [name]\n");
|
||||
std::printf(" Emit .wskl 12 classic professions (9 primary + 3 secondary) with canonical SkillLine IDs\n");
|
||||
std::printf(" --gen-skills-weapons <wskl-base> [name]\n");
|
||||
std::printf(" Emit .wskl all 16 weapon skills with rankPerLevel=5 auto-grow (use-trained, not trainer-trained)\n");
|
||||
std::printf(" --info-wskl <wskl-base> [--json]\n");
|
||||
std::printf(" Print WSKL entries (id / category / max rank / per-level grow / trainer-required / name)\n");
|
||||
std::printf(" --validate-wskl <wskl-base> [--json]\n");
|
||||
std::printf(" Static checks: skillId>0+unique, name not empty, maxRank>0, weapon needs rankPerLevel>0\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");
|
||||
|
|
|
|||
233
tools/editor/cli_skills_catalog.cpp
Normal file
233
tools/editor/cli_skills_catalog.cpp
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
#include "cli_skills_catalog.hpp"
|
||||
#include "cli_arg_parse.hpp"
|
||||
#include "cli_box_emitter.hpp"
|
||||
|
||||
#include "pipeline/wowee_skills.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 stripWsklExt(std::string base) {
|
||||
stripExt(base, ".wskl");
|
||||
return base;
|
||||
}
|
||||
|
||||
bool saveOrError(const wowee::pipeline::WoweeSkill& c,
|
||||
const std::string& base, const char* cmd) {
|
||||
if (!wowee::pipeline::WoweeSkillLoader::save(c, base)) {
|
||||
std::fprintf(stderr, "%s: failed to save %s.wskl\n",
|
||||
cmd, base.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void printGenSummary(const wowee::pipeline::WoweeSkill& c,
|
||||
const std::string& base) {
|
||||
std::printf("Wrote %s.wskl\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" skills : %zu\n", c.entries.size());
|
||||
}
|
||||
|
||||
int handleGenStarter(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "StarterSkills";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWsklExt(base);
|
||||
auto c = wowee::pipeline::WoweeSkillLoader::makeStarter(name);
|
||||
if (!saveOrError(c, base, "gen-skills")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenProfessions(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "ProfessionSkills";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWsklExt(base);
|
||||
auto c = wowee::pipeline::WoweeSkillLoader::makeProfessions(name);
|
||||
if (!saveOrError(c, base, "gen-skills-professions")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenWeapons(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "WeaponSkills";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWsklExt(base);
|
||||
auto c = wowee::pipeline::WoweeSkillLoader::makeWeapons(name);
|
||||
if (!saveOrError(c, base, "gen-skills-weapons")) 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 = stripWsklExt(base);
|
||||
if (!wowee::pipeline::WoweeSkillLoader::exists(base)) {
|
||||
std::fprintf(stderr, "WSKL not found: %s.wskl\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeSkillLoader::load(base);
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wskl"] = base + ".wskl";
|
||||
j["name"] = c.name;
|
||||
j["count"] = c.entries.size();
|
||||
nlohmann::json arr = nlohmann::json::array();
|
||||
for (const auto& e : c.entries) {
|
||||
arr.push_back({
|
||||
{"skillId", e.skillId},
|
||||
{"name", e.name},
|
||||
{"description", e.description},
|
||||
{"categoryId", e.categoryId},
|
||||
{"categoryName", wowee::pipeline::WoweeSkill::categoryName(e.categoryId)},
|
||||
{"canTrain", e.canTrain},
|
||||
{"maxRank", e.maxRank},
|
||||
{"rankPerLevel", e.rankPerLevel},
|
||||
{"iconPath", e.iconPath},
|
||||
});
|
||||
}
|
||||
j["entries"] = arr;
|
||||
std::printf("%s\n", j.dump(2).c_str());
|
||||
return 0;
|
||||
}
|
||||
std::printf("WSKL: %s.wskl\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" skills : %zu\n", c.entries.size());
|
||||
if (c.entries.empty()) return 0;
|
||||
std::printf(" id category max /lvl train name\n");
|
||||
for (const auto& e : c.entries) {
|
||||
std::printf(" %4u %-11s %3u %2u %s %s\n",
|
||||
e.skillId,
|
||||
wowee::pipeline::WoweeSkill::categoryName(e.categoryId),
|
||||
e.maxRank, e.rankPerLevel,
|
||||
e.canTrain ? "yes" : "no ",
|
||||
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 = stripWsklExt(base);
|
||||
if (!wowee::pipeline::WoweeSkillLoader::exists(base)) {
|
||||
std::fprintf(stderr,
|
||||
"validate-wskl: WSKL not found: %s.wskl\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeSkillLoader::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;
|
||||
idsSeen.reserve(c.entries.size());
|
||||
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.skillId);
|
||||
if (!e.name.empty()) ctx += " " + e.name;
|
||||
ctx += ")";
|
||||
if (e.skillId == 0) {
|
||||
errors.push_back(ctx + ": skillId is 0");
|
||||
}
|
||||
if (e.name.empty()) {
|
||||
errors.push_back(ctx + ": name is empty");
|
||||
}
|
||||
if (e.maxRank == 0) {
|
||||
errors.push_back(ctx + ": maxRank is 0");
|
||||
}
|
||||
if (e.categoryId > wowee::pipeline::WoweeSkill::WeaponSpec) {
|
||||
errors.push_back(ctx + ": categoryId " +
|
||||
std::to_string(e.categoryId) + " not in 0..7");
|
||||
}
|
||||
// Languages have maxRank=1 (you either know it or you don't);
|
||||
// anything else with maxRank=1 is suspicious.
|
||||
if (e.maxRank == 1 &&
|
||||
e.categoryId != wowee::pipeline::WoweeSkill::Language) {
|
||||
warnings.push_back(ctx +
|
||||
": maxRank=1 on non-Language skill (only languages cap at 1)");
|
||||
}
|
||||
// Weapon skills should auto-grow (rankPerLevel > 0).
|
||||
if (e.categoryId == wowee::pipeline::WoweeSkill::Weapon &&
|
||||
e.rankPerLevel == 0) {
|
||||
warnings.push_back(ctx +
|
||||
": weapon skill with rankPerLevel=0 (won't auto-grow on use)");
|
||||
}
|
||||
for (uint32_t prev : idsSeen) {
|
||||
if (prev == e.skillId) {
|
||||
errors.push_back(ctx + ": duplicate skillId");
|
||||
break;
|
||||
}
|
||||
}
|
||||
idsSeen.push_back(e.skillId);
|
||||
}
|
||||
bool ok = errors.empty();
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wskl"] = base + ".wskl";
|
||||
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-wskl: %s.wskl\n", base.c_str());
|
||||
if (ok && warnings.empty()) {
|
||||
std::printf(" OK — %zu skills, all skillIds 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 handleSkillsCatalog(int& i, int argc, char** argv, int& outRc) {
|
||||
if (std::strcmp(argv[i], "--gen-skills") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenStarter(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-skills-professions") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenProfessions(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-skills-weapons") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenWeapons(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--info-wskl") == 0 && i + 1 < argc) {
|
||||
outRc = handleInfo(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--validate-wskl") == 0 && i + 1 < argc) {
|
||||
outRc = handleValidate(i, argc, argv); return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace editor
|
||||
} // namespace wowee
|
||||
11
tools/editor/cli_skills_catalog.hpp
Normal file
11
tools/editor/cli_skills_catalog.hpp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
namespace cli {
|
||||
|
||||
bool handleSkillsCatalog(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