From 64c33194879779044c9506c072f6c64259ab2f82 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 31 Mar 2026 08:37:02 +0000 Subject: [PATCH] fix: guard against division by zero in GetSceneIDFromPosition Agent-Logs-Url: https://github.com/DarkflameUniverse/DarkflameServer/sessions/8e30d854-e439-4b25-bb15-891ba389f0fd Co-authored-by: aronwk-aaron <26027722+aronwk-aaron@users.noreply.github.com> --- dZoneManager/dZoneManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dZoneManager/dZoneManager.cpp b/dZoneManager/dZoneManager.cpp index 9eb21467..f4df5ccb 100644 --- a/dZoneManager/dZoneManager.cpp +++ b/dZoneManager/dZoneManager.cpp @@ -320,7 +320,7 @@ LWOSCENEID dZoneManager::GetSceneIDFromPosition(const NiPoint3& position) const // Find the chunk containing this position // Reverse the world position calculation from GenerateTerrainMesh for (const auto& chunk : raw.chunks) { - if (chunk.sceneMap.empty()) continue; + if (chunk.sceneMap.empty() || chunk.scaleFactor <= 0.0f || chunk.width <= 1 || chunk.height <= 1 || chunk.colorMapResolution == 0) continue; // Reverse: worldX = (i + offsetX/scaleFactor) * scaleFactor // Therefore: i = worldX/scaleFactor - offsetX/scaleFactor