mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-10 02:53:51 +00:00
Novel open replacement for Blizzard's TaxiNodes.dbc +
TaxiPath.dbc + TaxiPathNode.dbc. The 24th open format
added to the editor.
Defines the flight-master network: a set of named nodes
(positions on the world map) plus the paths between them
(sequences of waypoints with per-segment delay and a
per-path gold cost). The same file holds both node and
path lists — flat arrays keyed by id, with intra-format
references from path.fromNodeId / toNodeId to node.nodeId.
Cross-references:
WCRT.entry (with FlightMaster npcFlag) ~= WTAX.nodeId
(matched by world
position; flight
master NPCs stand
at their nodes)
WTAX.path.fromNodeId / toNodeId -> WTAX.entry.nodeId
(intra-format graph)
Format:
• magic "WTAX", version 1, little-endian
• nodes (each): nodeId / mapId / name / iconPath /
position / faction restrictions
• paths (each): pathId / from+toNodeId / moneyCostCopper /
waypoints[] each with position + per-waypoint delaySec
API: WoweeTaxiLoader::save / load / exists +
WoweeTaxi::findNode / findPath / findPathBetween.
Three preset emitters showcase different graph shapes:
• makeStarter — 2 nodes + 2 paths (round-trip)
• makeRegion — 4 nodes at a 500m square + 4-path
directed ring (NW->NE->SE->SW->NW)
• makeContinent — 6 nodes hub-spoke + 3 perimeter
shortcuts; intermediate waypoints
climb to altitude 120m for visual
arc effect
CLI added (5 flags, 564 documented total now):
--gen-taxi / --gen-taxi-region / --gen-taxi-continent
--info-wtax / --validate-wtax
Validator catches: nodeId/pathId=0 + duplicates, empty node
name, non-finite positions, fromNodeId == toNodeId
(self-loop path), path references to non-existent nodes
(intra-format cross-reference resolution), negative
waypoint delays.
301 lines
10 KiB
C++
301 lines
10 KiB
C++
#include "cli_taxi_catalog.hpp"
|
|
#include "cli_arg_parse.hpp"
|
|
#include "cli_box_emitter.hpp"
|
|
|
|
#include "pipeline/wowee_taxi.hpp"
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include <cmath>
|
|
#include <cstdint>
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
#include <fstream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace wowee {
|
|
namespace editor {
|
|
namespace cli {
|
|
|
|
namespace {
|
|
|
|
std::string stripWtaxExt(std::string base) {
|
|
stripExt(base, ".wtax");
|
|
return base;
|
|
}
|
|
|
|
bool saveOrError(const wowee::pipeline::WoweeTaxi& c,
|
|
const std::string& base, const char* cmd) {
|
|
if (!wowee::pipeline::WoweeTaxiLoader::save(c, base)) {
|
|
std::fprintf(stderr, "%s: failed to save %s.wtax\n",
|
|
cmd, base.c_str());
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
uint32_t totalWaypoints(const wowee::pipeline::WoweeTaxi& c) {
|
|
uint32_t n = 0;
|
|
for (const auto& p : c.paths) n += static_cast<uint32_t>(p.waypoints.size());
|
|
return n;
|
|
}
|
|
|
|
void printGenSummary(const wowee::pipeline::WoweeTaxi& c,
|
|
const std::string& base) {
|
|
std::printf("Wrote %s.wtax\n", base.c_str());
|
|
std::printf(" catalog : %s\n", c.name.c_str());
|
|
std::printf(" nodes : %zu\n", c.nodes.size());
|
|
std::printf(" paths : %zu (%u waypoints total)\n",
|
|
c.paths.size(), totalWaypoints(c));
|
|
}
|
|
|
|
int handleGenStarter(int& i, int argc, char** argv) {
|
|
std::string base = argv[++i];
|
|
std::string name = "StarterTaxi";
|
|
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
|
base = stripWtaxExt(base);
|
|
auto c = wowee::pipeline::WoweeTaxiLoader::makeStarter(name);
|
|
if (!saveOrError(c, base, "gen-taxi")) return 1;
|
|
printGenSummary(c, base);
|
|
return 0;
|
|
}
|
|
|
|
int handleGenRegion(int& i, int argc, char** argv) {
|
|
std::string base = argv[++i];
|
|
std::string name = "RegionTaxi";
|
|
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
|
base = stripWtaxExt(base);
|
|
auto c = wowee::pipeline::WoweeTaxiLoader::makeRegion(name);
|
|
if (!saveOrError(c, base, "gen-taxi-region")) return 1;
|
|
printGenSummary(c, base);
|
|
return 0;
|
|
}
|
|
|
|
int handleGenContinent(int& i, int argc, char** argv) {
|
|
std::string base = argv[++i];
|
|
std::string name = "ContinentTaxi";
|
|
if (parseOptArg(i, argc, argv)) name = argv[++i];
|
|
base = stripWtaxExt(base);
|
|
auto c = wowee::pipeline::WoweeTaxiLoader::makeContinent(name);
|
|
if (!saveOrError(c, base, "gen-taxi-continent")) 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 = stripWtaxExt(base);
|
|
if (!wowee::pipeline::WoweeTaxiLoader::exists(base)) {
|
|
std::fprintf(stderr, "WTAX not found: %s.wtax\n", base.c_str());
|
|
return 1;
|
|
}
|
|
auto c = wowee::pipeline::WoweeTaxiLoader::load(base);
|
|
if (jsonOut) {
|
|
nlohmann::json j;
|
|
j["wtax"] = base + ".wtax";
|
|
j["name"] = c.name;
|
|
j["nodeCount"] = c.nodes.size();
|
|
j["pathCount"] = c.paths.size();
|
|
j["totalWaypoints"] = totalWaypoints(c);
|
|
nlohmann::json na = nlohmann::json::array();
|
|
for (const auto& n : c.nodes) {
|
|
na.push_back({
|
|
{"nodeId", n.nodeId},
|
|
{"mapId", n.mapId},
|
|
{"name", n.name},
|
|
{"iconPath", n.iconPath},
|
|
{"position", {n.position.x, n.position.y, n.position.z}},
|
|
{"factionAlliance", n.factionAlliance},
|
|
{"factionHorde", n.factionHorde},
|
|
});
|
|
}
|
|
j["nodes"] = na;
|
|
nlohmann::json pa = nlohmann::json::array();
|
|
for (const auto& p : c.paths) {
|
|
nlohmann::json wpa = nlohmann::json::array();
|
|
for (const auto& w : p.waypoints) {
|
|
wpa.push_back({
|
|
{"position", {w.position.x, w.position.y, w.position.z}},
|
|
{"delaySec", w.delaySec},
|
|
});
|
|
}
|
|
pa.push_back({
|
|
{"pathId", p.pathId},
|
|
{"fromNodeId", p.fromNodeId},
|
|
{"toNodeId", p.toNodeId},
|
|
{"moneyCostCopper", p.moneyCostCopper},
|
|
{"waypoints", wpa},
|
|
});
|
|
}
|
|
j["paths"] = pa;
|
|
std::printf("%s\n", j.dump(2).c_str());
|
|
return 0;
|
|
}
|
|
std::printf("WTAX: %s.wtax\n", base.c_str());
|
|
std::printf(" catalog : %s\n", c.name.c_str());
|
|
std::printf(" nodes : %zu\n", c.nodes.size());
|
|
std::printf(" paths : %zu (%u waypoints total)\n",
|
|
c.paths.size(), totalWaypoints(c));
|
|
if (!c.nodes.empty()) {
|
|
std::printf("\n Nodes:\n");
|
|
std::printf(" id map pos (x, y, z) name\n");
|
|
for (const auto& n : c.nodes) {
|
|
std::printf(" %4u %3u (%7.1f,%6.1f,%7.1f) %s\n",
|
|
n.nodeId, n.mapId,
|
|
n.position.x, n.position.y, n.position.z,
|
|
n.name.c_str());
|
|
}
|
|
}
|
|
if (!c.paths.empty()) {
|
|
std::printf("\n Paths:\n");
|
|
std::printf(" id from -> to cost waypoints\n");
|
|
for (const auto& p : c.paths) {
|
|
std::printf(" %4u %4u -> %-4u %5uc %zu\n",
|
|
p.pathId, p.fromNodeId, p.toNodeId,
|
|
p.moneyCostCopper, p.waypoints.size());
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int handleValidate(int& i, int argc, char** argv) {
|
|
std::string base = argv[++i];
|
|
bool jsonOut = consumeJsonFlag(i, argc, argv);
|
|
base = stripWtaxExt(base);
|
|
if (!wowee::pipeline::WoweeTaxiLoader::exists(base)) {
|
|
std::fprintf(stderr,
|
|
"validate-wtax: WTAX not found: %s.wtax\n", base.c_str());
|
|
return 1;
|
|
}
|
|
auto c = wowee::pipeline::WoweeTaxiLoader::load(base);
|
|
std::vector<std::string> errors;
|
|
std::vector<std::string> warnings;
|
|
if (c.nodes.empty()) {
|
|
warnings.push_back("catalog has zero nodes");
|
|
}
|
|
std::vector<uint32_t> nodeIdsSeen;
|
|
for (size_t k = 0; k < c.nodes.size(); ++k) {
|
|
const auto& n = c.nodes[k];
|
|
std::string ctx = "node " + std::to_string(k) +
|
|
" (id=" + std::to_string(n.nodeId);
|
|
if (!n.name.empty()) ctx += " " + n.name;
|
|
ctx += ")";
|
|
if (n.nodeId == 0) {
|
|
errors.push_back(ctx + ": nodeId is 0");
|
|
}
|
|
if (n.name.empty()) {
|
|
errors.push_back(ctx + ": name is empty");
|
|
}
|
|
if (!std::isfinite(n.position.x) ||
|
|
!std::isfinite(n.position.y) ||
|
|
!std::isfinite(n.position.z)) {
|
|
errors.push_back(ctx + ": position not finite");
|
|
}
|
|
for (uint32_t prev : nodeIdsSeen) {
|
|
if (prev == n.nodeId) {
|
|
errors.push_back(ctx + ": duplicate nodeId");
|
|
break;
|
|
}
|
|
}
|
|
nodeIdsSeen.push_back(n.nodeId);
|
|
}
|
|
std::vector<uint32_t> pathIdsSeen;
|
|
for (size_t k = 0; k < c.paths.size(); ++k) {
|
|
const auto& p = c.paths[k];
|
|
std::string ctx = "path " + std::to_string(k) +
|
|
" (id=" + std::to_string(p.pathId) + ")";
|
|
if (p.pathId == 0) {
|
|
errors.push_back(ctx + ": pathId is 0");
|
|
}
|
|
if (p.fromNodeId == p.toNodeId) {
|
|
errors.push_back(ctx +
|
|
": fromNodeId == toNodeId (path goes nowhere)");
|
|
}
|
|
if (!c.findNode(p.fromNodeId)) {
|
|
errors.push_back(ctx + ": fromNodeId " +
|
|
std::to_string(p.fromNodeId) + " does not exist");
|
|
}
|
|
if (!c.findNode(p.toNodeId)) {
|
|
errors.push_back(ctx + ": toNodeId " +
|
|
std::to_string(p.toNodeId) + " does not exist");
|
|
}
|
|
if (p.waypoints.empty()) {
|
|
warnings.push_back(ctx +
|
|
": no waypoints (gryphon teleports instantly)");
|
|
}
|
|
for (size_t wi = 0; wi < p.waypoints.size(); ++wi) {
|
|
const auto& w = p.waypoints[wi];
|
|
if (!std::isfinite(w.position.x) ||
|
|
!std::isfinite(w.position.y) ||
|
|
!std::isfinite(w.position.z) ||
|
|
!std::isfinite(w.delaySec)) {
|
|
errors.push_back(ctx + " waypoint " +
|
|
std::to_string(wi) + ": position/delay not finite");
|
|
}
|
|
if (w.delaySec < 0) {
|
|
errors.push_back(ctx + " waypoint " +
|
|
std::to_string(wi) + ": delaySec is negative");
|
|
}
|
|
}
|
|
for (uint32_t prev : pathIdsSeen) {
|
|
if (prev == p.pathId) {
|
|
errors.push_back(ctx + ": duplicate pathId");
|
|
break;
|
|
}
|
|
}
|
|
pathIdsSeen.push_back(p.pathId);
|
|
}
|
|
bool ok = errors.empty();
|
|
if (jsonOut) {
|
|
nlohmann::json j;
|
|
j["wtax"] = base + ".wtax";
|
|
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-wtax: %s.wtax\n", base.c_str());
|
|
if (ok && warnings.empty()) {
|
|
std::printf(" OK — %zu nodes, %zu paths, %u waypoints, all IDs unique\n",
|
|
c.nodes.size(), c.paths.size(), totalWaypoints(c));
|
|
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 handleTaxiCatalog(int& i, int argc, char** argv, int& outRc) {
|
|
if (std::strcmp(argv[i], "--gen-taxi") == 0 && i + 1 < argc) {
|
|
outRc = handleGenStarter(i, argc, argv); return true;
|
|
}
|
|
if (std::strcmp(argv[i], "--gen-taxi-region") == 0 && i + 1 < argc) {
|
|
outRc = handleGenRegion(i, argc, argv); return true;
|
|
}
|
|
if (std::strcmp(argv[i], "--gen-taxi-continent") == 0 && i + 1 < argc) {
|
|
outRc = handleGenContinent(i, argc, argv); return true;
|
|
}
|
|
if (std::strcmp(argv[i], "--info-wtax") == 0 && i + 1 < argc) {
|
|
outRc = handleInfo(i, argc, argv); return true;
|
|
}
|
|
if (std::strcmp(argv[i], "--validate-wtax") == 0 && i + 1 < argc) {
|
|
outRc = handleValidate(i, argc, argv); return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
} // namespace cli
|
|
} // namespace editor
|
|
} // namespace wowee
|