feat(editor): add WSRG (Spell Range Index) open catalog format

Open replacement for Blizzard's SpellRange.dbc plus the per-spell
range-bucket fields in Spell.dbc. Defines the categorical range
buckets that spells reference instead of carrying their own min/max
yards (every Frostbolt shares one 30y bucket; every Heal shares
one 40y friendly bucket). Each entry carries separate min/max for
hostile vs friendly targets so heals can reach further on allies
than nukes do on enemies, plus an icon color for HUD range
indicators.

Three preset emitters: --gen-srg (3 baseline buckets:
Self/Melee/Spell), --gen-srg-ranged (5 ranged spell buckets:
Short/Medium/Long/VeryLong/Unlimited), --gen-srg-friendly (3
friendly-only buckets where hostile range is 0). --info-wsrg and
--validate-wsrg round out the per-format surface; validation
catches negative ranges, min>max, duplicate ids, out-of-range
rangeKind, and warns on Self+nonzero range or Melee>8y.

Wired through the cross-format table so WSRG appears automatically
in --list-formats, --info-magic, --diff-headers, --summary-dir,
--rename-by-magic, --catalog-grep, --tree-summary-md, and
--touch-tree. Format count 67 -> 68; CLI flag count 885 -> 890.
This commit is contained in:
Kelsi 2026-05-09 21:33:17 -07:00
parent 99a952299b
commit ede2d9918a
10 changed files with 620 additions and 0 deletions

View file

@ -656,6 +656,7 @@ set(WOWEE_SOURCES
src/pipeline/wowee_combat_ratings.cpp
src/pipeline/wowee_unit_movement.cpp
src/pipeline/wowee_quest_sorts.cpp
src/pipeline/wowee_spell_ranges.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/dbc_layout.cpp
@ -1467,6 +1468,7 @@ add_executable(wowee_editor
tools/editor/cli_combat_ratings_catalog.cpp
tools/editor/cli_unit_movement_catalog.cpp
tools/editor/cli_quest_sorts_catalog.cpp
tools/editor/cli_spell_ranges_catalog.cpp
tools/editor/cli_quest_objective.cpp
tools/editor/cli_quest_reward.cpp
tools/editor/cli_clone.cpp
@ -1601,6 +1603,7 @@ add_executable(wowee_editor
src/pipeline/wowee_combat_ratings.cpp
src/pipeline/wowee_unit_movement.cpp
src/pipeline/wowee_quest_sorts.cpp
src/pipeline/wowee_spell_ranges.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/terrain_mesh.cpp

View file

@ -0,0 +1,106 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
namespace wowee {
namespace pipeline {
// Wowee Open Spell Range Index catalog (.wsrg) — novel
// replacement for Blizzard's SpellRange.dbc plus the per-
// spell range-bucket fields in Spell.dbc. Defines the
// categorical range buckets that spells use ("Combat Range"
// 0-5y for melee, "Long Range" 0-40y for ranged casts,
// "Vision Range" 0-100y for area effects).
//
// Each spell references a rangeId here rather than carrying
// its own min/max yards. This lets the engine share range
// metadata across thousands of spells (every Frostbolt
// references the same 30y bucket) and lets the UI draw
// consistent range indicators (color-coded per-bucket).
//
// Friendly vs hostile range can differ — Heal might reach
// 40y on allies but Smite only 30y on enemies — so each
// entry carries separate min/max pairs for each affiliation.
//
// Cross-references with previously-added formats:
// None — this catalog is consumed directly by the spell
// engine and HUD. WSPL spell entries reference rangeId.
//
// Binary layout (little-endian):
// magic[4] = "WSRG"
// version (uint32) = current 1
// nameLen + name (catalog label)
// entryCount (uint32)
// entries (each):
// rangeId (uint32)
// nameLen + name
// descLen + description
// rangeKind (uint8) / pad[3]
// minRange (float)
// maxRange (float)
// minRangeFriendly (float)
// maxRangeFriendly (float)
// iconColorRGBA (uint32)
struct WoweeSpellRange {
enum RangeKind : uint8_t {
Self = 0, // 0-0 yards (caster only)
Melee = 1, // 0-5 yards (white attack range)
ShortRanged = 2, // 0-20 yards (close-quarters spell)
Ranged = 3, // 0-30 yards (standard cast)
LongRanged = 4, // 0-40 yards (rifle / long-cast spell)
VeryLong = 5, // 0-100 yards (vision / aura range)
Unlimited = 6, // any range (server-tracked global)
};
struct Entry {
uint32_t rangeId = 0;
std::string name;
std::string description;
uint8_t rangeKind = Ranged;
float minRange = 0.0f;
float maxRange = 30.0f;
float minRangeFriendly = 0.0f;
float maxRangeFriendly = 30.0f;
uint32_t iconColorRGBA = 0xFFFFFFFFu;
};
std::string name;
std::vector<Entry> entries;
bool isValid() const { return !entries.empty(); }
const Entry* findById(uint32_t rangeId) const;
static const char* rangeKindName(uint8_t k);
};
class WoweeSpellRangeLoader {
public:
static bool save(const WoweeSpellRange& cat,
const std::string& basePath);
static WoweeSpellRange load(const std::string& basePath);
static bool exists(const std::string& basePath);
// Preset emitters used by --gen-srg* variants.
//
// makeStarter — 3 baseline buckets (Self 0-0,
// Melee 0-5, Spell 0-30) covering
// the most common range categories.
// makeRanged — 5 ranged spell buckets (Short 0-20,
// Medium 0-30, Long 0-40, VeryLong
// 0-100, Unlimited) for varied
// ranged-class spell ranges.
// makeFriendly — 3 buckets where friendly-target
// range exceeds hostile-target range
// (Heal 40y friendly / 0 hostile,
// Cleanse 30y friendly / 0 hostile,
// Buff 30y friendly / 0 hostile).
static WoweeSpellRange makeStarter(const std::string& catalogName);
static WoweeSpellRange makeRanged(const std::string& catalogName);
static WoweeSpellRange makeFriendly(const std::string& catalogName);
};
} // namespace pipeline
} // namespace wowee

View file

@ -0,0 +1,234 @@
#include "pipeline/wowee_spell_ranges.hpp"
#include <cstdio>
#include <cstring>
#include <fstream>
namespace wowee {
namespace pipeline {
namespace {
constexpr char kMagic[4] = {'W', 'S', 'R', 'G'};
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) != ".wsrg") {
base += ".wsrg";
}
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 WoweeSpellRange::Entry*
WoweeSpellRange::findById(uint32_t rangeId) const {
for (const auto& e : entries)
if (e.rangeId == rangeId) return &e;
return nullptr;
}
const char* WoweeSpellRange::rangeKindName(uint8_t k) {
switch (k) {
case Self: return "self";
case Melee: return "melee";
case ShortRanged: return "short";
case Ranged: return "ranged";
case LongRanged: return "long";
case VeryLong: return "very-long";
case Unlimited: return "unlimited";
default: return "unknown";
}
}
bool WoweeSpellRangeLoader::save(const WoweeSpellRange& 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.rangeId);
writeStr(os, e.name);
writeStr(os, e.description);
writePOD(os, e.rangeKind);
uint8_t pad3[3] = {0, 0, 0};
os.write(reinterpret_cast<const char*>(pad3), 3);
writePOD(os, e.minRange);
writePOD(os, e.maxRange);
writePOD(os, e.minRangeFriendly);
writePOD(os, e.maxRangeFriendly);
writePOD(os, e.iconColorRGBA);
}
return os.good();
}
WoweeSpellRange WoweeSpellRangeLoader::load(const std::string& basePath) {
WoweeSpellRange 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.rangeId)) {
out.entries.clear(); return out;
}
if (!readStr(is, e.name) || !readStr(is, e.description)) {
out.entries.clear(); return out;
}
if (!readPOD(is, e.rangeKind)) {
out.entries.clear(); return out;
}
uint8_t pad3[3];
is.read(reinterpret_cast<char*>(pad3), 3);
if (is.gcount() != 3) { out.entries.clear(); return out; }
if (!readPOD(is, e.minRange) ||
!readPOD(is, e.maxRange) ||
!readPOD(is, e.minRangeFriendly) ||
!readPOD(is, e.maxRangeFriendly) ||
!readPOD(is, e.iconColorRGBA)) {
out.entries.clear(); return out;
}
}
return out;
}
bool WoweeSpellRangeLoader::exists(const std::string& basePath) {
std::ifstream is(normalizePath(basePath), std::ios::binary);
return is.good();
}
WoweeSpellRange WoweeSpellRangeLoader::makeStarter(
const std::string& catalogName) {
WoweeSpellRange c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name, uint8_t kind,
float minR, float maxR, uint8_t r, uint8_t g,
uint8_t b, const char* desc) {
WoweeSpellRange::Entry e;
e.rangeId = id; e.name = name; e.description = desc;
e.rangeKind = kind;
e.minRange = minR; e.maxRange = maxR;
// Default friendly == hostile.
e.minRangeFriendly = minR; e.maxRangeFriendly = maxR;
e.iconColorRGBA = packRgba(r, g, b);
c.entries.push_back(e);
};
add(1, "SelfRange", WoweeSpellRange::Self,
0.0f, 0.0f, 240, 240, 240,
"Self-only — caster is the only valid target.");
add(2, "MeleeRange", WoweeSpellRange::Melee,
0.0f, 5.0f, 220, 80, 80,
"Melee — within white-attack range (5y).");
add(3, "SpellRange", WoweeSpellRange::Ranged,
0.0f, 30.0f, 100, 180, 240,
"Standard spell — 30 yards, common caster range.");
return c;
}
WoweeSpellRange WoweeSpellRangeLoader::makeRanged(
const std::string& catalogName) {
WoweeSpellRange c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name, uint8_t kind,
float maxR, uint8_t r, uint8_t g, uint8_t b,
const char* desc) {
WoweeSpellRange::Entry e;
e.rangeId = id; e.name = name; e.description = desc;
e.rangeKind = kind;
e.maxRange = maxR;
e.maxRangeFriendly = maxR;
e.iconColorRGBA = packRgba(r, g, b);
c.entries.push_back(e);
};
add(100, "ShortCast", WoweeSpellRange::ShortRanged, 20.0f,
100, 200, 240, "Short-range spell — 20y. Close-up casts.");
add(101, "MediumCast", WoweeSpellRange::Ranged, 30.0f,
100, 180, 240, "Medium-range spell — 30y. Default caster range.");
add(102, "LongCast", WoweeSpellRange::LongRanged, 40.0f,
100, 160, 240, "Long-range spell — 40y. Hunter / sniper range.");
add(103, "VeryLong", WoweeSpellRange::VeryLong, 100.0f,
100, 140, 240, "Very-long range — 100y. Vision / aura range.");
add(104, "Unlimited", WoweeSpellRange::Unlimited, 99999.0f,
140, 100, 240, "Unlimited range — global server-tracked spell.");
return c;
}
WoweeSpellRange WoweeSpellRangeLoader::makeFriendly(
const std::string& catalogName) {
WoweeSpellRange c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name, float maxFriendly,
float maxHostile, const char* desc) {
WoweeSpellRange::Entry e;
e.rangeId = id; e.name = name; e.description = desc;
e.rangeKind = WoweeSpellRange::Ranged;
// Friendly range is the larger of the two.
e.maxRange = maxHostile;
e.maxRangeFriendly = maxFriendly;
e.iconColorRGBA = packRgba(80, 240, 100); // green for healing
c.entries.push_back(e);
};
add(200, "HealRange", 40.0f, 0.0f,
"Heal target — 40y friendly, 0y hostile (heals don't "
"reach enemies).");
add(201, "CleanseRange", 30.0f, 0.0f,
"Cleanse / dispel — 30y friendly only.");
add(202, "BuffRange", 30.0f, 0.0f,
"Beneficial buff — 30y friendly only (Power Word: "
"Fortitude, Mark of the Wild).");
return c;
}
} // namespace pipeline
} // namespace wowee

View file

@ -206,6 +206,8 @@ const char* const kArgRequired[] = {
"--gen-qso", "--gen-qso-class", "--gen-qso-profession",
"--info-wqso", "--validate-wqso",
"--export-wqso-json", "--import-wqso-json",
"--gen-srg", "--gen-srg-ranged", "--gen-srg-friendly",
"--info-wsrg", "--validate-wsrg",
"--gen-weather-temperate", "--gen-weather-arctic",
"--gen-weather-desert", "--gen-weather-stormy",
"--gen-zone-atmosphere",

View file

@ -104,6 +104,7 @@
#include "cli_combat_ratings_catalog.hpp"
#include "cli_unit_movement_catalog.hpp"
#include "cli_quest_sorts_catalog.hpp"
#include "cli_spell_ranges_catalog.hpp"
#include "cli_quest_objective.hpp"
#include "cli_quest_reward.hpp"
#include "cli_clone.hpp"
@ -249,6 +250,7 @@ constexpr DispatchFn kDispatchTable[] = {
handleCombatRatingsCatalog,
handleUnitMovementCatalog,
handleQuestSortsCatalog,
handleSpellRangesCatalog,
handleQuestObjective,
handleQuestReward,
handleClone,

View file

@ -70,6 +70,7 @@ constexpr FormatMagicEntry kFormats[] = {
{{'W','C','R','R'}, ".wcrr", "stats", "--info-wcrr", "Combat rating conversion catalog"},
{{'W','U','M','V'}, ".wumv", "stats", "--info-wumv", "Unit movement type catalog"},
{{'W','Q','S','O'}, ".wqso", "quests", "--info-wqso", "Quest sort / category catalog"},
{{'W','S','R','G'}, ".wsrg", "spells", "--info-wsrg", "Spell range bucket 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

@ -1687,6 +1687,16 @@ void printUsage(const char* argv0) {
std::printf(" Export binary .wqso to a human-editable JSON sidecar (defaults to <base>.wqso.json)\n");
std::printf(" --import-wqso-json <json-path> [out-base]\n");
std::printf(" Import a .wqso.json sidecar back into binary .wqso (accepts sortKind int OR name string)\n");
std::printf(" --gen-srg <wsrg-base> [name]\n");
std::printf(" Emit .wsrg starter: 3 baseline range buckets (Self 0-0 / Melee 0-5 / Spell 0-30)\n");
std::printf(" --gen-srg-ranged <wsrg-base> [name]\n");
std::printf(" Emit .wsrg 5 ranged spell buckets (Short 20y / Medium 30y / Long 40y / VeryLong 100y / Unlimited)\n");
std::printf(" --gen-srg-friendly <wsrg-base> [name]\n");
std::printf(" Emit .wsrg 3 friendly-only buckets (Heal 40y / Cleanse 30y / Buff 30y) where hostile range = 0\n");
std::printf(" --info-wsrg <wsrg-base> [--json]\n");
std::printf(" Print WSRG entries (id / kind / hostile + friendly min-max yards / icon color / name)\n");
std::printf(" --validate-wsrg <wsrg-base> [--json]\n");
std::printf(" Static checks: id+name required, rangeKind 0..6, min<=max, no negatives, no duplicate ids; warns on Self+nonzero range and Melee>8y\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");

View file

@ -92,6 +92,7 @@ constexpr FormatRow kFormats[] = {
{"WCRR", ".wcrr", "stats", "gtCombatRatings.dbc + curves", "Combat rating conversion catalog"},
{"WUMV", ".wumv", "stats", "UnitMovement.dbc + speed mods", "Unit movement type / speed catalog"},
{"WQSO", ".wqso", "quests", "QuestSort.dbc + QuestInfo cats", "Quest sort / category catalog"},
{"WSRG", ".wsrg", "spells", "SpellRange.dbc + per-spell range", "Spell range bucket catalog"},
// Additional pipeline catalogs without the alternating
// gen/info/validate CLI surface (loaded by the engine

View file

@ -0,0 +1,249 @@
#include "cli_spell_ranges_catalog.hpp"
#include "cli_arg_parse.hpp"
#include "cli_box_emitter.hpp"
#include "pipeline/wowee_spell_ranges.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 stripWsrgExt(std::string base) {
stripExt(base, ".wsrg");
return base;
}
bool saveOrError(const wowee::pipeline::WoweeSpellRange& c,
const std::string& base, const char* cmd) {
if (!wowee::pipeline::WoweeSpellRangeLoader::save(c, base)) {
std::fprintf(stderr, "%s: failed to save %s.wsrg\n",
cmd, base.c_str());
return false;
}
return true;
}
void printGenSummary(const wowee::pipeline::WoweeSpellRange& c,
const std::string& base) {
std::printf("Wrote %s.wsrg\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" ranges : %zu\n", c.entries.size());
}
int handleGenStarter(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "StarterRanges";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWsrgExt(base);
auto c = wowee::pipeline::WoweeSpellRangeLoader::makeStarter(name);
if (!saveOrError(c, base, "gen-srg")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenRanged(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "RangedSpellBuckets";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWsrgExt(base);
auto c = wowee::pipeline::WoweeSpellRangeLoader::makeRanged(name);
if (!saveOrError(c, base, "gen-srg-ranged")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenFriendly(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "FriendlyOnlyRanges";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWsrgExt(base);
auto c = wowee::pipeline::WoweeSpellRangeLoader::makeFriendly(name);
if (!saveOrError(c, base, "gen-srg-friendly")) 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 = stripWsrgExt(base);
if (!wowee::pipeline::WoweeSpellRangeLoader::exists(base)) {
std::fprintf(stderr, "WSRG not found: %s.wsrg\n", base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeSpellRangeLoader::load(base);
if (jsonOut) {
nlohmann::json j;
j["wsrg"] = base + ".wsrg";
j["name"] = c.name;
j["count"] = c.entries.size();
nlohmann::json arr = nlohmann::json::array();
for (const auto& e : c.entries) {
arr.push_back({
{"rangeId", e.rangeId},
{"name", e.name},
{"description", e.description},
{"rangeKind", e.rangeKind},
{"rangeKindName", wowee::pipeline::WoweeSpellRange::rangeKindName(e.rangeKind)},
{"minRange", e.minRange},
{"maxRange", e.maxRange},
{"minRangeFriendly", e.minRangeFriendly},
{"maxRangeFriendly", e.maxRangeFriendly},
{"iconColorRGBA", e.iconColorRGBA},
});
}
j["entries"] = arr;
std::printf("%s\n", j.dump(2).c_str());
return 0;
}
std::printf("WSRG: %s.wsrg\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" ranges : %zu\n", c.entries.size());
if (c.entries.empty()) return 0;
std::printf(" id kind min-max(hostile) min-max(friendly) color name\n");
for (const auto& e : c.entries) {
std::printf(" %4u %-9s %5.1f - %6.1f %5.1f - %6.1f 0x%08x %s\n",
e.rangeId,
wowee::pipeline::WoweeSpellRange::rangeKindName(e.rangeKind),
e.minRange, e.maxRange,
e.minRangeFriendly, e.maxRangeFriendly,
e.iconColorRGBA, 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 = stripWsrgExt(base);
if (!wowee::pipeline::WoweeSpellRangeLoader::exists(base)) {
std::fprintf(stderr,
"validate-wsrg: WSRG not found: %s.wsrg\n", base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeSpellRangeLoader::load(base);
std::vector<std::string> errors;
std::vector<std::string> warnings;
if (c.entries.empty()) {
warnings.push_back("catalog has zero entries");
}
std::vector<uint32_t> idsSeen;
for (size_t k = 0; k < c.entries.size(); ++k) {
const auto& e = c.entries[k];
std::string ctx = "entry " + std::to_string(k) +
" (id=" + std::to_string(e.rangeId);
if (!e.name.empty()) ctx += " " + e.name;
ctx += ")";
if (e.rangeId == 0)
errors.push_back(ctx + ": rangeId is 0");
if (e.name.empty())
errors.push_back(ctx + ": name is empty");
if (e.rangeKind > wowee::pipeline::WoweeSpellRange::Unlimited) {
errors.push_back(ctx + ": rangeKind " +
std::to_string(e.rangeKind) + " not in 0..6");
}
if (e.minRange < 0.0f || e.maxRange < 0.0f ||
e.minRangeFriendly < 0.0f ||
e.maxRangeFriendly < 0.0f) {
errors.push_back(ctx +
": negative range value (ranges must be >= 0)");
}
if (e.minRange > e.maxRange) {
errors.push_back(ctx + ": minRange " +
std::to_string(e.minRange) +
" > maxRange " + std::to_string(e.maxRange));
}
if (e.minRangeFriendly > e.maxRangeFriendly) {
errors.push_back(ctx + ": minRangeFriendly " +
std::to_string(e.minRangeFriendly) +
" > maxRangeFriendly " +
std::to_string(e.maxRangeFriendly));
}
// Self-kind should have max range = 0; otherwise the
// engine would treat it as targeted.
if (e.rangeKind == wowee::pipeline::WoweeSpellRange::Self &&
(e.maxRange != 0.0f || e.maxRangeFriendly != 0.0f)) {
warnings.push_back(ctx +
": Self kind with non-zero maxRange — engine "
"treats this as targeted, not self-only");
}
// Melee-kind should be 0..5y by canonical convention.
if (e.rangeKind == wowee::pipeline::WoweeSpellRange::Melee &&
e.maxRange > 8.0f) {
warnings.push_back(ctx +
": Melee kind with maxRange " +
std::to_string(e.maxRange) +
" > 8 (canonical melee is 5y)");
}
for (uint32_t prev : idsSeen) {
if (prev == e.rangeId) {
errors.push_back(ctx + ": duplicate rangeId");
break;
}
}
idsSeen.push_back(e.rangeId);
}
bool ok = errors.empty();
if (jsonOut) {
nlohmann::json j;
j["wsrg"] = base + ".wsrg";
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-wsrg: %s.wsrg\n", base.c_str());
if (ok && warnings.empty()) {
std::printf(" OK — %zu ranges, all rangeIds unique, all min<=max\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 handleSpellRangesCatalog(int& i, int argc, char** argv,
int& outRc) {
if (std::strcmp(argv[i], "--gen-srg") == 0 && i + 1 < argc) {
outRc = handleGenStarter(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-srg-ranged") == 0 && i + 1 < argc) {
outRc = handleGenRanged(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-srg-friendly") == 0 && i + 1 < argc) {
outRc = handleGenFriendly(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--info-wsrg") == 0 && i + 1 < argc) {
outRc = handleInfo(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--validate-wsrg") == 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 handleSpellRangesCatalog(int& i, int argc, char** argv,
int& outRc);
} // namespace cli
} // namespace editor
} // namespace wowee