From 891bb711a0151497f1190d0d36b5cca68dce01c1 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 6 May 2026 07:36:32 -0700 Subject: [PATCH] fix(editor): bound tile coords + NaN-guard baseHeight in createNewTerrain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same defensive validation as loadADT — out-of-range tile coords would generate broken save paths. Also guards against a NaN baseHeight slider (would propagate into every terrain vertex). --- tools/editor/editor_app.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/editor/editor_app.cpp b/tools/editor/editor_app.cpp index 443ff925..66817109 100644 --- a/tools/editor/editor_app.cpp +++ b/tools/editor/editor_app.cpp @@ -1038,6 +1038,12 @@ void EditorApp::loadADT(const std::string& mapName, int tileX, int tileY) { } void EditorApp::createNewTerrain(const std::string& mapName, int tileX, int tileY, float baseHeight, Biome biome) { + if (tileX < 0 || tileX > 63 || tileY < 0 || tileY > 63) { + LOG_ERROR("createNewTerrain rejected: tile (", tileX, ",", tileY, + ") out of valid 0..63 range"); + return; + } + if (!std::isfinite(baseHeight)) baseHeight = 0.0f; terrain_ = TerrainEditor::createBlankTerrain(tileX, tileY, baseHeight, biome); // Clear all previous state clearAllObjects();