From 0a5583310ce2630db245ab24f6a5cfa9008ddcfd Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 06:45:09 -0700 Subject: [PATCH] fix(editor): clamp project mapId and zone tile coords on load A hand-edited project.json could carry a 0 or massively-OOR mapId (would break DBC indexing) or tile coords outside 0..63 (would produce garbage ADT filenames). Defaults restore safe values. --- tools/editor/editor_project.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/editor/editor_project.cpp b/tools/editor/editor_project.cpp index 76f666b9..a8ae327a 100644 --- a/tools/editor/editor_project.cpp +++ b/tools/editor/editor_project.cpp @@ -49,6 +49,10 @@ bool EditorProject::load(const std::string& path) { startMapId = j.value("startMapId", 9000u); projectDir = std::filesystem::path(path).parent_path().string(); + // Cap mapId to a reasonable range. mapId 0 is reserved for Eastern + // Kingdoms; >65535 wraps DBC fields. Custom zones live in 9000+. + if (startMapId == 0 || startMapId > 65535) startMapId = 9000; + zones.clear(); if (j.contains("zones") && j["zones"].is_array()) { for (const auto& jz : j["zones"]) { @@ -58,6 +62,10 @@ bool EditorProject::load(const std::string& path) { z.tileY = jz.value("tileY", 32); z.biome = jz.value("biome", ""); z.description = jz.value("description", ""); + // Tile coords valid 0..63 in WoW. Out-of-range values would + // produce garbage ADT filenames or off-map terrain placement. + if (z.tileX < 0 || z.tileX > 63) z.tileX = 32; + if (z.tileY < 0 || z.tileY > 63) z.tileY = 32; if (!z.mapName.empty()) zones.push_back(z); } }