Kelsidavis-WoWee/include/pipeline/wowee_server_broadcasts.hpp
Kelsi 57df129404 feat(editor): add WSCB (Server Channel Broadcast) open catalog format
Novel replacement for the hardcoded login-MOTD chain,
restart-warning announcements, and rotating /help-channel
tips. Each entry is one scheduled or event-triggered
broadcast with channelKind (Login / SystemChannel /
RaidWarning / MOTD / HelpTip), faction filter,
level-range gating, and optional periodic interval for
ticker-driven channels.

Three preset emitters covering the canonical operational
broadcast patterns: makeMotd (4 login MOTDs — welcome
banner, patch summary, Discord, forum), makeMaintenance
(3 RaidWarning entries firing at 15min/5min/60s before
restart, intervalSeconds=0 since they're triggered by
the cron scheduler, not a self-timer), makeHelpTips (6
rotating /help-channel tips on a 600s cycle covering
talents/mounts/auction/professions/dungeon-finder/
hearthstone with appropriate level gates).

Validator catches several real misconfigurations: empty
messageText (no payload), interval>0 with login/MOTD
channel (timer ignored — those fire on session enter),
intervalSeconds<10 (player-spam error), <60 (warning),
text>255 chars (server truncation), level-range
inversions, factionFilter=0 (no audience).

Format count 97 -> 98. CLI flag count 1104 -> 1109.
2026-05-10 00:31:15 -07:00

129 lines
4.9 KiB
C++

#pragma once
#include <cstdint>
#include <string>
#include <vector>
namespace wowee {
namespace pipeline {
// Wowee Open Server Channel Broadcast catalog (.wscb) —
// novel replacement for the hardcoded login-MOTD,
// server-restart-warning, and rotating-help-tip messages
// that vanilla servers nail into source. Each entry is
// one scheduled or event-triggered broadcast: a one-shot
// MOTD shown on login, a periodic system message
// ("server restart in 10 minutes"), a raid-wide warning,
// or a rotating gameplay tip displayed in the /help
// channel.
//
// Cross-references with previously-added formats:
// WCHN: channelKind values 0..4 map to dispatch sinks;
// the SystemChannel/HelpTip variants land in the
// WCHN-defined system / help channels.
// WCHC: factionFilter uses the WCHC faction-mask bits
// (1=Alliance, 2=Horde, 3=Both, 0=neither which
// means "no broadcast" — validator warns).
//
// Binary layout (little-endian):
// magic[4] = "WSCB"
// version (uint32) = current 1
// nameLen + name (catalog label)
// entryCount (uint32)
// entries (each):
// broadcastId (uint32)
// nameLen + name
// descLen + description
// msgLen + messageText
// intervalSeconds (uint32) — 0 = login-only / once
// channelKind (uint8) — Login / SystemChannel /
// RaidWarning / MOTD /
// HelpTip
// factionFilter (uint8) — WCHC faction-mask bits
// minLevel (uint8) — earliest level player
// must be to receive (0
// = any)
// maxLevel (uint8) — latest level (0 = any)
// iconColorRGBA (uint32)
struct WoweeServerBroadcasts {
enum ChannelKind : uint8_t {
Login = 0, // shown once on character
// entering world
SystemChannel = 1, // WCHN system channel
// (server-side)
RaidWarning = 2, // SMSG_RAID_WARNING (red
// banner across screen)
MOTD = 3, // appended to existing
// server MOTD chain
HelpTip = 4, // rotating tip shown in
// /help channel
};
enum FactionFilter : uint8_t {
AllianceOnly = 1,
HordeOnly = 2,
Both = 3,
};
struct Entry {
uint32_t broadcastId = 0;
std::string name;
std::string description;
std::string messageText; // body shown to player
uint32_t intervalSeconds = 0;
uint8_t channelKind = MOTD;
uint8_t factionFilter = Both;
uint8_t minLevel = 0;
uint8_t maxLevel = 0;
uint32_t iconColorRGBA = 0xFFFFFFFFu;
};
std::string name;
std::vector<Entry> entries;
bool isValid() const { return !entries.empty(); }
const Entry* findById(uint32_t broadcastId) const;
// Returns all broadcasts that should fire for a player
// of the given faction and level. Used by the
// BroadcastTicker to build the per-player message
// queue on login.
std::vector<const Entry*> findFor(uint8_t playerFaction,
uint8_t playerLevel) const;
// Returns all broadcasts of one channel kind (used by
// the periodic ticker to schedule SystemChannel /
// HelpTip rotations independently from login MOTDs).
std::vector<const Entry*> findByChannel(uint8_t channelKind) const;
};
class WoweeServerBroadcastsLoader {
public:
static bool save(const WoweeServerBroadcasts& cat,
const std::string& basePath);
static WoweeServerBroadcasts load(const std::string& basePath);
static bool exists(const std::string& basePath);
// Preset emitters used by --gen-scb* variants.
//
// makeMotd — 4 login MOTD entries (welcome /
// patch notes summary / Discord
// link / forum link).
// makeMaintenance — 3 raid-wide maintenance warnings
// at decreasing intervals (15min
// / 5min / 1min before restart),
// each with intervalSeconds=0
// (one-shot).
// makeHelpTips — 6 rotating help-channel tips on
// a 600s (10min) cycle covering
// core gameplay (talents, mounts,
// auction, professions, dungeon
// finder, hearthstone).
static WoweeServerBroadcasts makeMotd(const std::string& catalogName);
static WoweeServerBroadcasts makeMaintenance(const std::string& catalogName);
static WoweeServerBroadcasts makeHelpTips(const std::string& catalogName);
};
} // namespace pipeline
} // namespace wowee