From b067a148f37e6f76d56e4dd5cc599b9a0582079b Mon Sep 17 00:00:00 2001 From: Erik Date: Wed, 8 Apr 2026 15:43:15 +0200 Subject: [PATCH] fix: flip dungeon Y for north-up, guard COM exceptions - Negate Y delta for dungeon tiles and objects so north points up (AC Y+ = north, canvas Y+ = down) - Wrap early COM calls in try/catch to prevent RPC_E_SERVERFAULT during state transitions (portal loading, etc.) Co-Authored-By: Claude Opus 4.6 (1M context) --- static/script.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/static/script.js b/static/script.js index b27e09a8..77d940bc 100644 --- a/static/script.js +++ b/static/script.js @@ -3877,9 +3877,9 @@ function updateRadarWindow(msg) { ctx.globalAlpha = isCurrentFloor ? 0.85 : 0.12; (level.cells || []).forEach(cell => { - // UB mirrors X: x = -(cell.x - playerX), Y is direct: y = cell.y - playerY + // UB mirrors X, Y flipped for north-up (AC Y+ = north, canvas Y+ = down) const dx = -(cell.x - playerX) * scale; - const dy = (cell.y - playerY) * scale; + const dy = -(cell.y - playerY) * scale; const tileCanvas = hasTiles ? dungeonTileCanvases[String(cell.env_id)] : null; if (tileCanvas) { @@ -3976,8 +3976,8 @@ function updateRadarWindow(msg) { // Use raw physics coords in dungeons (X mirrored), EW/NS on surface let dX, dY; if (isDungeon && obj.raw_x !== undefined) { - dX = -(obj.raw_x - playerX); // X mirrored to match UB coordinate system - dY = (obj.raw_y - playerY); + dX = -(obj.raw_x - playerX); // X mirrored + dY = -(obj.raw_y - playerY); // Y flipped for north-up } else { dX = obj.ew - playerEW; dY = obj.ns - playerNS; @@ -4039,8 +4039,8 @@ function updateRadarWindow(msg) { const withDist = objects.map(obj => { let distMeters, dX, dY; if (isDungeon && obj.raw_x !== undefined) { - dX = -(obj.raw_x - playerX); // X mirrored - dY = (obj.raw_y - playerY); + dX = -(obj.raw_x - playerX); + dY = -(obj.raw_y - playerY); distMeters = Math.sqrt(dX * dX + dY * dY); // raw coords are ~meters } else { dX = obj.ew - playerEW;