mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-11 11:33:52 +00:00
feat(editor): add WMSP (Master Server Profile) — 100th open format
Novel replacement for the hardcoded realmlist that the
WoW client receives via SMSG_REALM_LIST during login.
Each entry is one selectable realm: name, network address
(host:port), realm type (Normal/PvP/RP/RPPvP/Test), realm
category (Public/Private/Beta/Dev), expansion gating
(Vanilla 1.12.1 / TBC 2.4.3 / WotLK 3.3.5a / Cata 4.3.4),
population indicator (Low/Medium/High/Full/Locked), char-
acter cap, GM-only flag, timezone hint, and per-realm
version+build numbers.
100th open format — milestone marker for the catalog
ecosystem. WMSP is a TOP-LEVEL bootstrap catalog (read by
the login server before any character is loaded), so it
deliberately has no cross-references to other catalogs;
all other social/world/spell catalogs depend on a player
session that doesn't exist until WMSP has been consulted.
Three preset emitters covering common deployment shapes:
makeSingleRealm (1 default WoweeMain WotLK Public),
makePvPCluster (3 realms — PvE/PvP/RP — sharing one login
address so players pick rule-set without changing servers),
makeMultiExpansion (4 progression realms across all
expansion gates with their canonical build numbers from
the matching client).
Validator catches several real misconfigurations: empty
address (login server cannot route session), realmType
out of {0,1,4,6,8} (the WoW client's RealmType enum is
non-contiguous — 2/3/5/7 are unused values that crash the
picker), characterCap=0 (players can't make characters),
duplicate realm names (picker requires unique display
names), missing port in address.
Format count 99 -> 100. CLI flag count 1119 -> 1124.
This commit is contained in:
parent
2f76653cf7
commit
054f44e4aa
10 changed files with 808 additions and 0 deletions
284
src/pipeline/wowee_realm_list.cpp
Normal file
284
src/pipeline/wowee_realm_list.cpp
Normal file
|
|
@ -0,0 +1,284 @@
|
|||
#include "pipeline/wowee_realm_list.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr char kMagic[4] = {'W', 'M', 'S', 'P'};
|
||||
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) != ".wmsp") {
|
||||
base += ".wmsp";
|
||||
}
|
||||
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 WoweeRealmList::Entry*
|
||||
WoweeRealmList::findById(uint32_t realmId) const {
|
||||
for (const auto& e : entries)
|
||||
if (e.realmId == realmId) return &e;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<const WoweeRealmList::Entry*>
|
||||
WoweeRealmList::findByExpansion(uint8_t maxExpansion) const {
|
||||
std::vector<const Entry*> out;
|
||||
for (const auto& e : entries)
|
||||
if (e.expansion <= maxExpansion) out.push_back(&e);
|
||||
return out;
|
||||
}
|
||||
|
||||
std::vector<const WoweeRealmList::Entry*>
|
||||
WoweeRealmList::findByType(uint8_t realmType) const {
|
||||
std::vector<const Entry*> out;
|
||||
for (const auto& e : entries)
|
||||
if (e.realmType == realmType) out.push_back(&e);
|
||||
return out;
|
||||
}
|
||||
|
||||
bool WoweeRealmListLoader::save(const WoweeRealmList& 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.realmId);
|
||||
writeStr(os, e.name);
|
||||
writeStr(os, e.description);
|
||||
writeStr(os, e.address);
|
||||
writePOD(os, e.realmType);
|
||||
writePOD(os, e.realmCategory);
|
||||
writePOD(os, e.expansion);
|
||||
writePOD(os, e.population);
|
||||
writePOD(os, e.characterCap);
|
||||
writePOD(os, e.gmOnly);
|
||||
writePOD(os, e.timezone);
|
||||
writePOD(os, e.pad0);
|
||||
writePOD(os, e.versionMajor);
|
||||
writePOD(os, e.versionMinor);
|
||||
writePOD(os, e.versionPatch);
|
||||
writePOD(os, e.pad1);
|
||||
writePOD(os, e.buildNumber);
|
||||
writePOD(os, e.iconColorRGBA);
|
||||
}
|
||||
return os.good();
|
||||
}
|
||||
|
||||
WoweeRealmList WoweeRealmListLoader::load(const std::string& basePath) {
|
||||
WoweeRealmList 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.realmId)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
if (!readStr(is, e.name) ||
|
||||
!readStr(is, e.description) ||
|
||||
!readStr(is, e.address)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
if (!readPOD(is, e.realmType) ||
|
||||
!readPOD(is, e.realmCategory) ||
|
||||
!readPOD(is, e.expansion) ||
|
||||
!readPOD(is, e.population) ||
|
||||
!readPOD(is, e.characterCap) ||
|
||||
!readPOD(is, e.gmOnly) ||
|
||||
!readPOD(is, e.timezone) ||
|
||||
!readPOD(is, e.pad0) ||
|
||||
!readPOD(is, e.versionMajor) ||
|
||||
!readPOD(is, e.versionMinor) ||
|
||||
!readPOD(is, e.versionPatch) ||
|
||||
!readPOD(is, e.pad1) ||
|
||||
!readPOD(is, e.buildNumber) ||
|
||||
!readPOD(is, e.iconColorRGBA)) {
|
||||
out.entries.clear(); return out;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool WoweeRealmListLoader::exists(const std::string& basePath) {
|
||||
std::ifstream is(normalizePath(basePath), std::ios::binary);
|
||||
return is.good();
|
||||
}
|
||||
|
||||
WoweeRealmList WoweeRealmListLoader::makeSingleRealm(
|
||||
const std::string& catalogName) {
|
||||
using R = WoweeRealmList;
|
||||
WoweeRealmList c;
|
||||
c.name = catalogName;
|
||||
R::Entry e;
|
||||
e.realmId = 1;
|
||||
e.name = "WoweeMain";
|
||||
e.description =
|
||||
"Default Wowee server realm — WotLK 3.3.5a, Normal "
|
||||
"PvE rule-set, public category, US East timezone, "
|
||||
"10-character cap per account.";
|
||||
e.address = "logon.wowee.example.com:8085";
|
||||
e.realmType = R::Normal;
|
||||
e.realmCategory = R::Public;
|
||||
e.expansion = R::WotLK;
|
||||
e.population = R::Medium;
|
||||
e.characterCap = 10;
|
||||
e.gmOnly = 0;
|
||||
e.timezone = 8;
|
||||
e.versionMajor = 3; e.versionMinor = 3; e.versionPatch = 5;
|
||||
e.buildNumber = 12340;
|
||||
e.iconColorRGBA = packRgba(140, 200, 255); // realm blue
|
||||
c.entries.push_back(e);
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeRealmList WoweeRealmListLoader::makePvPCluster(
|
||||
const std::string& catalogName) {
|
||||
using R = WoweeRealmList;
|
||||
WoweeRealmList c;
|
||||
c.name = catalogName;
|
||||
auto add = [&](uint32_t id, const char* name, uint8_t type,
|
||||
uint8_t pop, uint32_t color, const char* desc) {
|
||||
R::Entry e;
|
||||
e.realmId = id; e.name = name; e.description = desc;
|
||||
e.address = "cluster.wowee.example.com:8085";
|
||||
e.realmType = type;
|
||||
e.realmCategory = R::Public;
|
||||
e.expansion = R::WotLK;
|
||||
e.population = pop;
|
||||
e.characterCap = 10;
|
||||
e.gmOnly = 0;
|
||||
e.timezone = 8;
|
||||
e.versionMajor = 3; e.versionMinor = 3; e.versionPatch = 5;
|
||||
e.buildNumber = 12340;
|
||||
e.iconColorRGBA = color;
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
add(1, "WoweePvE", R::Normal, R::Medium,
|
||||
packRgba(140, 200, 255),
|
||||
"Cluster realm — Normal PvE rule-set. World PvP "
|
||||
"is opt-in; ganking flagged as harassment.");
|
||||
add(2, "WoweePvP", R::PvP, R::High,
|
||||
packRgba(220, 80, 100),
|
||||
"Cluster realm — PvP rule-set. Cross-faction "
|
||||
"world combat is always-on outside of cities.");
|
||||
add(3, "WoweeRP", R::RP, R::Low,
|
||||
packRgba(180, 100, 240),
|
||||
"Cluster realm — Roleplay. Naming policy "
|
||||
"enforced; in-character chat encouraged.");
|
||||
return c;
|
||||
}
|
||||
|
||||
WoweeRealmList WoweeRealmListLoader::makeMultiExpansion(
|
||||
const std::string& catalogName) {
|
||||
using R = WoweeRealmList;
|
||||
WoweeRealmList c;
|
||||
c.name = catalogName;
|
||||
auto add = [&](uint32_t id, const char* name,
|
||||
uint8_t expansion,
|
||||
uint8_t verMajor, uint8_t verMinor,
|
||||
uint8_t verPatch, uint32_t build,
|
||||
uint32_t color, const char* desc) {
|
||||
R::Entry e;
|
||||
e.realmId = id; e.name = name; e.description = desc;
|
||||
e.address = "logon.wowee.example.com:8085";
|
||||
e.realmType = R::Normal;
|
||||
e.realmCategory = R::Public;
|
||||
e.expansion = expansion;
|
||||
e.population = R::Medium;
|
||||
e.characterCap = 10;
|
||||
e.gmOnly = 0;
|
||||
e.timezone = 8;
|
||||
e.versionMajor = verMajor;
|
||||
e.versionMinor = verMinor;
|
||||
e.versionPatch = verPatch;
|
||||
e.buildNumber = build;
|
||||
e.iconColorRGBA = color;
|
||||
c.entries.push_back(e);
|
||||
};
|
||||
add(1, "Wowee-Vanilla", R::Vanilla, 1, 12, 1, 5875,
|
||||
packRgba(220, 220, 100),
|
||||
"Vanilla 1.12.1 progression realm — original "
|
||||
"60-cap content, no Outland zones.");
|
||||
add(2, "Wowee-TBC", R::TBC, 2, 4, 3, 8606,
|
||||
packRgba(100, 220, 100),
|
||||
"TBC 2.4.3 progression realm — Outland + 70-cap "
|
||||
"content, Sunwell endgame.");
|
||||
add(3, "Wowee-WotLK", R::WotLK, 3, 3, 5, 12340,
|
||||
packRgba(140, 200, 255),
|
||||
"WotLK 3.3.5a progression realm — Northrend + "
|
||||
"80-cap content, ICC endgame.");
|
||||
add(4, "Wowee-Cata", R::Cata, 4, 3, 4, 15595,
|
||||
packRgba(220, 130, 80),
|
||||
"Cata 4.3.4 progression realm — post-Shattering "
|
||||
"world + 85-cap content, DS endgame. Currently "
|
||||
"Beta access only.");
|
||||
// Mark Cata as beta category (override the default
|
||||
// Public set by the lambda).
|
||||
if (!c.entries.empty()) {
|
||||
c.entries.back().realmCategory = R::Beta;
|
||||
c.entries.back().population = R::Low;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
} // namespace pipeline
|
||||
} // namespace wowee
|
||||
Loading…
Add table
Add a link
Reference in a new issue