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) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-04-08 15:43:15 +02:00
parent 3857c0de79
commit b067a148f3

View file

@ -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;