feat(editor): add WCMR (Creature Patrol Path) — 90th open format milestone
Open replacement for AzerothCore's creature_movement / waypoints
SQL tables plus the per-spawn waypoint arrays. Defines named
waypoint paths that creatures patrol along: Stormwind guards
walking the city perimeter, AQ40 trash rotating through the
chamber, ICC patrols circling the spire.
Each entry binds a creatureGuid to a sequence of (x, y, z,
delayMs) waypoints. The pathKind controls cycling behavior
(Loop / OneShot / Reverse / Random) and moveType controls the
locomotion kind (Walk / Run / Fly / Swim) — a flying patrol
ignores ground geometry, a swimming patrol stays underwater.
This is the first open format with truly variable-length
per-entry payload. Earlier formats with multi-slot fields
(WSPR's 8-reagent slots, WPSP's 4-item arrays) used fixed-size
caps padded with zeros. WCMR instead uses an inline
length-prefixed waypoint array — entries can be 4 waypoints or
4000, with the loader advancing through the file by reading the
count first then count*16 bytes of waypoint data. Cap of 64K
waypoints per path keeps a corrupted file from allocating
gigabytes.
pathLengthYards(pathId) is the engine helper that sums segment
distances between consecutive waypoints (closing the loop for
Loop kind). Tested across 12-point and 16-point circular paths
that geometrically resolve to the expected ~25y radius and
~60y radius totals.
Cross-references back to WCRT — creatureGuid points at the
spawned creature instance whose behavior mode follows this
patrol.
Three preset emitters: --gen-cmr (3 small paths showing each
pathKind variant), --gen-cmr-city (4 capital-city guard 6-point
loops with 2.0-2.5s waypoint dwell), --gen-cmr-boss (3 long
raid-zone patrols up to 16 waypoints, demonstrating that
variable-length payloads scale).
Validation enforces id+name+creatureGuid+waypoints presence,
pathKind 0..3, moveType 0..3, no duplicate ids; warns on
1-waypoint paths (creature would idle in place) and Loop with
fewer than 3 waypoints (degenerate — indistinguishable from
Reverse).
This is the 90th open format milestone. Wired through the
cross-format table; WCMR appears in all 18 cross-format
utilities. Format count 89 -> 90; CLI flag count 1048 -> 1053.
2026-05-09 23:38:59 -07:00
|
|
|
#include "cli_creature_patrols_catalog.hpp"
|
|
|
|
|
#include "cli_arg_parse.hpp"
|
|
|
|
|
#include "cli_box_emitter.hpp"
|
|
|
|
|
|
|
|
|
|
#include "pipeline/wowee_creature_patrols.hpp"
|
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
|
|
2026-05-09 23:41:17 -07:00
|
|
|
#include <cctype>
|
feat(editor): add WCMR (Creature Patrol Path) — 90th open format milestone
Open replacement for AzerothCore's creature_movement / waypoints
SQL tables plus the per-spawn waypoint arrays. Defines named
waypoint paths that creatures patrol along: Stormwind guards
walking the city perimeter, AQ40 trash rotating through the
chamber, ICC patrols circling the spire.
Each entry binds a creatureGuid to a sequence of (x, y, z,
delayMs) waypoints. The pathKind controls cycling behavior
(Loop / OneShot / Reverse / Random) and moveType controls the
locomotion kind (Walk / Run / Fly / Swim) — a flying patrol
ignores ground geometry, a swimming patrol stays underwater.
This is the first open format with truly variable-length
per-entry payload. Earlier formats with multi-slot fields
(WSPR's 8-reagent slots, WPSP's 4-item arrays) used fixed-size
caps padded with zeros. WCMR instead uses an inline
length-prefixed waypoint array — entries can be 4 waypoints or
4000, with the loader advancing through the file by reading the
count first then count*16 bytes of waypoint data. Cap of 64K
waypoints per path keeps a corrupted file from allocating
gigabytes.
pathLengthYards(pathId) is the engine helper that sums segment
distances between consecutive waypoints (closing the loop for
Loop kind). Tested across 12-point and 16-point circular paths
that geometrically resolve to the expected ~25y radius and
~60y radius totals.
Cross-references back to WCRT — creatureGuid points at the
spawned creature instance whose behavior mode follows this
patrol.
Three preset emitters: --gen-cmr (3 small paths showing each
pathKind variant), --gen-cmr-city (4 capital-city guard 6-point
loops with 2.0-2.5s waypoint dwell), --gen-cmr-boss (3 long
raid-zone patrols up to 16 waypoints, demonstrating that
variable-length payloads scale).
Validation enforces id+name+creatureGuid+waypoints presence,
pathKind 0..3, moveType 0..3, no duplicate ids; warns on
1-waypoint paths (creature would idle in place) and Loop with
fewer than 3 waypoints (degenerate — indistinguishable from
Reverse).
This is the 90th open format milestone. Wired through the
cross-format table; WCMR appears in all 18 cross-format
utilities. Format count 89 -> 90; CLI flag count 1048 -> 1053.
2026-05-09 23:38:59 -07:00
|
|
|
#include <cstdint>
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
#include <cstring>
|
|
|
|
|
#include <fstream>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace wowee {
|
|
|
|
|
namespace editor {
|
|
|
|
|
namespace cli {
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
std::string stripWcmrExt(std::string base) {
|
|
|
|
|
stripExt(base, ".wcmr");
|
|
|
|
|
return base;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool saveOrError(const wowee::pipeline::WoweeCreaturePatrol& c,
|
|
|
|
|
const std::string& base, const char* cmd) {
|
|
|
|
|
if (!wowee::pipeline::WoweeCreaturePatrolLoader::save(c, base)) {
|
|
|
|
|
std::fprintf(stderr, "%s: failed to save %s.wcmr\n",
|
|
|
|
|
cmd, base.c_str());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void printGenSummary(const wowee::pipeline::WoweeCreaturePatrol& c,
|
|
|
|
|
const std::string& base) {
|
|
|
|
|
size_t totalWp = 0;
|
|
|
|
|
for (const auto& e : c.entries) totalWp += e.waypoints.size();
|
|
|
|
|
std::printf("Wrote %s.wcmr\n", base.c_str());
|
|
|
|
|
std::printf(" catalog : %s\n", c.name.c_str());
|
|
|
|
|
std::printf(" paths : %zu\n", c.entries.size());
|
|
|
|
|
std::printf(" waypoints : %zu (across all paths)\n", totalWp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int handleGenPatrol(int& i, int argc, char** argv) {
|
|
|
|
|
std::string base = argv[++i];
|
|
|
|
|
std::string name = "PatrolPaths";
|
|
|
|
|
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
|
|
|
|
base = stripWcmrExt(base);
|
|
|
|
|
auto c = wowee::pipeline::WoweeCreaturePatrolLoader::makePatrol(name);
|
|
|
|
|
if (!saveOrError(c, base, "gen-cmr")) return 1;
|
|
|
|
|
printGenSummary(c, base);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int handleGenCity(int& i, int argc, char** argv) {
|
|
|
|
|
std::string base = argv[++i];
|
|
|
|
|
std::string name = "CityGuardRoutes";
|
|
|
|
|
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
|
|
|
|
base = stripWcmrExt(base);
|
|
|
|
|
auto c = wowee::pipeline::WoweeCreaturePatrolLoader::makeCity(name);
|
|
|
|
|
if (!saveOrError(c, base, "gen-cmr-city")) return 1;
|
|
|
|
|
printGenSummary(c, base);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int handleGenBoss(int& i, int argc, char** argv) {
|
|
|
|
|
std::string base = argv[++i];
|
|
|
|
|
std::string name = "BossPatrols";
|
|
|
|
|
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
|
|
|
|
base = stripWcmrExt(base);
|
|
|
|
|
auto c = wowee::pipeline::WoweeCreaturePatrolLoader::makeBoss(name);
|
|
|
|
|
if (!saveOrError(c, base, "gen-cmr-boss")) 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 = stripWcmrExt(base);
|
|
|
|
|
if (!wowee::pipeline::WoweeCreaturePatrolLoader::exists(base)) {
|
|
|
|
|
std::fprintf(stderr, "WCMR not found: %s.wcmr\n", base.c_str());
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
auto c = wowee::pipeline::WoweeCreaturePatrolLoader::load(base);
|
|
|
|
|
if (jsonOut) {
|
|
|
|
|
nlohmann::json j;
|
|
|
|
|
j["wcmr"] = base + ".wcmr";
|
|
|
|
|
j["name"] = c.name;
|
|
|
|
|
j["count"] = c.entries.size();
|
|
|
|
|
nlohmann::json arr = nlohmann::json::array();
|
|
|
|
|
for (const auto& e : c.entries) {
|
|
|
|
|
nlohmann::json wpArr = nlohmann::json::array();
|
|
|
|
|
for (const auto& w : e.waypoints) {
|
|
|
|
|
wpArr.push_back({
|
|
|
|
|
{"x", w.x}, {"y", w.y}, {"z", w.z},
|
|
|
|
|
{"delayMs", w.delayMs},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
arr.push_back({
|
|
|
|
|
{"pathId", e.pathId},
|
|
|
|
|
{"name", e.name},
|
|
|
|
|
{"description", e.description},
|
|
|
|
|
{"creatureGuid", e.creatureGuid},
|
|
|
|
|
{"pathKind", e.pathKind},
|
|
|
|
|
{"pathKindName", wowee::pipeline::WoweeCreaturePatrol::pathKindName(e.pathKind)},
|
|
|
|
|
{"moveType", e.moveType},
|
|
|
|
|
{"moveTypeName", wowee::pipeline::WoweeCreaturePatrol::moveTypeName(e.moveType)},
|
|
|
|
|
{"waypointCount", e.waypoints.size()},
|
|
|
|
|
{"pathLengthYards", c.pathLengthYards(e.pathId)},
|
|
|
|
|
{"waypoints", wpArr},
|
|
|
|
|
{"iconColorRGBA", e.iconColorRGBA},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
j["entries"] = arr;
|
|
|
|
|
std::printf("%s\n", j.dump(2).c_str());
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
std::printf("WCMR: %s.wcmr\n", base.c_str());
|
|
|
|
|
std::printf(" catalog : %s\n", c.name.c_str());
|
|
|
|
|
std::printf(" paths : %zu\n", c.entries.size());
|
|
|
|
|
if (c.entries.empty()) return 0;
|
|
|
|
|
std::printf(" id creatureGuid kind move waypoints pathLen(yd) name\n");
|
|
|
|
|
for (const auto& e : c.entries) {
|
|
|
|
|
std::printf(" %4u %8u %-8s %-5s %5zu %8.1f %s\n",
|
|
|
|
|
e.pathId, e.creatureGuid,
|
|
|
|
|
wowee::pipeline::WoweeCreaturePatrol::pathKindName(e.pathKind),
|
|
|
|
|
wowee::pipeline::WoweeCreaturePatrol::moveTypeName(e.moveType),
|
|
|
|
|
e.waypoints.size(),
|
|
|
|
|
c.pathLengthYards(e.pathId),
|
|
|
|
|
e.name.c_str());
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-09 23:41:17 -07:00
|
|
|
int handleExportJson(int& i, int argc, char** argv) {
|
|
|
|
|
std::string base = argv[++i];
|
|
|
|
|
std::string outPath;
|
|
|
|
|
if (parseOptArg(i, argc, argv)) outPath = argv[++i];
|
|
|
|
|
base = stripWcmrExt(base);
|
|
|
|
|
if (!wowee::pipeline::WoweeCreaturePatrolLoader::exists(base)) {
|
|
|
|
|
std::fprintf(stderr,
|
|
|
|
|
"export-wcmr-json: WCMR not found: %s.wcmr\n",
|
|
|
|
|
base.c_str());
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
auto c = wowee::pipeline::WoweeCreaturePatrolLoader::load(base);
|
|
|
|
|
if (outPath.empty()) outPath = base + ".wcmr.json";
|
|
|
|
|
nlohmann::json j;
|
|
|
|
|
j["catalog"] = c.name;
|
|
|
|
|
nlohmann::json arr = nlohmann::json::array();
|
|
|
|
|
for (const auto& e : c.entries) {
|
|
|
|
|
nlohmann::json wpArr = nlohmann::json::array();
|
|
|
|
|
for (const auto& w : e.waypoints) {
|
|
|
|
|
wpArr.push_back({
|
|
|
|
|
{"x", w.x}, {"y", w.y}, {"z", w.z},
|
|
|
|
|
{"delayMs", w.delayMs},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
nlohmann::json je;
|
|
|
|
|
je["pathId"] = e.pathId;
|
|
|
|
|
je["name"] = e.name;
|
|
|
|
|
je["description"] = e.description;
|
|
|
|
|
je["creatureGuid"] = e.creatureGuid;
|
|
|
|
|
je["pathKind"] = e.pathKind;
|
|
|
|
|
je["pathKindName"] =
|
|
|
|
|
wowee::pipeline::WoweeCreaturePatrol::pathKindName(e.pathKind);
|
|
|
|
|
je["moveType"] = e.moveType;
|
|
|
|
|
je["moveTypeName"] =
|
|
|
|
|
wowee::pipeline::WoweeCreaturePatrol::moveTypeName(e.moveType);
|
|
|
|
|
je["waypoints"] = wpArr;
|
|
|
|
|
je["iconColorRGBA"] = e.iconColorRGBA;
|
|
|
|
|
arr.push_back(je);
|
|
|
|
|
}
|
|
|
|
|
j["entries"] = arr;
|
|
|
|
|
std::ofstream os(outPath);
|
|
|
|
|
if (!os) {
|
|
|
|
|
std::fprintf(stderr,
|
|
|
|
|
"export-wcmr-json: failed to open %s for write\n",
|
|
|
|
|
outPath.c_str());
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
os << j.dump(2) << "\n";
|
|
|
|
|
std::printf("Wrote %s\n", outPath.c_str());
|
|
|
|
|
std::printf(" catalog : %s\n", c.name.c_str());
|
|
|
|
|
std::printf(" paths : %zu\n", c.entries.size());
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t parsePathKindToken(const nlohmann::json& jv, uint8_t fallback) {
|
|
|
|
|
if (jv.is_number_integer() || jv.is_number_unsigned()) {
|
|
|
|
|
int v = jv.get<int>();
|
|
|
|
|
if (v < 0 || v > wowee::pipeline::WoweeCreaturePatrol::Random)
|
|
|
|
|
return fallback;
|
|
|
|
|
return static_cast<uint8_t>(v);
|
|
|
|
|
}
|
|
|
|
|
if (jv.is_string()) {
|
|
|
|
|
std::string s = jv.get<std::string>();
|
|
|
|
|
for (auto& ch : s) ch = static_cast<char>(std::tolower(ch));
|
|
|
|
|
if (s == "loop") return wowee::pipeline::WoweeCreaturePatrol::Loop;
|
|
|
|
|
if (s == "one-shot" ||
|
|
|
|
|
s == "oneshot") return wowee::pipeline::WoweeCreaturePatrol::OneShot;
|
|
|
|
|
if (s == "reverse") return wowee::pipeline::WoweeCreaturePatrol::Reverse;
|
|
|
|
|
if (s == "random") return wowee::pipeline::WoweeCreaturePatrol::Random;
|
|
|
|
|
}
|
|
|
|
|
return fallback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t parseMoveTypeToken(const nlohmann::json& jv, uint8_t fallback) {
|
|
|
|
|
if (jv.is_number_integer() || jv.is_number_unsigned()) {
|
|
|
|
|
int v = jv.get<int>();
|
|
|
|
|
if (v < 0 || v > wowee::pipeline::WoweeCreaturePatrol::Swim)
|
|
|
|
|
return fallback;
|
|
|
|
|
return static_cast<uint8_t>(v);
|
|
|
|
|
}
|
|
|
|
|
if (jv.is_string()) {
|
|
|
|
|
std::string s = jv.get<std::string>();
|
|
|
|
|
for (auto& ch : s) ch = static_cast<char>(std::tolower(ch));
|
|
|
|
|
if (s == "walk") return wowee::pipeline::WoweeCreaturePatrol::Walk;
|
|
|
|
|
if (s == "run") return wowee::pipeline::WoweeCreaturePatrol::Run;
|
|
|
|
|
if (s == "fly") return wowee::pipeline::WoweeCreaturePatrol::Fly;
|
|
|
|
|
if (s == "swim") return wowee::pipeline::WoweeCreaturePatrol::Swim;
|
|
|
|
|
}
|
|
|
|
|
return fallback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int handleImportJson(int& i, int argc, char** argv) {
|
|
|
|
|
std::string jsonPath = argv[++i];
|
|
|
|
|
std::string outBase;
|
|
|
|
|
if (parseOptArg(i, argc, argv)) outBase = argv[++i];
|
|
|
|
|
std::ifstream is(jsonPath);
|
|
|
|
|
if (!is) {
|
|
|
|
|
std::fprintf(stderr,
|
|
|
|
|
"import-wcmr-json: failed to open %s\n", jsonPath.c_str());
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
nlohmann::json j;
|
|
|
|
|
try {
|
|
|
|
|
is >> j;
|
|
|
|
|
} catch (const std::exception& ex) {
|
|
|
|
|
std::fprintf(stderr,
|
|
|
|
|
"import-wcmr-json: parse error in %s: %s\n",
|
|
|
|
|
jsonPath.c_str(), ex.what());
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
wowee::pipeline::WoweeCreaturePatrol c;
|
|
|
|
|
if (j.contains("catalog") && j["catalog"].is_string())
|
|
|
|
|
c.name = j["catalog"].get<std::string>();
|
|
|
|
|
if (j.contains("entries") && j["entries"].is_array()) {
|
|
|
|
|
for (const auto& je : j["entries"]) {
|
|
|
|
|
wowee::pipeline::WoweeCreaturePatrol::Entry e;
|
|
|
|
|
if (je.contains("pathId")) e.pathId = je["pathId"].get<uint32_t>();
|
|
|
|
|
if (je.contains("name")) e.name = je["name"].get<std::string>();
|
|
|
|
|
if (je.contains("description")) e.description = je["description"].get<std::string>();
|
|
|
|
|
if (je.contains("creatureGuid")) e.creatureGuid = je["creatureGuid"].get<uint32_t>();
|
|
|
|
|
uint8_t kind = wowee::pipeline::WoweeCreaturePatrol::Loop;
|
|
|
|
|
if (je.contains("pathKind"))
|
|
|
|
|
kind = parsePathKindToken(je["pathKind"], kind);
|
|
|
|
|
else if (je.contains("pathKindName"))
|
|
|
|
|
kind = parsePathKindToken(je["pathKindName"], kind);
|
|
|
|
|
e.pathKind = kind;
|
|
|
|
|
uint8_t move = wowee::pipeline::WoweeCreaturePatrol::Walk;
|
|
|
|
|
if (je.contains("moveType"))
|
|
|
|
|
move = parseMoveTypeToken(je["moveType"], move);
|
|
|
|
|
else if (je.contains("moveTypeName"))
|
|
|
|
|
move = parseMoveTypeToken(je["moveTypeName"], move);
|
|
|
|
|
e.moveType = move;
|
|
|
|
|
if (je.contains("waypoints") && je["waypoints"].is_array()) {
|
|
|
|
|
for (const auto& wj : je["waypoints"]) {
|
|
|
|
|
wowee::pipeline::WoweeCreaturePatrol::Waypoint w;
|
|
|
|
|
if (wj.contains("x")) w.x = wj["x"].get<float>();
|
|
|
|
|
if (wj.contains("y")) w.y = wj["y"].get<float>();
|
|
|
|
|
if (wj.contains("z")) w.z = wj["z"].get<float>();
|
|
|
|
|
if (wj.contains("delayMs")) w.delayMs = wj["delayMs"].get<uint32_t>();
|
|
|
|
|
e.waypoints.push_back(w);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (je.contains("iconColorRGBA"))
|
|
|
|
|
e.iconColorRGBA = je["iconColorRGBA"].get<uint32_t>();
|
|
|
|
|
c.entries.push_back(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (outBase.empty()) {
|
|
|
|
|
outBase = jsonPath;
|
|
|
|
|
const std::string suffix1 = ".wcmr.json";
|
|
|
|
|
const std::string suffix2 = ".json";
|
|
|
|
|
if (outBase.size() >= suffix1.size() &&
|
|
|
|
|
outBase.compare(outBase.size() - suffix1.size(),
|
|
|
|
|
suffix1.size(), suffix1) == 0) {
|
|
|
|
|
outBase.resize(outBase.size() - suffix1.size());
|
|
|
|
|
} else if (outBase.size() >= suffix2.size() &&
|
|
|
|
|
outBase.compare(outBase.size() - suffix2.size(),
|
|
|
|
|
suffix2.size(), suffix2) == 0) {
|
|
|
|
|
outBase.resize(outBase.size() - suffix2.size());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
outBase = stripWcmrExt(outBase);
|
|
|
|
|
if (!wowee::pipeline::WoweeCreaturePatrolLoader::save(c, outBase)) {
|
|
|
|
|
std::fprintf(stderr,
|
|
|
|
|
"import-wcmr-json: failed to save %s.wcmr\n",
|
|
|
|
|
outBase.c_str());
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
std::printf("Wrote %s.wcmr\n", outBase.c_str());
|
|
|
|
|
std::printf(" catalog : %s\n", c.name.c_str());
|
|
|
|
|
std::printf(" paths : %zu\n", c.entries.size());
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
feat(editor): add WCMR (Creature Patrol Path) — 90th open format milestone
Open replacement for AzerothCore's creature_movement / waypoints
SQL tables plus the per-spawn waypoint arrays. Defines named
waypoint paths that creatures patrol along: Stormwind guards
walking the city perimeter, AQ40 trash rotating through the
chamber, ICC patrols circling the spire.
Each entry binds a creatureGuid to a sequence of (x, y, z,
delayMs) waypoints. The pathKind controls cycling behavior
(Loop / OneShot / Reverse / Random) and moveType controls the
locomotion kind (Walk / Run / Fly / Swim) — a flying patrol
ignores ground geometry, a swimming patrol stays underwater.
This is the first open format with truly variable-length
per-entry payload. Earlier formats with multi-slot fields
(WSPR's 8-reagent slots, WPSP's 4-item arrays) used fixed-size
caps padded with zeros. WCMR instead uses an inline
length-prefixed waypoint array — entries can be 4 waypoints or
4000, with the loader advancing through the file by reading the
count first then count*16 bytes of waypoint data. Cap of 64K
waypoints per path keeps a corrupted file from allocating
gigabytes.
pathLengthYards(pathId) is the engine helper that sums segment
distances between consecutive waypoints (closing the loop for
Loop kind). Tested across 12-point and 16-point circular paths
that geometrically resolve to the expected ~25y radius and
~60y radius totals.
Cross-references back to WCRT — creatureGuid points at the
spawned creature instance whose behavior mode follows this
patrol.
Three preset emitters: --gen-cmr (3 small paths showing each
pathKind variant), --gen-cmr-city (4 capital-city guard 6-point
loops with 2.0-2.5s waypoint dwell), --gen-cmr-boss (3 long
raid-zone patrols up to 16 waypoints, demonstrating that
variable-length payloads scale).
Validation enforces id+name+creatureGuid+waypoints presence,
pathKind 0..3, moveType 0..3, no duplicate ids; warns on
1-waypoint paths (creature would idle in place) and Loop with
fewer than 3 waypoints (degenerate — indistinguishable from
Reverse).
This is the 90th open format milestone. Wired through the
cross-format table; WCMR appears in all 18 cross-format
utilities. Format count 89 -> 90; CLI flag count 1048 -> 1053.
2026-05-09 23:38:59 -07:00
|
|
|
int handleValidate(int& i, int argc, char** argv) {
|
|
|
|
|
std::string base = argv[++i];
|
|
|
|
|
bool jsonOut = consumeJsonFlag(i, argc, argv);
|
|
|
|
|
base = stripWcmrExt(base);
|
|
|
|
|
if (!wowee::pipeline::WoweeCreaturePatrolLoader::exists(base)) {
|
|
|
|
|
std::fprintf(stderr,
|
|
|
|
|
"validate-wcmr: WCMR not found: %s.wcmr\n", base.c_str());
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
auto c = wowee::pipeline::WoweeCreaturePatrolLoader::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.pathId);
|
|
|
|
|
if (!e.name.empty()) ctx += " " + e.name;
|
|
|
|
|
ctx += ")";
|
|
|
|
|
if (e.pathId == 0)
|
|
|
|
|
errors.push_back(ctx + ": pathId is 0");
|
|
|
|
|
if (e.name.empty())
|
|
|
|
|
errors.push_back(ctx + ": name is empty");
|
|
|
|
|
if (e.creatureGuid == 0)
|
|
|
|
|
errors.push_back(ctx +
|
|
|
|
|
": creatureGuid is 0 — path is unbound to any spawn");
|
|
|
|
|
if (e.pathKind > wowee::pipeline::WoweeCreaturePatrol::Random) {
|
|
|
|
|
errors.push_back(ctx + ": pathKind " +
|
|
|
|
|
std::to_string(e.pathKind) + " not in 0..3");
|
|
|
|
|
}
|
|
|
|
|
if (e.moveType > wowee::pipeline::WoweeCreaturePatrol::Swim) {
|
|
|
|
|
errors.push_back(ctx + ": moveType " +
|
|
|
|
|
std::to_string(e.moveType) + " not in 0..3");
|
|
|
|
|
}
|
|
|
|
|
if (e.waypoints.empty())
|
|
|
|
|
errors.push_back(ctx + ": no waypoints — path has nothing to walk");
|
|
|
|
|
if (e.waypoints.size() == 1)
|
|
|
|
|
warnings.push_back(ctx +
|
|
|
|
|
": only 1 waypoint — creature will idle in place");
|
|
|
|
|
// Loop with fewer than 3 waypoints is degenerate
|
|
|
|
|
// (back and forth between 2 points isn't a loop).
|
|
|
|
|
if (e.pathKind == wowee::pipeline::WoweeCreaturePatrol::Loop &&
|
|
|
|
|
e.waypoints.size() < 3) {
|
|
|
|
|
warnings.push_back(ctx +
|
|
|
|
|
": Loop with " +
|
|
|
|
|
std::to_string(e.waypoints.size()) +
|
|
|
|
|
" waypoints — fewer than 3 makes Loop "
|
|
|
|
|
"indistinguishable from Reverse");
|
|
|
|
|
}
|
|
|
|
|
for (uint32_t prev : idsSeen) {
|
|
|
|
|
if (prev == e.pathId) {
|
|
|
|
|
errors.push_back(ctx + ": duplicate pathId");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
idsSeen.push_back(e.pathId);
|
|
|
|
|
}
|
|
|
|
|
bool ok = errors.empty();
|
|
|
|
|
if (jsonOut) {
|
|
|
|
|
nlohmann::json j;
|
|
|
|
|
j["wcmr"] = base + ".wcmr";
|
|
|
|
|
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-wcmr: %s.wcmr\n", base.c_str());
|
|
|
|
|
if (ok && warnings.empty()) {
|
|
|
|
|
std::printf(" OK — %zu paths, all pathIds 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 handleCreaturePatrolsCatalog(int& i, int argc, char** argv,
|
|
|
|
|
int& outRc) {
|
|
|
|
|
if (std::strcmp(argv[i], "--gen-cmr") == 0 && i + 1 < argc) {
|
|
|
|
|
outRc = handleGenPatrol(i, argc, argv); return true;
|
|
|
|
|
}
|
|
|
|
|
if (std::strcmp(argv[i], "--gen-cmr-city") == 0 && i + 1 < argc) {
|
|
|
|
|
outRc = handleGenCity(i, argc, argv); return true;
|
|
|
|
|
}
|
|
|
|
|
if (std::strcmp(argv[i], "--gen-cmr-boss") == 0 && i + 1 < argc) {
|
|
|
|
|
outRc = handleGenBoss(i, argc, argv); return true;
|
|
|
|
|
}
|
|
|
|
|
if (std::strcmp(argv[i], "--info-wcmr") == 0 && i + 1 < argc) {
|
|
|
|
|
outRc = handleInfo(i, argc, argv); return true;
|
|
|
|
|
}
|
|
|
|
|
if (std::strcmp(argv[i], "--validate-wcmr") == 0 && i + 1 < argc) {
|
|
|
|
|
outRc = handleValidate(i, argc, argv); return true;
|
|
|
|
|
}
|
2026-05-09 23:41:17 -07:00
|
|
|
if (std::strcmp(argv[i], "--export-wcmr-json") == 0 && i + 1 < argc) {
|
|
|
|
|
outRc = handleExportJson(i, argc, argv); return true;
|
|
|
|
|
}
|
|
|
|
|
if (std::strcmp(argv[i], "--import-wcmr-json") == 0 && i + 1 < argc) {
|
|
|
|
|
outRc = handleImportJson(i, argc, argv); return true;
|
|
|
|
|
}
|
feat(editor): add WCMR (Creature Patrol Path) — 90th open format milestone
Open replacement for AzerothCore's creature_movement / waypoints
SQL tables plus the per-spawn waypoint arrays. Defines named
waypoint paths that creatures patrol along: Stormwind guards
walking the city perimeter, AQ40 trash rotating through the
chamber, ICC patrols circling the spire.
Each entry binds a creatureGuid to a sequence of (x, y, z,
delayMs) waypoints. The pathKind controls cycling behavior
(Loop / OneShot / Reverse / Random) and moveType controls the
locomotion kind (Walk / Run / Fly / Swim) — a flying patrol
ignores ground geometry, a swimming patrol stays underwater.
This is the first open format with truly variable-length
per-entry payload. Earlier formats with multi-slot fields
(WSPR's 8-reagent slots, WPSP's 4-item arrays) used fixed-size
caps padded with zeros. WCMR instead uses an inline
length-prefixed waypoint array — entries can be 4 waypoints or
4000, with the loader advancing through the file by reading the
count first then count*16 bytes of waypoint data. Cap of 64K
waypoints per path keeps a corrupted file from allocating
gigabytes.
pathLengthYards(pathId) is the engine helper that sums segment
distances between consecutive waypoints (closing the loop for
Loop kind). Tested across 12-point and 16-point circular paths
that geometrically resolve to the expected ~25y radius and
~60y radius totals.
Cross-references back to WCRT — creatureGuid points at the
spawned creature instance whose behavior mode follows this
patrol.
Three preset emitters: --gen-cmr (3 small paths showing each
pathKind variant), --gen-cmr-city (4 capital-city guard 6-point
loops with 2.0-2.5s waypoint dwell), --gen-cmr-boss (3 long
raid-zone patrols up to 16 waypoints, demonstrating that
variable-length payloads scale).
Validation enforces id+name+creatureGuid+waypoints presence,
pathKind 0..3, moveType 0..3, no duplicate ids; warns on
1-waypoint paths (creature would idle in place) and Loop with
fewer than 3 waypoints (degenerate — indistinguishable from
Reverse).
This is the 90th open format milestone. Wired through the
cross-format table; WCMR appears in all 18 cross-format
utilities. Format count 89 -> 90; CLI flag count 1048 -> 1053.
2026-05-09 23:38:59 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace cli
|
|
|
|
|
} // namespace editor
|
|
|
|
|
} // namespace wowee
|