From fa631a45d60f143c3638048b09e4ce135984df80 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 02:52:46 -0700 Subject: [PATCH] refactor(sql): use core::coords::renderToCanonical for render->WoW swap Replaces hand-written x/y swap with the canonical helper from include/core/coordinates.hpp so the conversion stays in sync if the coord convention changes. --- tools/editor/sql_exporter.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/editor/sql_exporter.cpp b/tools/editor/sql_exporter.cpp index c7fcaabe..71c633aa 100644 --- a/tools/editor/sql_exporter.cpp +++ b/tools/editor/sql_exporter.cpp @@ -1,4 +1,5 @@ #include "sql_exporter.hpp" +#include "core/coordinates.hpp" #include "core/logger.hpp" #include #include @@ -88,12 +89,12 @@ bool SQLExporter::exportCreatures(const std::vector& spawns, if (s.behavior == CreatureBehavior::Wander) movementType = 1; if (s.behavior == CreatureBehavior::Patrol) movementType = 2; - // Editor stores positions in render coords (renderX=wowY, renderY=wowX, - // renderZ=wowZ) but AzerothCore creature.position_x/y are WoW canonical - // (X=north-south, Y=west-east). Swap x/y on the way out. - const float wowX = s.position.y; - const float wowY = s.position.x; - const float wowZ = s.position.z; + // Editor stores positions in render coords; AzerothCore expects WoW + // canonical (X=north, Y=west). renderToCanonical handles the swap. + const glm::vec3 wow = core::coords::renderToCanonical(s.position); + const float wowX = wow.x; + const float wowY = wow.y; + const float wowZ = wow.z; // AzerothCore expects orientation in radians from +X (north). Editor's // orientation is in degrees from +renderX (west). Convert via: // wowYaw = π/2 - editorYaw @@ -136,10 +137,10 @@ bool SQLExporter::exportCreatures(const std::vector& spawns, for (size_t pi = 0; pi < s.patrolPath.size(); pi++) { const auto& wp = s.patrolPath[pi]; - // Same render -> WoW canonical swap as the spawn position. - const float wpWowX = wp.position.y; - const float wpWowY = wp.position.x; - const float wpWowZ = wp.position.z; + const glm::vec3 wpWow = core::coords::renderToCanonical(wp.position); + const float wpWowX = wpWow.x; + const float wpWowY = wpWow.y; + const float wpWowZ = wpWow.z; f << "INSERT INTO `waypoint_data` " << "(`id`, `point`, `position_x`, `position_y`, `position_z`, `delay`) VALUES (" << pathId << ", " << (pi + 1) << ", "