mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 02:53:51 +00:00
feat(pipeline): add WCHN (Wowee Chat Channel) catalog
Novel open replacement for Blizzard's ChatChannels.dbc +
the AzerothCore-style chat_channel SQL tables. The 40th
open format added to the editor.
Defines the world chat channel system: General, Trade,
LookingForGroup, GuildRecruitment, LocalDefense, plus
per-zone area channels and custom user-created channels.
Each channel has access rules (faction / level), join
behavior (auto vs opt-in), broadcast policy (announce /
moderated), and optional area / map gating that auto-joins
or auto-leaves the channel as the player moves.
Cross-references with previously-added formats:
WCHN.entry.areaIdGate -> WMS.area.areaId
(channel auto-attaches in this area)
WCHN.entry.mapIdGate -> WMS.map.mapId
(channel auto-attaches on this map)
Format:
• magic "WCHN", version 1, little-endian
• per channel: channelId / name / description /
channelType / factionAccess / autoJoin / announce /
moderated / minLevel / areaIdGate / mapIdGate
Enums:
• ChannelType (10): AreaLocal / Zone / Continent / World /
Trade / LookingForGroup / GuildRecruit /
LocalDefense / Custom / Pvp
• FactionAccess (3): Alliance / Horde / Both
API: WoweeChannelLoader::save / load / exists / findById.
Three preset emitters:
• makeStarter — 4 stock channels (General Zone +
Trade + LFG + GuildRecruit) with
default autoJoin policies
• makeCity — 5 city-specific channels (3 Stormwind +
2 Orgrimmar) with mapId / areaId gates
so they auto-attach on entry
• makeModerated — 3 moderated / restricted channels
(LocalDefense level 10+, WorldDefense
moderated, RaidCoordination level 60+)
CLI added (5 flags, 677 documented total now):
--gen-channels / --gen-channels-city / --gen-channels-moderated
--info-wchn / --validate-wchn
Validator catches: channelId=0 + duplicates, empty name,
unknown channelType / factionAccess, world / continent
channel with area or map gate (gate is silently ignored at
runtime — usually a typo), minLevel=0 (no level gate at all).
This commit is contained in:
parent
13f09b8cb7
commit
af214d8b34
8 changed files with 623 additions and 0 deletions
|
|
@ -627,6 +627,7 @@ set(WOWEE_SOURCES
|
|||
src/pipeline/wowee_conditions.cpp
|
||||
src/pipeline/wowee_pets.cpp
|
||||
src/pipeline/wowee_auction.cpp
|
||||
src/pipeline/wowee_channels.cpp
|
||||
src/pipeline/custom_zone_discovery.cpp
|
||||
src/pipeline/dbc_layout.cpp
|
||||
|
||||
|
|
@ -1400,6 +1401,7 @@ add_executable(wowee_editor
|
|||
tools/editor/cli_conditions_catalog.cpp
|
||||
tools/editor/cli_pets_catalog.cpp
|
||||
tools/editor/cli_auction_catalog.cpp
|
||||
tools/editor/cli_channels_catalog.cpp
|
||||
tools/editor/cli_quest_objective.cpp
|
||||
tools/editor/cli_quest_reward.cpp
|
||||
tools/editor/cli_clone.cpp
|
||||
|
|
@ -1505,6 +1507,7 @@ add_executable(wowee_editor
|
|||
src/pipeline/wowee_conditions.cpp
|
||||
src/pipeline/wowee_pets.cpp
|
||||
src/pipeline/wowee_auction.cpp
|
||||
src/pipeline/wowee_channels.cpp
|
||||
src/pipeline/custom_zone_discovery.cpp
|
||||
src/pipeline/terrain_mesh.cpp
|
||||
|
||||
|
|
|
|||
111
include/pipeline/wowee_channels.hpp
Normal file
111
include/pipeline/wowee_channels.hpp
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
||||
// Wowee Open Chat Channel catalog (.wchn) — novel
|
||||
// replacement for Blizzard's ChatChannels.dbc + the
|
||||
// AzerothCore-style chat_channel SQL tables. The 40th
|
||||
// open format added to the editor.
|
||||
//
|
||||
// Defines the world chat channel system: General, Trade,
|
||||
// LookingForGroup, GuildRecruitment, LocalDefense, plus
|
||||
// per-zone area channels and custom user-created channels.
|
||||
// Each channel has access rules (faction / level), join
|
||||
// behavior (auto vs opt-in), broadcast policy (announce /
|
||||
// moderated), and optional area / map gating that
|
||||
// auto-joins or auto-leaves the channel as the player moves.
|
||||
//
|
||||
// Cross-references with previously-added formats:
|
||||
// WCHN.entry.areaIdGate → WMS.area.areaId
|
||||
// (channel auto-attaches in this area)
|
||||
// WCHN.entry.mapIdGate → WMS.map.mapId
|
||||
// (channel auto-attaches on this map)
|
||||
//
|
||||
// Binary layout (little-endian):
|
||||
// magic[4] = "WCHN"
|
||||
// version (uint32) = current 1
|
||||
// nameLen + name (catalog label)
|
||||
// entryCount (uint32)
|
||||
// entries (each):
|
||||
// channelId (uint32)
|
||||
// nameLen + name
|
||||
// descLen + description
|
||||
// channelType (uint8) / factionAccess (uint8) /
|
||||
// autoJoin (uint8) / announce (uint8)
|
||||
// moderated (uint8) / pad[1] / minLevel (uint16)
|
||||
// areaIdGate (uint32) / mapIdGate (uint32)
|
||||
struct WoweeChannel {
|
||||
enum ChannelType : uint8_t {
|
||||
AreaLocal = 0, // /local within a sub-zone
|
||||
Zone = 1, // zone-wide
|
||||
Continent = 2, // continent-wide
|
||||
World = 3, // entire realm
|
||||
Trade = 4, // trade district + opt-in
|
||||
LookingForGroup = 5, // LFG global
|
||||
GuildRecruit = 6, // GuildFinder global
|
||||
LocalDefense = 7, // alarm channel for zone attacks
|
||||
Custom = 8, // user-created
|
||||
Pvp = 9, // PvP-mode players
|
||||
};
|
||||
|
||||
enum FactionAccess : uint8_t {
|
||||
Alliance = 0,
|
||||
Horde = 1,
|
||||
Both = 2,
|
||||
};
|
||||
|
||||
struct Entry {
|
||||
uint32_t channelId = 0;
|
||||
std::string name;
|
||||
std::string description;
|
||||
uint8_t channelType = AreaLocal;
|
||||
uint8_t factionAccess = Both;
|
||||
uint8_t autoJoin = 0; // 1 = auto-join on context match
|
||||
uint8_t announce = 1; // 1 = broadcast join/leave
|
||||
uint8_t moderated = 0; // 1 = only operators speak
|
||||
uint16_t minLevel = 1;
|
||||
uint32_t areaIdGate = 0; // 0 = no gate
|
||||
uint32_t mapIdGate = 0;
|
||||
};
|
||||
|
||||
std::string name;
|
||||
std::vector<Entry> entries;
|
||||
|
||||
bool isValid() const { return !entries.empty(); }
|
||||
|
||||
const Entry* findById(uint32_t channelId) const;
|
||||
|
||||
static const char* channelTypeName(uint8_t t);
|
||||
static const char* factionAccessName(uint8_t f);
|
||||
};
|
||||
|
||||
class WoweeChannelLoader {
|
||||
public:
|
||||
static bool save(const WoweeChannel& cat,
|
||||
const std::string& basePath);
|
||||
static WoweeChannel load(const std::string& basePath);
|
||||
static bool exists(const std::string& basePath);
|
||||
|
||||
// Preset emitters used by --gen-channels* variants.
|
||||
//
|
||||
// makeStarter — 4 stock channels (General / Trade /
|
||||
// LFG / GuildRecruit) with default
|
||||
// autoJoin and announce rules.
|
||||
// makeCity — 5 city-specific channels (Stormwind
|
||||
// General / Trade / LFG + Orgrimmar
|
||||
// General / Trade) with mapId gates.
|
||||
// makeModerated — 3 moderated / restricted channels
|
||||
// (LocalDefense level 10+, World event
|
||||
// chat, custom raid coordination).
|
||||
static WoweeChannel makeStarter(const std::string& catalogName);
|
||||
static WoweeChannel makeCity(const std::string& catalogName);
|
||||
static WoweeChannel makeModerated(const std::string& catalogName);
|
||||
};
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace wowee
|
||||
250
src/pipeline/wowee_channels.cpp
Normal file
250
src/pipeline/wowee_channels.cpp
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
#include "pipeline/wowee_channels.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr char kMagic[4] = {'W', 'C', 'H', 'N'};
|
||||
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) != ".wchn") {
|
||||
base += ".wchn";
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const WoweeChannel::Entry*
|
||||
WoweeChannel::findById(uint32_t channelId) const {
|
||||
for (const auto& e : entries) if (e.channelId == channelId) return &e;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char* WoweeChannel::channelTypeName(uint8_t t) {
|
||||
switch (t) {
|
||||
case AreaLocal: return "local";
|
||||
case Zone: return "zone";
|
||||
case Continent: return "continent";
|
||||
case World: return "world";
|
||||
case Trade: return "trade";
|
||||
case LookingForGroup: return "lfg";
|
||||
case GuildRecruit: return "guild-recruit";
|
||||
case LocalDefense: return "local-defense";
|
||||
case Custom: return "custom";
|
||||
case Pvp: return "pvp";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const char* WoweeChannel::factionAccessName(uint8_t f) {
|
||||
switch (f) {
|
||||
case Alliance: return "alliance";
|
||||
case Horde: return "horde";
|
||||
case Both: return "both";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
bool WoweeChannelLoader::save(const WoweeChannel& 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.channelId);
|
||||
writeStr(os, e.name);
|
||||
writeStr(os, e.description);
|
||||
writePOD(os, e.channelType);
|
||||
writePOD(os, e.factionAccess);
|
||||
writePOD(os, e.autoJoin);
|
||||
writePOD(os, e.announce);
|
||||
writePOD(os, e.moderated);
|
||||
uint8_t pad = 0;
|
||||
writePOD(os, pad);
|
||||
writePOD(os, e.minLevel);
|
||||
writePOD(os, e.areaIdGate);
|
||||
writePOD(os, e.mapIdGate);
|
||||
}
|
||||
return os.good();
|
||||
}
|
||||
|
||||
WoweeChannel WoweeChannelLoader::load(const std::string& basePath) {
|
||||
WoweeChannel 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.channelId)) { out.entries.clear(); return out; }
|
||||
if (!readStr(is, e.name) || !readStr(is, e.description)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
if (!readPOD(is, e.channelType) ||
|
||||
!readPOD(is, e.factionAccess) ||
|
||||
!readPOD(is, e.autoJoin) ||
|
||||
!readPOD(is, e.announce) ||
|
||||
!readPOD(is, e.moderated)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
uint8_t pad = 0;
|
||||
if (!readPOD(is, pad)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
if (!readPOD(is, e.minLevel) ||
|
||||
!readPOD(is, e.areaIdGate) ||
|
||||
!readPOD(is, e.mapIdGate)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool WoweeChannelLoader::exists(const std::string& basePath) {
|
||||
std::ifstream is(normalizePath(basePath), std::ios::binary);
|
||||
return is.good();
|
||||
}
|
||||
|
||||
WoweeChannel WoweeChannelLoader::makeStarter(const std::string& catalogName) {
|
||||
WoweeChannel c;
|
||||
c.name = catalogName;
|
||||
auto add = [&](uint32_t id, const char* name, uint8_t type,
|
||||
uint8_t autoJ, uint16_t minLvl,
|
||||
const char* desc) {
|
||||
WoweeChannel::Entry e;
|
||||
e.channelId = id; e.name = name; e.description = desc;
|
||||
e.channelType = type; e.autoJoin = autoJ;
|
||||
e.minLevel = minLvl;
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
add(1, "General", WoweeChannel::Zone, 1, 1,
|
||||
"Zone-wide chatter; auto-joined for current zone.");
|
||||
add(2, "Trade", WoweeChannel::Trade, 0, 1,
|
||||
"Cross-zone trade chatter; opt-in.");
|
||||
add(3, "LookingForGroup", WoweeChannel::LookingForGroup, 1, 10,
|
||||
"Global LFG queue chat.");
|
||||
add(4, "GuildRecruitment", WoweeChannel::GuildRecruit, 0, 10,
|
||||
"Recruit-a-guild + hire-a-guild bulletin.");
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeChannel WoweeChannelLoader::makeCity(const std::string& catalogName) {
|
||||
WoweeChannel c;
|
||||
c.name = catalogName;
|
||||
auto add = [&](uint32_t id, const char* name, uint8_t type,
|
||||
uint8_t fac, uint32_t mapId, uint32_t areaId,
|
||||
const char* desc) {
|
||||
WoweeChannel::Entry e;
|
||||
e.channelId = id; e.name = name; e.description = desc;
|
||||
e.channelType = type; e.factionAccess = fac;
|
||||
e.autoJoin = 1;
|
||||
e.mapIdGate = mapId; e.areaIdGate = areaId;
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
// mapId 0 + areaId 1 ~ Stormwind City (matches WMS preset).
|
||||
add(100, "General - Stormwind", WoweeChannel::Zone,
|
||||
WoweeChannel::Alliance, 0, 1,
|
||||
"Stormwind general chat.");
|
||||
add(101, "Trade - Stormwind", WoweeChannel::Trade,
|
||||
WoweeChannel::Alliance, 0, 1,
|
||||
"Stormwind trade district chat.");
|
||||
add(102, "LFG - Stormwind", WoweeChannel::LookingForGroup,
|
||||
WoweeChannel::Alliance, 0, 1,
|
||||
"Stormwind LFG within-city queue.");
|
||||
add(110, "General - Orgrimmar", WoweeChannel::Zone,
|
||||
WoweeChannel::Horde, 1, 1637,
|
||||
"Orgrimmar general chat.");
|
||||
add(111, "Trade - Orgrimmar", WoweeChannel::Trade,
|
||||
WoweeChannel::Horde, 1, 1637,
|
||||
"Orgrimmar trade district chat.");
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeChannel WoweeChannelLoader::makeModerated(const std::string& catalogName) {
|
||||
WoweeChannel c;
|
||||
c.name = catalogName;
|
||||
{
|
||||
WoweeChannel::Entry e;
|
||||
e.channelId = 200; e.name = "LocalDefense";
|
||||
e.description =
|
||||
"Alarm channel — broadcasts when zone is attacked. "
|
||||
"Level 10+ auto-joined.";
|
||||
e.channelType = WoweeChannel::LocalDefense;
|
||||
e.autoJoin = 1; e.minLevel = 10;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
{
|
||||
WoweeChannel::Entry e;
|
||||
e.channelId = 201; e.name = "WorldDefense";
|
||||
e.description =
|
||||
"Cross-zone defense alarm. World boss / invasion broadcast.";
|
||||
e.channelType = WoweeChannel::World;
|
||||
e.autoJoin = 1; e.minLevel = 10;
|
||||
e.moderated = 1;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
{
|
||||
WoweeChannel::Entry e;
|
||||
e.channelId = 202; e.name = "RaidCoordination";
|
||||
e.description =
|
||||
"Custom moderated channel for cross-guild raid runs.";
|
||||
e.channelType = WoweeChannel::Custom;
|
||||
e.autoJoin = 0; e.minLevel = 60;
|
||||
e.moderated = 1;
|
||||
c.entries.push_back(e);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace wowee
|
||||
|
|
@ -115,6 +115,8 @@ const char* const kArgRequired[] = {
|
|||
"--export-wpet-json", "--import-wpet-json",
|
||||
"--gen-auction", "--gen-auction-pair", "--gen-auction-restricted",
|
||||
"--info-wauc", "--validate-wauc",
|
||||
"--gen-channels", "--gen-channels-city", "--gen-channels-moderated",
|
||||
"--info-wchn", "--validate-wchn",
|
||||
"--gen-weather-temperate", "--gen-weather-arctic",
|
||||
"--gen-weather-desert", "--gen-weather-stormy",
|
||||
"--gen-zone-atmosphere",
|
||||
|
|
|
|||
234
tools/editor/cli_channels_catalog.cpp
Normal file
234
tools/editor/cli_channels_catalog.cpp
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
#include "cli_channels_catalog.hpp"
|
||||
#include "cli_arg_parse.hpp"
|
||||
#include "cli_box_emitter.hpp"
|
||||
|
||||
#include "pipeline/wowee_channels.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 stripWchnExt(std::string base) {
|
||||
stripExt(base, ".wchn");
|
||||
return base;
|
||||
}
|
||||
|
||||
bool saveOrError(const wowee::pipeline::WoweeChannel& c,
|
||||
const std::string& base, const char* cmd) {
|
||||
if (!wowee::pipeline::WoweeChannelLoader::save(c, base)) {
|
||||
std::fprintf(stderr, "%s: failed to save %s.wchn\n",
|
||||
cmd, base.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void printGenSummary(const wowee::pipeline::WoweeChannel& c,
|
||||
const std::string& base) {
|
||||
std::printf("Wrote %s.wchn\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" channels : %zu\n", c.entries.size());
|
||||
}
|
||||
|
||||
int handleGenStarter(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "StarterChannels";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWchnExt(base);
|
||||
auto c = wowee::pipeline::WoweeChannelLoader::makeStarter(name);
|
||||
if (!saveOrError(c, base, "gen-channels")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenCity(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "CityChannels";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWchnExt(base);
|
||||
auto c = wowee::pipeline::WoweeChannelLoader::makeCity(name);
|
||||
if (!saveOrError(c, base, "gen-channels-city")) return 1;
|
||||
printGenSummary(c, base);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int handleGenModerated(int& i, int argc, char** argv) {
|
||||
std::string base = argv[++i];
|
||||
std::string name = "ModeratedChannels";
|
||||
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
||||
base = stripWchnExt(base);
|
||||
auto c = wowee::pipeline::WoweeChannelLoader::makeModerated(name);
|
||||
if (!saveOrError(c, base, "gen-channels-moderated")) 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 = stripWchnExt(base);
|
||||
if (!wowee::pipeline::WoweeChannelLoader::exists(base)) {
|
||||
std::fprintf(stderr, "WCHN not found: %s.wchn\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeChannelLoader::load(base);
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wchn"] = base + ".wchn";
|
||||
j["name"] = c.name;
|
||||
j["count"] = c.entries.size();
|
||||
nlohmann::json arr = nlohmann::json::array();
|
||||
for (const auto& e : c.entries) {
|
||||
arr.push_back({
|
||||
{"channelId", e.channelId},
|
||||
{"name", e.name},
|
||||
{"description", e.description},
|
||||
{"channelType", e.channelType},
|
||||
{"channelTypeName", wowee::pipeline::WoweeChannel::channelTypeName(e.channelType)},
|
||||
{"factionAccess", e.factionAccess},
|
||||
{"factionAccessName", wowee::pipeline::WoweeChannel::factionAccessName(e.factionAccess)},
|
||||
{"autoJoin", e.autoJoin},
|
||||
{"announce", e.announce},
|
||||
{"moderated", e.moderated},
|
||||
{"minLevel", e.minLevel},
|
||||
{"areaIdGate", e.areaIdGate},
|
||||
{"mapIdGate", e.mapIdGate},
|
||||
});
|
||||
}
|
||||
j["entries"] = arr;
|
||||
std::printf("%s\n", j.dump(2).c_str());
|
||||
return 0;
|
||||
}
|
||||
std::printf("WCHN: %s.wchn\n", base.c_str());
|
||||
std::printf(" catalog : %s\n", c.name.c_str());
|
||||
std::printf(" channels : %zu\n", c.entries.size());
|
||||
if (c.entries.empty()) return 0;
|
||||
std::printf(" id type faction auto ann mod lvl map area name\n");
|
||||
for (const auto& e : c.entries) {
|
||||
std::printf(" %4u %-13s %-8s %u %u %u %3u %3u %4u %s\n",
|
||||
e.channelId,
|
||||
wowee::pipeline::WoweeChannel::channelTypeName(e.channelType),
|
||||
wowee::pipeline::WoweeChannel::factionAccessName(e.factionAccess),
|
||||
e.autoJoin, e.announce, e.moderated,
|
||||
e.minLevel, e.mapIdGate, e.areaIdGate,
|
||||
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 = stripWchnExt(base);
|
||||
if (!wowee::pipeline::WoweeChannelLoader::exists(base)) {
|
||||
std::fprintf(stderr,
|
||||
"validate-wchn: WCHN not found: %s.wchn\n", base.c_str());
|
||||
return 1;
|
||||
}
|
||||
auto c = wowee::pipeline::WoweeChannelLoader::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.channelId);
|
||||
if (!e.name.empty()) ctx += " " + e.name;
|
||||
ctx += ")";
|
||||
if (e.channelId == 0) errors.push_back(ctx + ": channelId is 0");
|
||||
if (e.name.empty()) errors.push_back(ctx + ": name is empty");
|
||||
if (e.channelType > wowee::pipeline::WoweeChannel::Pvp) {
|
||||
errors.push_back(ctx + ": channelType " +
|
||||
std::to_string(e.channelType) + " not in 0..9");
|
||||
}
|
||||
if (e.factionAccess > wowee::pipeline::WoweeChannel::Both) {
|
||||
errors.push_back(ctx + ": factionAccess " +
|
||||
std::to_string(e.factionAccess) + " not in 0..2");
|
||||
}
|
||||
// AreaLocal / Zone channels with no area gate aren't broken,
|
||||
// but world / continent channels with an area gate is
|
||||
// contradictory.
|
||||
if ((e.channelType == wowee::pipeline::WoweeChannel::World ||
|
||||
e.channelType == wowee::pipeline::WoweeChannel::Continent) &&
|
||||
(e.areaIdGate != 0 || e.mapIdGate != 0)) {
|
||||
warnings.push_back(ctx +
|
||||
": world/continent channel with area or map gate "
|
||||
"(gate is silently ignored at runtime)");
|
||||
}
|
||||
if (e.minLevel == 0) {
|
||||
warnings.push_back(ctx + ": minLevel=0 (no level gate at all)");
|
||||
}
|
||||
for (uint32_t prev : idsSeen) {
|
||||
if (prev == e.channelId) {
|
||||
errors.push_back(ctx + ": duplicate channelId");
|
||||
break;
|
||||
}
|
||||
}
|
||||
idsSeen.push_back(e.channelId);
|
||||
}
|
||||
bool ok = errors.empty();
|
||||
if (jsonOut) {
|
||||
nlohmann::json j;
|
||||
j["wchn"] = base + ".wchn";
|
||||
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-wchn: %s.wchn\n", base.c_str());
|
||||
if (ok && warnings.empty()) {
|
||||
std::printf(" OK — %zu channels, all channelIds 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 handleChannelsCatalog(int& i, int argc, char** argv, int& outRc) {
|
||||
if (std::strcmp(argv[i], "--gen-channels") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenStarter(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-channels-city") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenCity(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--gen-channels-moderated") == 0 && i + 1 < argc) {
|
||||
outRc = handleGenModerated(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--info-wchn") == 0 && i + 1 < argc) {
|
||||
outRc = handleInfo(i, argc, argv); return true;
|
||||
}
|
||||
if (std::strcmp(argv[i], "--validate-wchn") == 0 && i + 1 < argc) {
|
||||
outRc = handleValidate(i, argc, argv); return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace cli
|
||||
} // namespace editor
|
||||
} // namespace wowee
|
||||
11
tools/editor/cli_channels_catalog.hpp
Normal file
11
tools/editor/cli_channels_catalog.hpp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
namespace wowee {
|
||||
namespace editor {
|
||||
namespace cli {
|
||||
|
||||
bool handleChannelsCatalog(int& i, int argc, char** argv, int& outRc);
|
||||
|
||||
} // namespace cli
|
||||
} // namespace editor
|
||||
} // namespace wowee
|
||||
|
|
@ -67,6 +67,7 @@
|
|||
#include "cli_conditions_catalog.hpp"
|
||||
#include "cli_pets_catalog.hpp"
|
||||
#include "cli_auction_catalog.hpp"
|
||||
#include "cli_channels_catalog.hpp"
|
||||
#include "cli_quest_objective.hpp"
|
||||
#include "cli_quest_reward.hpp"
|
||||
#include "cli_clone.hpp"
|
||||
|
|
@ -175,6 +176,7 @@ constexpr DispatchFn kDispatchTable[] = {
|
|||
handleConditionsCatalog,
|
||||
handlePetsCatalog,
|
||||
handleAuctionCatalog,
|
||||
handleChannelsCatalog,
|
||||
handleQuestObjective,
|
||||
handleQuestReward,
|
||||
handleClone,
|
||||
|
|
|
|||
|
|
@ -1259,6 +1259,16 @@ void printUsage(const char* argv0) {
|
|||
std::printf(" Print WAUC houses (id / faction / deposit + cut percent / 3 duration tiers / disallow mask / npc)\n");
|
||||
std::printf(" --validate-wauc <wauc-base> [--json]\n");
|
||||
std::printf(" Static checks: id>0+unique, faction 0..3, durations short<=medium<=long, cut < 100%%\n");
|
||||
std::printf(" --gen-channels <wchn-base> [name]\n");
|
||||
std::printf(" Emit .wchn starter: 4 stock channels (General / Trade / LFG / GuildRecruit) with autoJoin defaults\n");
|
||||
std::printf(" --gen-channels-city <wchn-base> [name]\n");
|
||||
std::printf(" Emit .wchn 5 city channels (Stormwind General/Trade/LFG + Orgrimmar General/Trade) with map+area gates\n");
|
||||
std::printf(" --gen-channels-moderated <wchn-base> [name]\n");
|
||||
std::printf(" Emit .wchn 3 moderated channels (LocalDefense / WorldDefense moderated / RaidCoordination level 60+)\n");
|
||||
std::printf(" --info-wchn <wchn-base> [--json]\n");
|
||||
std::printf(" Print WCHN entries (id / type / faction / autoJoin/announce/moderated / level / map+area gates / name)\n");
|
||||
std::printf(" --validate-wchn <wchn-base> [--json]\n");
|
||||
std::printf(" Static checks: id>0+unique, name not empty, type 0..9, faction 0..2, world+area-gate combo warning\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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue