feat(editor): add WLMA (Loot Mode Policy) — 118th open format

Novel replacement for the implicit loot-distribution
rules vanilla WoW encoded across the GroupLoot system
(CMSG_LOOT_METHOD), the per-quality thresholds for
Need-roll triggering, and the master-looter permission
gates. Each entry binds one group-loot policy mode to
its kind (FFA / RoundRobin / MasterLoot / Need-Before-
Greed / Personal / Disenchant) plus quality threshold,
master-looter requirement, idle-skip seconds, and
disconnect-fallback policy.

Six modeKind values cover the full loot-distribution
surface. The thresholdQuality field uses the WIQR
quality tier convention (0=Poor through 7=Heirloom)
to gate Need-roll triggering — anything below threshold
auto-distributes via FFA-equivalent semantics.

The disconnect-fallback (timeoutFallbackKind) field is
unique to MasterLoot policies — if the master looter
disconnects mid-distribution, the policy auto-promotes
to the fallback mode for democratic recovery. Common
fallbacks: Need-Before-Greed (full roll system),
FreeForAll (fastest unblock).

Three preset emitters: makeStandard (4 5-man / casual
modes covering FFA farming, RoundRobin trash, NBG
Uncommon, MasterLoot Rare), makeRaidPolicies (3 raid
loot policies including MasterLoot Epic with NBG
fallback, Personal Loot, NBG Rare), makeAFKPrevention
(3 AFK-mitigating modes with idleSkipSec gates).

Validator's most novel check is per-kind consistency:
MasterLoot kind REQUIRES masterLooterRequired=1 (else
the policy contradicts itself — "Master Loot mode
without requiring a master looter"). Personal kind
warns if masterLooterRequired=1 (no-op flag). Tightened
fallback-to-self warning to fire ONLY for MasterLoot
where the field is meaningful — original version fired
falsely for FFA/Personal/RoundRobin where the leader-
disconnect scenario doesn't apply (caught + tightened
during smoke-test).

Format count 117 -> 118. CLI flag count 1248 -> 1253.
This commit is contained in:
Kelsi 2026-05-10 02:46:26 -07:00
parent e7755c77c9
commit 6fa81cf185
10 changed files with 729 additions and 0 deletions

View file

@ -706,6 +706,7 @@ set(WOWEE_SOURCES
src/pipeline/wowee_trade_rules.cpp
src/pipeline/wowee_word_filters.cpp
src/pipeline/wowee_raid_markers.cpp
src/pipeline/wowee_loot_modes.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/dbc_layout.cpp
@ -1575,6 +1576,7 @@ add_executable(wowee_editor
tools/editor/cli_trade_rules_catalog.cpp
tools/editor/cli_word_filters_catalog.cpp
tools/editor/cli_raid_markers_catalog.cpp
tools/editor/cli_loot_modes_catalog.cpp
tools/editor/cli_catalog_pluck.cpp
tools/editor/cli_catalog_find.cpp
tools/editor/cli_catalog_by_name.cpp
@ -1763,6 +1765,7 @@ add_executable(wowee_editor
src/pipeline/wowee_trade_rules.cpp
src/pipeline/wowee_word_filters.cpp
src/pipeline/wowee_raid_markers.cpp
src/pipeline/wowee_loot_modes.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/terrain_mesh.cpp

View file

@ -0,0 +1,133 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
namespace wowee {
namespace pipeline {
// Wowee Open Loot Mode Policy catalog (.wlma) — novel
// replacement for the implicit loot-distribution rules
// vanilla WoW encoded across the GroupLoot system
// (CMSG_LOOT_METHOD), the per-quality thresholds for
// Need-roll triggering, and the master-looter
// permission gates. Each entry binds one group-loot
// policy mode to its kind (FFA / RoundRobin / Master
// Loot / Need-Before-Greed / Personal / Disenchant)
// plus quality threshold and master-looter requirement.
//
// Cross-references with previously-added formats:
// WIQR: thresholdQuality references the WIQR item-
// quality tier catalog (0=Poor, 1=Common,
// 2=Uncommon, 3=Rare, 4=Epic, 5=Legendary,
// 6=Artifact, 7=Heirloom).
//
// Binary layout (little-endian):
// magic[4] = "WLMA"
// version (uint32) = current 1
// nameLen + name (catalog label)
// entryCount (uint32)
// entries (each):
// modeId (uint32)
// nameLen + name
// descLen + description
// modeKind (uint8) — FFA / RoundRobin /
// MasterLoot /
// NeedBeforeGreed /
// Personal /
// Disenchant
// thresholdQuality (uint8) — 0..7 quality tier;
// loot at or above
// triggers special-
// roll behavior
// masterLooterRequired (uint8) — 0/1 bool
// idleSkipSec (uint8) — 0..255 sec; 0 = no
// idle skip; round-
// robin advances if
// current pick is
// AFK > N seconds
// timeoutFallbackKind (uint8) — fallback mode if
// master looter
// disconnects
// mid-distribution
// pad0 / pad1 / pad2 (uint8)
// iconColorRGBA (uint32)
struct WoweeLootModes {
enum ModeKind : uint8_t {
FreeForAll = 0, // first-click wins
RoundRobin = 1, // rotating per-player
// assignment
MasterLoot = 2, // group leader
// distributes
NeedBeforeGreed = 3, // roll Need (gear) /
// Greed (vendor) /
// Pass per drop
Personal = 4, // each player gets
// their own roll
Disenchant = 5, // bundles with
// Need/Greed adding
// Disenchant button
// for enchanters
};
struct Entry {
uint32_t modeId = 0;
std::string name;
std::string description;
uint8_t modeKind = FreeForAll;
uint8_t thresholdQuality = 2; // Uncommon
// default
uint8_t masterLooterRequired = 0;
uint8_t idleSkipSec = 0;
uint8_t timeoutFallbackKind = FreeForAll;
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 modeId) const;
// Returns all modes of one kind. Used by the loot-
// policy UI to populate per-kind preset selectors
// (the Master Loot section, the Need-Before-Greed
// tier picker, etc.).
std::vector<const Entry*> findByKind(uint8_t modeKind) const;
};
class WoweeLootModesLoader {
public:
static bool save(const WoweeLootModes& cat,
const std::string& basePath);
static WoweeLootModes load(const std::string& basePath);
static bool exists(const std::string& basePath);
// Preset emitters used by --gen-lma* variants.
//
// makeStandard — 4 standard 5-man / casual
// modes (FreeForAll farming /
// RoundRobin trash / NeedBefore-
// Greed Uncommon / MasterLoot
// Rare).
// makeRaidPolicies — 3 raid loot policies
// (MasterLoot Epic threshold /
// Personal Loot / NeedBefore-
// Greed Rare default).
// makeAFKPrevention — 3 AFK-mitigating modes
// (RoundRobin idle-skip 30s /
// MasterLoot 60s timeout fall-
// back to NeedBeforeGreed /
// Personal idle-skip 45s).
static WoweeLootModes makeStandard(const std::string& catalogName);
static WoweeLootModes makeRaidPolicies(const std::string& catalogName);
static WoweeLootModes makeAFKPrevention(const std::string& catalogName);
};
} // namespace pipeline
} // namespace wowee

View file

@ -0,0 +1,264 @@
#include "pipeline/wowee_loot_modes.hpp"
#include <cstdio>
#include <cstring>
#include <fstream>
namespace wowee {
namespace pipeline {
namespace {
constexpr char kMagic[4] = {'W', 'L', 'M', '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) != ".wlma") {
base += ".wlma";
}
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 WoweeLootModes::Entry*
WoweeLootModes::findById(uint32_t modeId) const {
for (const auto& e : entries)
if (e.modeId == modeId) return &e;
return nullptr;
}
std::vector<const WoweeLootModes::Entry*>
WoweeLootModes::findByKind(uint8_t modeKind) const {
std::vector<const Entry*> out;
for (const auto& e : entries)
if (e.modeKind == modeKind) out.push_back(&e);
return out;
}
bool WoweeLootModesLoader::save(const WoweeLootModes& 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.modeId);
writeStr(os, e.name);
writeStr(os, e.description);
writePOD(os, e.modeKind);
writePOD(os, e.thresholdQuality);
writePOD(os, e.masterLooterRequired);
writePOD(os, e.idleSkipSec);
writePOD(os, e.timeoutFallbackKind);
writePOD(os, e.pad0);
writePOD(os, e.pad1);
writePOD(os, e.pad2);
writePOD(os, e.iconColorRGBA);
}
return os.good();
}
WoweeLootModes WoweeLootModesLoader::load(
const std::string& basePath) {
WoweeLootModes 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.modeId)) {
out.entries.clear(); return out;
}
if (!readStr(is, e.name) || !readStr(is, e.description)) {
out.entries.clear(); return out;
}
if (!readPOD(is, e.modeKind) ||
!readPOD(is, e.thresholdQuality) ||
!readPOD(is, e.masterLooterRequired) ||
!readPOD(is, e.idleSkipSec) ||
!readPOD(is, e.timeoutFallbackKind) ||
!readPOD(is, e.pad0) ||
!readPOD(is, e.pad1) ||
!readPOD(is, e.pad2) ||
!readPOD(is, e.iconColorRGBA)) {
out.entries.clear(); return out;
}
}
return out;
}
bool WoweeLootModesLoader::exists(const std::string& basePath) {
std::ifstream is(normalizePath(basePath), std::ios::binary);
return is.good();
}
WoweeLootModes WoweeLootModesLoader::makeStandard(
const std::string& catalogName) {
using L = WoweeLootModes;
WoweeLootModes c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name, uint8_t kind,
uint8_t threshold, uint8_t mlReq,
uint8_t idleSkip, const char* desc) {
L::Entry e;
e.modeId = id; e.name = name; e.description = desc;
e.modeKind = kind;
e.thresholdQuality = threshold;
e.masterLooterRequired = mlReq;
e.idleSkipSec = idleSkip;
e.timeoutFallbackKind = L::FreeForAll;
e.iconColorRGBA = packRgba(180, 220, 100); // standard green
c.entries.push_back(e);
};
add(1, "FFAFarming", L::FreeForAll, 0, 0, 0,
"Free-For-All — first-click wins. Common in "
"solo/duo farming runs where all loot is "
"destined for the AH.");
add(2, "RoundRobinTrash", L::RoundRobin, 0, 0, 0,
"Round-Robin — rotates through party slots, "
"assigns loot to the next player in sequence. "
"Standard 5-man trash policy.");
add(3, "NeedBeforeGreedUncommon",
L::NeedBeforeGreed, 2, 0, 0,
"Need-Before-Greed at Uncommon threshold — "
"anything Uncommon (green) or above triggers "
"the Need/Greed/Pass roll dialog. Standard "
"5-man heroic policy.");
add(4, "MasterLootRare", L::MasterLoot, 3, 1, 0,
"Master Loot at Rare threshold — anything "
"Rare (blue) or above goes to the master "
"looter for hand distribution. Master looter "
"REQUIRED.");
return c;
}
WoweeLootModes WoweeLootModesLoader::makeRaidPolicies(
const std::string& catalogName) {
using L = WoweeLootModes;
WoweeLootModes c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name, uint8_t kind,
uint8_t threshold, uint8_t mlReq,
uint8_t fallback, const char* desc) {
L::Entry e;
e.modeId = id; e.name = name; e.description = desc;
e.modeKind = kind;
e.thresholdQuality = threshold;
e.masterLooterRequired = mlReq;
e.idleSkipSec = 0;
e.timeoutFallbackKind = fallback;
e.iconColorRGBA = packRgba(220, 80, 100); // raid red
c.entries.push_back(e);
};
add(100, "MasterLootEpicRaid", L::MasterLoot, 4, 1,
L::NeedBeforeGreed,
"Master Loot at Epic threshold — standard 25-"
"man raid policy. Master looter REQUIRED. "
"Fallback to Need-Before-Greed if master looter "
"disconnects mid-distribution.");
add(101, "PersonalLootEpic", L::Personal, 4, 0,
L::Personal,
"Personal Loot at Epic threshold — each player "
"gets their own roll, no master-looter needed. "
"Anti-drama policy for pug raids.");
add(102, "NBGRareDefault", L::NeedBeforeGreed, 3, 0,
L::FreeForAll,
"Need-Before-Greed at Rare (Blue) threshold — "
"less restrictive than Epic gating. Common "
"10-man raid default.");
return c;
}
WoweeLootModes WoweeLootModesLoader::makeAFKPrevention(
const std::string& catalogName) {
using L = WoweeLootModes;
WoweeLootModes c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name, uint8_t kind,
uint8_t threshold, uint8_t mlReq,
uint8_t idleSkip, uint8_t fallback,
const char* desc) {
L::Entry e;
e.modeId = id; e.name = name; e.description = desc;
e.modeKind = kind;
e.thresholdQuality = threshold;
e.masterLooterRequired = mlReq;
e.idleSkipSec = idleSkip;
e.timeoutFallbackKind = fallback;
e.iconColorRGBA = packRgba(220, 200, 80); // AFK warning yellow
c.entries.push_back(e);
};
add(200, "RoundRobinIdleSkip30",
L::RoundRobin, 0, 0, 30, L::FreeForAll,
"Round-Robin with 30-second idle-skip — "
"advances rotation if current pick is AFK > "
"30s. Prevents stuck loot rotations in casual "
"groups.");
add(201, "MasterLootTimeout",
L::MasterLoot, 4, 1, 0, L::NeedBeforeGreed,
"Master Loot with timeout fallback — if master "
"looter is unresponsive for 60s, the loot mode "
"auto-promotes to Need-Before-Greed. Server "
"enforces the 60s window externally.");
add(202, "PersonalIdleSkip45",
L::Personal, 3, 0, 45, L::Personal,
"Personal Loot with 45-second idle-skip — "
"each player has 45s to pick up their personal "
"drop, then it bag-skips. Anti-AFK-leech "
"policy.");
return c;
}
} // namespace pipeline
} // namespace wowee

View file

@ -362,6 +362,8 @@ const char* const kArgRequired[] = {
"--gen-mar", "--gen-mar-world", "--gen-mar-party",
"--info-wmar", "--validate-wmar",
"--export-wmar-json", "--import-wmar-json",
"--gen-lma", "--gen-lma-raid", "--gen-lma-afk",
"--info-wlma", "--validate-wlma",
"--gen-weather-temperate", "--gen-weather-arctic",
"--gen-weather-desert", "--gen-weather-stormy",
"--gen-zone-atmosphere",

View file

@ -162,6 +162,7 @@
#include "cli_trade_rules_catalog.hpp"
#include "cli_word_filters_catalog.hpp"
#include "cli_raid_markers_catalog.hpp"
#include "cli_loot_modes_catalog.hpp"
#include "cli_catalog_pluck.hpp"
#include "cli_catalog_find.hpp"
#include "cli_catalog_by_name.hpp"
@ -369,6 +370,7 @@ constexpr DispatchFn kDispatchTable[] = {
handleTradeRulesCatalog,
handleWordFiltersCatalog,
handleRaidMarkersCatalog,
handleLootModesCatalog,
handleCatalogPluck,
handleCatalogFind,
handleCatalogByName,

View file

@ -120,6 +120,7 @@ constexpr FormatMagicEntry kFormats[] = {
{{'W','T','R','D'}, ".wtrd", "social", "--info-wtrd", "Trade window rules catalog"},
{{'W','W','F','L'}, ".wwfl", "social", "--info-wwfl", "Word filter catalog"},
{{'W','M','A','R'}, ".wmar", "ui", "--info-wmar", "Raid marker catalog"},
{{'W','L','M','A'}, ".wlma", "loot", "--info-wlma", "Loot mode policy 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

@ -2405,6 +2405,16 @@ void printUsage(const char* argv0) {
std::printf(" Export binary .wmar to a human-editable JSON sidecar (defaults to <base>.wmar.json; emits markerKind as both int AND name string; iconPath and displayChar as plain strings)\n");
std::printf(" --import-wmar-json <json-path> [out-base]\n");
std::printf(" Import a .wmar.json sidecar back into binary .wmar (markerKind int OR \"raidtarget\"/\"worldmap\"/\"party\"/\"custom\")\n");
std::printf(" --gen-lma <wlma-base> [name]\n");
std::printf(" Emit .wlma 4 standard loot modes (FFA farming / RoundRobin trash / NeedBeforeGreed Uncommon threshold / MasterLoot Rare threshold)\n");
std::printf(" --gen-lma-raid <wlma-base> [name]\n");
std::printf(" Emit .wlma 3 raid loot policies (MasterLoot Epic 25-man / Personal Loot Epic / NeedBeforeGreed Rare default)\n");
std::printf(" --gen-lma-afk <wlma-base> [name]\n");
std::printf(" Emit .wlma 3 AFK-mitigating modes (RoundRobin idle-skip 30s / MasterLoot 60s timeout fallback / Personal idle-skip 45s)\n");
std::printf(" --info-wlma <wlma-base> [--json]\n");
std::printf(" Print WLMA entries (id / kind / threshold quality / master-looter required / idle skip seconds / fallback kind / name)\n");
std::printf(" --validate-wlma <wlma-base> [--json]\n");
std::printf(" Static checks: id+name required, modeKind 0..5, thresholdQuality 0..7, no duplicate modeIds, MasterLoot kind REQUIRES masterLooterRequired=1 (else self-contradicting); warns on Personal kind with masterLooterRequired=1 (no-op flag), timeoutFallbackKind == modeKind (fallback to self is no-op)\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

@ -142,6 +142,7 @@ constexpr FormatRow kFormats[] = {
{"WTRD", ".wtrd", "social", "trade-window state machine policy", "Trade window rules catalog (P2P trade policy)"},
{"WWFL", ".wwfl", "social", "chat preprocessor bad-word matcher", "Word filter catalog (spam/RMT/all-caps/URL)"},
{"WMAR", ".wmar", "ui", "raid-target icon set (8 fixed)", "Raid marker catalog (8 raid + map pins + party roles)"},
{"WLMA", ".wlma", "loot", "GroupLoot CMSG_LOOT_METHOD policy", "Loot mode policy catalog (FFA / RR / Master / NBG / Personal)"},
// Additional pipeline catalogs without the alternating
// gen/info/validate CLI surface (loaded by the engine

View file

@ -0,0 +1,301 @@
#include "cli_loot_modes_catalog.hpp"
#include "cli_arg_parse.hpp"
#include "cli_box_emitter.hpp"
#include "pipeline/wowee_loot_modes.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 stripWlmaExt(std::string base) {
stripExt(base, ".wlma");
return base;
}
const char* modeKindName(uint8_t k) {
using L = wowee::pipeline::WoweeLootModes;
switch (k) {
case L::FreeForAll: return "freeforall";
case L::RoundRobin: return "roundrobin";
case L::MasterLoot: return "masterloot";
case L::NeedBeforeGreed: return "needbeforegreed";
case L::Personal: return "personal";
case L::Disenchant: return "disenchant";
default: return "unknown";
}
}
const char* qualityName(uint8_t q) {
switch (q) {
case 0: return "Poor";
case 1: return "Common";
case 2: return "Uncommon";
case 3: return "Rare";
case 4: return "Epic";
case 5: return "Legendary";
case 6: return "Artifact";
case 7: return "Heirloom";
default: return "?";
}
}
bool saveOrError(const wowee::pipeline::WoweeLootModes& c,
const std::string& base, const char* cmd) {
if (!wowee::pipeline::WoweeLootModesLoader::save(c, base)) {
std::fprintf(stderr, "%s: failed to save %s.wlma\n",
cmd, base.c_str());
return false;
}
return true;
}
void printGenSummary(const wowee::pipeline::WoweeLootModes& c,
const std::string& base) {
std::printf("Wrote %s.wlma\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" modes : %zu\n", c.entries.size());
}
int handleGenStandard(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "StandardLootModes";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWlmaExt(base);
auto c = wowee::pipeline::WoweeLootModesLoader::makeStandard(name);
if (!saveOrError(c, base, "gen-lma")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenRaid(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "RaidLootPolicies";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWlmaExt(base);
auto c = wowee::pipeline::WoweeLootModesLoader::makeRaidPolicies(name);
if (!saveOrError(c, base, "gen-lma-raid")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenAFK(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "AFKPreventionLootModes";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWlmaExt(base);
auto c = wowee::pipeline::WoweeLootModesLoader::makeAFKPrevention(name);
if (!saveOrError(c, base, "gen-lma-afk")) 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 = stripWlmaExt(base);
if (!wowee::pipeline::WoweeLootModesLoader::exists(base)) {
std::fprintf(stderr, "WLMA not found: %s.wlma\n", base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeLootModesLoader::load(base);
if (jsonOut) {
nlohmann::json j;
j["wlma"] = base + ".wlma";
j["name"] = c.name;
j["count"] = c.entries.size();
nlohmann::json arr = nlohmann::json::array();
for (const auto& e : c.entries) {
arr.push_back({
{"modeId", e.modeId},
{"name", e.name},
{"description", e.description},
{"modeKind", e.modeKind},
{"modeKindName", modeKindName(e.modeKind)},
{"thresholdQuality", e.thresholdQuality},
{"thresholdQualityName",
qualityName(e.thresholdQuality)},
{"masterLooterRequired",
e.masterLooterRequired != 0},
{"idleSkipSec", e.idleSkipSec},
{"timeoutFallbackKind", e.timeoutFallbackKind},
{"timeoutFallbackKindName",
modeKindName(e.timeoutFallbackKind)},
{"iconColorRGBA", e.iconColorRGBA},
});
}
j["entries"] = arr;
std::printf("%s\n", j.dump(2).c_str());
return 0;
}
std::printf("WLMA: %s.wlma\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" modes : %zu\n", c.entries.size());
if (c.entries.empty()) return 0;
std::printf(" id kind threshold ML idleSkip fallback name\n");
for (const auto& e : c.entries) {
std::printf(" %4u %-15s %-10s %s %3us %-15s %s\n",
e.modeId, modeKindName(e.modeKind),
qualityName(e.thresholdQuality),
e.masterLooterRequired ? "Y" : "n",
e.idleSkipSec,
modeKindName(e.timeoutFallbackKind),
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 = stripWlmaExt(base);
if (!wowee::pipeline::WoweeLootModesLoader::exists(base)) {
std::fprintf(stderr,
"validate-wlma: WLMA not found: %s.wlma\n",
base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeLootModesLoader::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;
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.modeId);
if (!e.name.empty()) ctx += " " + e.name;
ctx += ")";
if (e.modeId == 0)
errors.push_back(ctx + ": modeId is 0");
if (e.name.empty())
errors.push_back(ctx + ": name is empty");
if (e.modeKind > 5) {
errors.push_back(ctx + ": modeKind " +
std::to_string(e.modeKind) +
" out of range (must be 0..5)");
}
if (e.thresholdQuality > 7) {
errors.push_back(ctx + ": thresholdQuality " +
std::to_string(e.thresholdQuality) +
" out of range (must be 0..7 — Poor "
"through Heirloom)");
}
if (e.timeoutFallbackKind > 5) {
errors.push_back(ctx + ": timeoutFallbackKind " +
std::to_string(e.timeoutFallbackKind) +
" out of range (must be 0..5)");
}
// Per-kind validity: MasterLoot kind REQUIRES
// masterLooterRequired=1 (else the policy is
// self-contradicting — saying use Master Loot
// without requiring a master looter).
using L = wowee::pipeline::WoweeLootModes;
if (e.modeKind == L::MasterLoot &&
e.masterLooterRequired == 0) {
errors.push_back(ctx +
": MasterLoot kind with master"
"LooterRequired=0 — policy contradicts "
"itself (Master Loot mode without "
"requiring a master looter)");
}
// Personal kind doesn't use master-looter
// semantics — flag as warning if set.
if (e.modeKind == L::Personal &&
e.masterLooterRequired != 0) {
warnings.push_back(ctx +
": Personal kind with master"
"LooterRequired=1 — Personal Loot "
"doesn't use master-looter semantics; "
"the flag is meaningless");
}
// Fallback to self is meaningful only for kinds
// with a "leader" concept that can disconnect
// (MasterLoot). Other kinds (FFA, Personal,
// RoundRobin, NBG) have no leader-timeout
// scenario so the fallback field is unused —
// setting it to self is the conventional default
// and not a bug.
if (e.modeKind == L::MasterLoot &&
e.timeoutFallbackKind == e.modeKind) {
warnings.push_back(ctx +
": MasterLoot timeoutFallbackKind equals "
"modeKind — if the master looter "
"disconnects, the fallback would just "
"wait for them to reconnect (no policy "
"change). Common alternatives: Need"
"BeforeGreed for democratic recovery, "
"FreeForAll for fast unblocking.");
}
if (!idsSeen.insert(e.modeId).second) {
errors.push_back(ctx + ": duplicate modeId");
}
}
bool ok = errors.empty();
if (jsonOut) {
nlohmann::json j;
j["wlma"] = base + ".wlma";
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-wlma: %s.wlma\n", base.c_str());
if (ok && warnings.empty()) {
std::printf(" OK — %zu modes, all modeIds unique, "
"per-kind constraints satisfied\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 handleLootModesCatalog(int& i, int argc, char** argv,
int& outRc) {
if (std::strcmp(argv[i], "--gen-lma") == 0 && i + 1 < argc) {
outRc = handleGenStandard(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-lma-raid") == 0 && i + 1 < argc) {
outRc = handleGenRaid(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-lma-afk") == 0 && i + 1 < argc) {
outRc = handleGenAFK(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--info-wlma") == 0 && i + 1 < argc) {
outRc = handleInfo(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--validate-wlma") == 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 handleLootModesCatalog(int& i, int argc, char** argv,
int& outRc);
} // namespace cli
} // namespace editor
} // namespace wowee