feat(editor): add WCFG (Server Config) — 120th open format

Novel replacement for the worldserver.conf / mangosd.conf
flat-text configuration files vanilla server forks
shipped. Each entry binds one configId to its
polymorphic value via the valueKind enum (Float / Int /
Bool / String) — only the matching value field is
authoritative per entry.

The polymorphic value is the novel data shape: each
entry stores ALL three value carriers on disk
(floatValue float / intValue int64 / strValue string),
and valueKind picks which is meaningful at runtime. Bool
folds into intValue with strict 0/1 semantics. JSON
export reflects this: an activeValue derived field
renders the right form per kind so operators editing
JSON see only the relevant value.

Nine configKind values cover the full server-tunable
surface: XPRate / DropRate / HonorRate / RestedXP /
RealmType / WorldFlag / Performance / Security / Misc.
Each kind groups settings the server iterates by kind
at startup (all XPRate entries seed the per-class
experience matrix; all Security entries configure the
anti-cheat thresholds).

Three preset emitters: makeRates (4 vanilla baseline
rate multipliers with valueKind=Float), makePerformance
(4 server tuning configs mixing Int and Float kinds —
max creatures per cell, view distance yards, GC
interval seconds, etc.), makeSecurity (4 anti-cheat
configs FIRST format using valueKind=String for the
cheat-detection sensitivity preset name).

Validator's most novel checks are per-valueKind cross-
field consistency: Bool requires intValue strictly 0/1
(error), and warns on cross-field bleed (Float kind
with non-zero intValue means the int is silently
ignored at runtime but persists on disk). Plus name
uniqueness — server name-based config lookups would
be ambiguous otherwise.

Format count 119 -> 120 (multiple-of-10 milestone).
CLI flag count 1262 -> 1267.
This commit is contained in:
Kelsi 2026-05-10 02:57:26 -07:00
parent 9a734acb87
commit 441ca0d139
10 changed files with 761 additions and 0 deletions

View file

@ -708,6 +708,7 @@ set(WOWEE_SOURCES
src/pipeline/wowee_raid_markers.cpp
src/pipeline/wowee_loot_modes.cpp
src/pipeline/wowee_sky_params.cpp
src/pipeline/wowee_server_config.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/dbc_layout.cpp
@ -1579,6 +1580,7 @@ add_executable(wowee_editor
tools/editor/cli_raid_markers_catalog.cpp
tools/editor/cli_loot_modes_catalog.cpp
tools/editor/cli_sky_params_catalog.cpp
tools/editor/cli_server_config_catalog.cpp
tools/editor/cli_catalog_pluck.cpp
tools/editor/cli_catalog_find.cpp
tools/editor/cli_catalog_by_name.cpp
@ -1769,6 +1771,7 @@ add_executable(wowee_editor
src/pipeline/wowee_raid_markers.cpp
src/pipeline/wowee_loot_modes.cpp
src/pipeline/wowee_sky_params.cpp
src/pipeline/wowee_server_config.cpp
src/pipeline/custom_zone_discovery.cpp
src/pipeline/terrain_mesh.cpp

View file

@ -0,0 +1,139 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
namespace wowee {
namespace pipeline {
// Wowee Open Server Config catalog (.wcfg) — novel
// replacement for the worldserver.conf / mangosd.conf
// flat-text configuration files vanilla server forks
// shipped. Each entry binds one configId to its
// polymorphic value via the valueKind enum
// (Float / Int / Bool / String) — only the matching
// value field is meaningful per entry.
//
// Polymorphic value is the novel data shape: each
// entry stores ALL four possible value fields
// (floatValue / intValue / strValue presence + boolean
// folded into intValue's low bit), and the valueKind
// enum picks which is authoritative. JSON export
// reflects this: the active field is rendered with
// its kind label so operators can edit the right one.
//
// Cross-references with previously-added formats:
// No catalog cross-references — WCFG is a TOP-LEVEL
// bootstrap catalog read at world startup, before
// any in-world data is loaded.
//
// Binary layout (little-endian):
// magic[4] = "WCFG"
// version (uint32) = current 1
// nameLen + name (catalog label)
// entryCount (uint32)
// entries (each):
// configId (uint32)
// nameLen + name
// descLen + description
// configKind (uint8) — XPRate / DropRate /
// HonorRate / RestedXP
// / RealmType / World-
// Flag / Performance /
// Security / Misc
// valueKind (uint8) — Float / Int / Bool /
// String
// restartRequired (uint8) — 0/1 bool
// pad0 (uint8)
// floatValue (float) — meaningful if
// valueKind == Float
// intValue (int64) — meaningful if
// valueKind == Int
// (or Bool: 0/1)
// strLen + strValue — meaningful if
// valueKind == String
// iconColorRGBA (uint32)
struct WoweeServerConfig {
enum ConfigKind : uint8_t {
XPRate = 0,
DropRate = 1,
HonorRate = 2,
RestedXP = 3,
RealmType = 4, // Normal / PvP / RP /
// RP-PvP — see WMSP
WorldFlag = 5, // bool world-state flags
// (DoubleXPWeekend, etc.)
Performance = 6, // server tuning (cell-grid
// sizes, etc.)
Security = 7, // anti-cheat thresholds
Misc = 255,
};
enum ValueKind : uint8_t {
Float = 0,
Int = 1,
Bool = 2, // serialized as int 0/1
String = 3,
};
struct Entry {
uint32_t configId = 0;
std::string name;
std::string description;
uint8_t configKind = Misc;
uint8_t valueKind = Float;
uint8_t restartRequired = 0;
uint8_t pad0 = 0;
float floatValue = 0.0f;
int64_t intValue = 0;
std::string strValue;
uint32_t iconColorRGBA = 0xFFFFFFFFu;
};
std::string name;
std::vector<Entry> entries;
bool isValid() const { return !entries.empty(); }
const Entry* findById(uint32_t configId) const;
// Returns all entries of one configKind. Used by
// server startup code to iterate the matching
// tunables: pull all XPRate entries to seed the
// experience-rate matrix per character class, etc.
std::vector<const Entry*> findByKind(uint8_t configKind) const;
};
class WoweeServerConfigLoader {
public:
static bool save(const WoweeServerConfig& cat,
const std::string& basePath);
static WoweeServerConfig load(const std::string& basePath);
static bool exists(const std::string& basePath);
// Preset emitters used by --gen-cfg* variants.
//
// makeRates — 4 rate-multiplier configs
// (XPRate 1.0x / DropRate 1.0x /
// HonorRate 1.0x / RestedXP
// 200%) — vanilla baseline.
// makePerformance — 4 server tuning configs
// (max creatures per cell 100 /
// view distance 533 yards /
// spawn-rate 1.0x / GC interval
// 300s) — Performance kind.
// makeSecurity — 4 anti-cheat configs
// (speedhack tolerance 1.05x /
// trade gold cap 100000g /
// GM command audit logging
// enabled / cheat-detection
// sensitivity "high" — String
// value).
static WoweeServerConfig makeRates(const std::string& catalogName);
static WoweeServerConfig makePerformance(const std::string& catalogName);
static WoweeServerConfig makeSecurity(const std::string& catalogName);
};
} // namespace pipeline
} // namespace wowee

View file

@ -0,0 +1,272 @@
#include "pipeline/wowee_server_config.hpp"
#include <cstdio>
#include <cstring>
#include <fstream>
namespace wowee {
namespace pipeline {
namespace {
constexpr char kMagic[4] = {'W', 'C', 'F', '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) != ".wcfg") {
base += ".wcfg";
}
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 WoweeServerConfig::Entry*
WoweeServerConfig::findById(uint32_t configId) const {
for (const auto& e : entries)
if (e.configId == configId) return &e;
return nullptr;
}
std::vector<const WoweeServerConfig::Entry*>
WoweeServerConfig::findByKind(uint8_t configKind) const {
std::vector<const Entry*> out;
for (const auto& e : entries)
if (e.configKind == configKind) out.push_back(&e);
return out;
}
bool WoweeServerConfigLoader::save(const WoweeServerConfig& 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.configId);
writeStr(os, e.name);
writeStr(os, e.description);
writePOD(os, e.configKind);
writePOD(os, e.valueKind);
writePOD(os, e.restartRequired);
writePOD(os, e.pad0);
writePOD(os, e.floatValue);
writePOD(os, e.intValue);
writeStr(os, e.strValue);
writePOD(os, e.iconColorRGBA);
}
return os.good();
}
WoweeServerConfig WoweeServerConfigLoader::load(
const std::string& basePath) {
WoweeServerConfig 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.configId)) {
out.entries.clear(); return out;
}
if (!readStr(is, e.name) || !readStr(is, e.description)) {
out.entries.clear(); return out;
}
if (!readPOD(is, e.configKind) ||
!readPOD(is, e.valueKind) ||
!readPOD(is, e.restartRequired) ||
!readPOD(is, e.pad0) ||
!readPOD(is, e.floatValue) ||
!readPOD(is, e.intValue)) {
out.entries.clear(); return out;
}
if (!readStr(is, e.strValue)) {
out.entries.clear(); return out;
}
if (!readPOD(is, e.iconColorRGBA)) {
out.entries.clear(); return out;
}
}
return out;
}
bool WoweeServerConfigLoader::exists(const std::string& basePath) {
std::ifstream is(normalizePath(basePath), std::ios::binary);
return is.good();
}
WoweeServerConfig WoweeServerConfigLoader::makeRates(
const std::string& catalogName) {
using C = WoweeServerConfig;
WoweeServerConfig c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name, uint8_t kind,
float floatVal, const char* desc) {
C::Entry e;
e.configId = id; e.name = name; e.description = desc;
e.configKind = kind;
e.valueKind = C::Float;
e.floatValue = floatVal;
e.iconColorRGBA = packRgba(220, 220, 100); // rate gold
c.entries.push_back(e);
};
add(1, "XPRateGlobal", C::XPRate, 1.0f,
"Global experience-rate multiplier — 1.0 = "
"Blizzard-default rate. Custom-server values "
"commonly 2.0 (double-XP), 5.0 (low-population "
"boost), 10.0 (instant-leveling testing).");
add(2, "DropRateGlobal", C::DropRate, 1.0f,
"Global loot-drop multiplier — 1.0 = Blizzard "
"default. Increase to compensate for low-pop "
"raid-team availability.");
add(3, "HonorRateGlobal", C::HonorRate, 1.0f,
"PvP honor-gain multiplier — 1.0 = default. "
"Custom-server boost to accelerate PvP rank "
"progression.");
add(4, "RestedRate200Pct", C::RestedXP, 2.0f,
"Rested-XP multiplier — 2.0 = double-XP while "
"in rested state (Blizzard default). Custom "
"values up to 5.0 for casual-friendly servers.");
return c;
}
WoweeServerConfig WoweeServerConfigLoader::makePerformance(
const std::string& catalogName) {
using C = WoweeServerConfig;
WoweeServerConfig c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name,
uint8_t valueKind, float floatVal,
int64_t intVal, uint8_t restart,
const char* desc) {
C::Entry e;
e.configId = id; e.name = name; e.description = desc;
e.configKind = C::Performance;
e.valueKind = valueKind;
e.floatValue = floatVal;
e.intValue = intVal;
e.restartRequired = restart;
e.iconColorRGBA = packRgba(140, 200, 255); // perf blue
c.entries.push_back(e);
};
add(100, "MaxCreaturesPerCell", C::Int, 0.0f, 100, 1,
"Maximum creatures spawned per 533x533yd cell. "
"Higher = denser zones but more memory + more "
"AI updates per server tick. 100 is the canonical "
"Wrath-era default. Restart REQUIRED.");
add(101, "DefaultViewDistance", C::Float, 533.0f, 0, 0,
"Default client view distance in yards. 533 = "
"1 cell width — clients can see one cell beyond "
"their own. Higher values stress server; lower "
"values reduce load but reduce immersion.");
add(102, "SpawnRateMultiplier", C::Float, 1.0f, 0, 0,
"Creature spawn-rate multiplier. 1.0 = "
"Blizzard default. 2.0 doubles all respawn "
"rates — useful for low-pop farming zones.");
add(103, "GCIntervalSec", C::Int, 0.0f, 300, 1,
"Server-side garbage collection interval in "
"seconds. 300 (5min) is standard. Lower = more "
"frequent GC pauses but lower memory peaks. "
"Restart REQUIRED to apply.");
return c;
}
WoweeServerConfig WoweeServerConfigLoader::makeSecurity(
const std::string& catalogName) {
using C = WoweeServerConfig;
WoweeServerConfig c;
c.name = catalogName;
auto add = [&](uint32_t id, const char* name,
uint8_t valueKind, float floatVal,
int64_t intVal, const char* strVal,
uint8_t restart, const char* desc) {
C::Entry e;
e.configId = id; e.name = name; e.description = desc;
e.configKind = C::Security;
e.valueKind = valueKind;
e.floatValue = floatVal;
e.intValue = intVal;
e.strValue = strVal;
e.restartRequired = restart;
e.iconColorRGBA = packRgba(220, 60, 60); // security red
c.entries.push_back(e);
};
add(200, "SpeedhackTolerance", C::Float, 1.05f, 0, "", 0,
"Speed-hack tolerance multiplier. Server "
"rejects movements > (max_legitimate_speed * "
"this). 1.05 = 5%% leeway for network jitter. "
"Lower = tighter detection (more false positives); "
"higher = looser (more false negatives).");
add(201, "TradeGoldCapCopper", C::Int, 0.0f, 1000000000, "", 0,
"Trade-window gold cap in copper. 1000000000 "
"(100,000g) is the Wrath default. Values > 4 "
"billion don't fit in uint32, so the field is "
"int64 to be safe.");
add(202, "GMAuditLogEnabled", C::Bool, 0.0f, 1, "", 1,
"Enable GM-command audit logging. When true "
"(int=1), every GM command is logged to the "
"audit table for moderation review. Restart "
"REQUIRED.");
add(203, "CheatDetectionSensitivity", C::String, 0.0f, 0,
"high", 0,
"Cheat-detection sensitivity preset name — "
"valid: \"low\" / \"medium\" / \"high\" / "
"\"paranoid\". This is a STRING value (the "
"first format using valueKind=String) since "
"the underlying detection logic is named-preset "
"based, not numeric.");
return c;
}
} // namespace pipeline
} // namespace wowee

View file

@ -368,6 +368,8 @@ const char* const kArgRequired[] = {
"--gen-skp", "--gen-skp-arctic", "--gen-skp-hellfire",
"--info-wskp", "--validate-wskp",
"--export-wskp-json", "--import-wskp-json",
"--gen-cfg", "--gen-cfg-perf", "--gen-cfg-sec",
"--info-wcfg", "--validate-wcfg",
"--gen-weather-temperate", "--gen-weather-arctic",
"--gen-weather-desert", "--gen-weather-stormy",
"--gen-zone-atmosphere",

View file

@ -164,6 +164,7 @@
#include "cli_raid_markers_catalog.hpp"
#include "cli_loot_modes_catalog.hpp"
#include "cli_sky_params_catalog.hpp"
#include "cli_server_config_catalog.hpp"
#include "cli_catalog_pluck.hpp"
#include "cli_catalog_find.hpp"
#include "cli_catalog_by_name.hpp"
@ -373,6 +374,7 @@ constexpr DispatchFn kDispatchTable[] = {
handleRaidMarkersCatalog,
handleLootModesCatalog,
handleSkyParamsCatalog,
handleServerConfigCatalog,
handleCatalogPluck,
handleCatalogFind,
handleCatalogByName,

View file

@ -122,6 +122,7 @@ constexpr FormatMagicEntry kFormats[] = {
{{'W','M','A','R'}, ".wmar", "ui", "--info-wmar", "Raid marker catalog"},
{{'W','L','M','A'}, ".wlma", "loot", "--info-wlma", "Loot mode policy catalog"},
{{'W','S','K','P'}, ".wskp", "world", "--info-wskp", "Sky parameters catalog"},
{{'W','C','F','G'}, ".wcfg", "server", "--info-wcfg", "Server config 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

@ -2433,6 +2433,16 @@ void printUsage(const char* argv0) {
std::printf(" Export binary .wskp to a human-editable JSON sidecar (defaults to <base>.wskp.json; emits cloudSpeedX10 as both raw int AND derived cloudSpeedMph float convenience field)\n");
std::printf(" --import-wskp-json <json-path> [out-base]\n");
std::printf(" Import a .wskp.json sidecar back into binary .wskp (no enum coercion — all-numeric payload; cloudSpeedX10 raw int OR cloudSpeedMph float — converts mph * 10 -> raw with rounding and clamp to 0..255)\n");
std::printf(" --gen-cfg <wcfg-base> [name]\n");
std::printf(" Emit .wcfg 4 rate-multiplier configs (XPRate 1.0x / DropRate 1.0x / HonorRate 1.0x / RestedRate 200%%) — vanilla baselines\n");
std::printf(" --gen-cfg-perf <wcfg-base> [name]\n");
std::printf(" Emit .wcfg 4 server tuning configs (max creatures per cell 100 / view distance 533 yards / spawn rate 1.0x / GC interval 300s)\n");
std::printf(" --gen-cfg-sec <wcfg-base> [name]\n");
std::printf(" Emit .wcfg 4 anti-cheat configs (speedhack tolerance 1.05x / trade gold cap 100,000g / GM audit logging enabled / cheat-detection \"high\" preset — first format using valueKind=String)\n");
std::printf(" --info-wcfg <wcfg-base> [--json]\n");
std::printf(" Print WCFG entries (id / configKind / valueKind / restart-required / active value rendered per kind / name)\n");
std::printf(" --validate-wcfg <wcfg-base> [--json]\n");
std::printf(" Static checks: id+name required, configKind 0..7 OR 255 Misc, valueKind 0..3, no duplicate configIds OR config names (server name-based lookups would be ambiguous), Bool valueKind requires intValue 0/1; warns on cross-field bleed (Float kind with non-zero intValue, etc.)\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

@ -144,6 +144,7 @@ constexpr FormatRow kFormats[] = {
{"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)"},
{"WSKP", ".wskp", "world", "LightParams.dbc + Light.dbc diurnal","Sky parameters catalog (per-zone keyframes)"},
{"WCFG", ".wcfg", "server", "worldserver.conf flat-text config", "Server config catalog (polymorphic Float/Int/Bool/String values)"},
// Additional pipeline catalogs without the alternating
// gen/info/validate CLI surface (loaded by the engine

View file

@ -0,0 +1,319 @@
#include "cli_server_config_catalog.hpp"
#include "cli_arg_parse.hpp"
#include "cli_box_emitter.hpp"
#include "pipeline/wowee_server_config.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 stripWcfgExt(std::string base) {
stripExt(base, ".wcfg");
return base;
}
const char* configKindName(uint8_t k) {
using C = wowee::pipeline::WoweeServerConfig;
switch (k) {
case C::XPRate: return "xprate";
case C::DropRate: return "droprate";
case C::HonorRate: return "honorrate";
case C::RestedXP: return "restedxp";
case C::RealmType: return "realmtype";
case C::WorldFlag: return "worldflag";
case C::Performance: return "performance";
case C::Security: return "security";
case C::Misc: return "misc";
default: return "unknown";
}
}
const char* valueKindName(uint8_t k) {
using C = wowee::pipeline::WoweeServerConfig;
switch (k) {
case C::Float: return "float";
case C::Int: return "int";
case C::Bool: return "bool";
case C::String: return "string";
default: return "unknown";
}
}
// Render the active value field (per valueKind) as a
// terse human-readable string. Used by the info display
// to show only the meaningful field per entry.
std::string activeValueString(
const wowee::pipeline::WoweeServerConfig::Entry& e) {
using C = wowee::pipeline::WoweeServerConfig;
char buf[64];
switch (e.valueKind) {
case C::Float:
std::snprintf(buf, sizeof(buf), "%.4f",
e.floatValue);
return buf;
case C::Int:
std::snprintf(buf, sizeof(buf), "%lld",
static_cast<long long>(e.intValue));
return buf;
case C::Bool:
return e.intValue != 0 ? "true" : "false";
case C::String:
return "\"" + e.strValue + "\"";
default:
return "?";
}
}
bool saveOrError(const wowee::pipeline::WoweeServerConfig& c,
const std::string& base, const char* cmd) {
if (!wowee::pipeline::WoweeServerConfigLoader::save(c, base)) {
std::fprintf(stderr, "%s: failed to save %s.wcfg\n",
cmd, base.c_str());
return false;
}
return true;
}
void printGenSummary(const wowee::pipeline::WoweeServerConfig& c,
const std::string& base) {
std::printf("Wrote %s.wcfg\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" configs : %zu\n", c.entries.size());
}
int handleGenRates(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "RateMultipliers";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWcfgExt(base);
auto c = wowee::pipeline::WoweeServerConfigLoader::makeRates(name);
if (!saveOrError(c, base, "gen-cfg")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenPerf(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "PerformanceTuning";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWcfgExt(base);
auto c = wowee::pipeline::WoweeServerConfigLoader::makePerformance(name);
if (!saveOrError(c, base, "gen-cfg-perf")) return 1;
printGenSummary(c, base);
return 0;
}
int handleGenSecurity(int& i, int argc, char** argv) {
std::string base = argv[++i];
std::string name = "SecurityPolicy";
if (parseOptArg(i, argc, argv)) name = argv[++i];
base = stripWcfgExt(base);
auto c = wowee::pipeline::WoweeServerConfigLoader::makeSecurity(name);
if (!saveOrError(c, base, "gen-cfg-sec")) 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 = stripWcfgExt(base);
if (!wowee::pipeline::WoweeServerConfigLoader::exists(base)) {
std::fprintf(stderr, "WCFG not found: %s.wcfg\n", base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeServerConfigLoader::load(base);
if (jsonOut) {
nlohmann::json j;
j["wcfg"] = base + ".wcfg";
j["name"] = c.name;
j["count"] = c.entries.size();
nlohmann::json arr = nlohmann::json::array();
for (const auto& e : c.entries) {
arr.push_back({
{"configId", e.configId},
{"name", e.name},
{"description", e.description},
{"configKind", e.configKind},
{"configKindName", configKindName(e.configKind)},
{"valueKind", e.valueKind},
{"valueKindName", valueKindName(e.valueKind)},
{"restartRequired", e.restartRequired != 0},
{"floatValue", e.floatValue},
{"intValue", e.intValue},
{"strValue", e.strValue},
{"activeValue", activeValueString(e)},
{"iconColorRGBA", e.iconColorRGBA},
});
}
j["entries"] = arr;
std::printf("%s\n", j.dump(2).c_str());
return 0;
}
std::printf("WCFG: %s.wcfg\n", base.c_str());
std::printf(" catalog : %s\n", c.name.c_str());
std::printf(" configs : %zu\n", c.entries.size());
if (c.entries.empty()) return 0;
std::printf(" id kind valueKind restart value name\n");
for (const auto& e : c.entries) {
std::printf(" %4u %-11s %-8s %s %-20s %s\n",
e.configId, configKindName(e.configKind),
valueKindName(e.valueKind),
e.restartRequired ? "Y" : "n",
activeValueString(e).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 = stripWcfgExt(base);
if (!wowee::pipeline::WoweeServerConfigLoader::exists(base)) {
std::fprintf(stderr,
"validate-wcfg: WCFG not found: %s.wcfg\n",
base.c_str());
return 1;
}
auto c = wowee::pipeline::WoweeServerConfigLoader::load(base);
std::vector<std::string> errors;
std::vector<std::string> warnings;
if (c.entries.empty()) {
warnings.push_back("catalog has zero entries");
}
std::set<uint32_t> idsSeen;
std::set<std::string> namesSeen;
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.configId);
if (!e.name.empty()) ctx += " " + e.name;
ctx += ")";
if (e.configId == 0)
errors.push_back(ctx + ": configId is 0");
if (e.name.empty())
errors.push_back(ctx + ": name is empty");
if (e.configKind > 7 && e.configKind != 255) {
errors.push_back(ctx + ": configKind " +
std::to_string(e.configKind) +
" out of range (must be 0..7 or 255 Misc)");
}
if (e.valueKind > 3) {
errors.push_back(ctx + ": valueKind " +
std::to_string(e.valueKind) +
" out of range (must be 0..3)");
}
// Per-valueKind validity: each kind requires its
// matching field to carry meaningful data, others
// should be unset (server ignores them).
using C = wowee::pipeline::WoweeServerConfig;
if (e.valueKind == C::Float &&
e.floatValue == 0.0f && e.intValue != 0) {
warnings.push_back(ctx +
": valueKind=Float but intValue is "
"non-zero — intValue will be ignored "
"by the server but stored on disk; "
"consider clearing for cleaner serialization");
}
if (e.valueKind == C::Int && e.floatValue != 0.0f) {
warnings.push_back(ctx +
": valueKind=Int but floatValue is "
"non-zero — floatValue will be ignored "
"by the server");
}
if (e.valueKind == C::Bool && e.intValue != 0 &&
e.intValue != 1) {
errors.push_back(ctx +
": valueKind=Bool but intValue is " +
std::to_string(e.intValue) +
" (must be 0 or 1)");
}
if (e.valueKind == C::String && e.strValue.empty()) {
warnings.push_back(ctx +
": valueKind=String but strValue is "
"empty — config would default to empty "
"string");
}
// Names should be unique within a catalog (the
// server uses name as the primary lookup key for
// config-by-name access patterns common in
// legacy SQL-driven server configs).
if (!e.name.empty() &&
!namesSeen.insert(e.name).second) {
errors.push_back(ctx +
": duplicate config name '" + e.name +
"' — server name-based lookups would "
"be ambiguous");
}
if (!idsSeen.insert(e.configId).second) {
errors.push_back(ctx + ": duplicate configId");
}
}
bool ok = errors.empty();
if (jsonOut) {
nlohmann::json j;
j["wcfg"] = base + ".wcfg";
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-wcfg: %s.wcfg\n", base.c_str());
if (ok && warnings.empty()) {
std::printf(" OK — %zu configs, all configIds + "
"names unique, per-kind value semantics "
"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 handleServerConfigCatalog(int& i, int argc, char** argv,
int& outRc) {
if (std::strcmp(argv[i], "--gen-cfg") == 0 && i + 1 < argc) {
outRc = handleGenRates(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-cfg-perf") == 0 && i + 1 < argc) {
outRc = handleGenPerf(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--gen-cfg-sec") == 0 && i + 1 < argc) {
outRc = handleGenSecurity(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--info-wcfg") == 0 && i + 1 < argc) {
outRc = handleInfo(i, argc, argv); return true;
}
if (std::strcmp(argv[i], "--validate-wcfg") == 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 handleServerConfigCatalog(int& i, int argc, char** argv,
int& outRc);
} // namespace cli
} // namespace editor
} // namespace wowee