From 550ea227249b9d92fab0188f5416b120356cf0a8 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Sat, 21 Feb 2026 17:02:50 +0100 Subject: [PATCH] fix(minimap): improve error handling and performance in tile parsing - Add warning logging in renderChunkToPixels catch block before fallback - Switch maxTick filtering from skip/continue to early break (append-only optimization) - Use existsSync for directory existence check in loadExistingTagContent --- plugins/minimap/controller.ts | 3 ++- plugins/minimap/utils/tile-utils.ts | 18 ++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/plugins/minimap/controller.ts b/plugins/minimap/controller.ts index 8fd7cd41..7d35fd4d 100644 --- a/plugins/minimap/controller.ts +++ b/plugins/minimap/controller.ts @@ -819,7 +819,8 @@ export class ControllerPlugin extends BaseControllerPlugin { async loadExistingTagContent() { try { - if (!await fs.pathExists(this.chartTagsPath)) { + // Use existsSync for synchronous directory existence check + if (!fs.existsSync(this.chartTagsPath)) { return; } diff --git a/plugins/minimap/utils/tile-utils.ts b/plugins/minimap/utils/tile-utils.ts index 3cc23820..c1c5487f 100644 --- a/plugins/minimap/utils/tile-utils.ts +++ b/plugins/minimap/utils/tile-utils.ts @@ -63,6 +63,8 @@ export async function renderChunkToPixels(chunkData: BinaryData): Promise maxTick) { - const chunkCoordsByte = readUInt8(tileData, offset); - offset += 1; - const length = readUInt16BE(tileData, offset); - offset += 2; - if (offset + length > tileData.length) { - return { success: false, newOffset: offset }; - } - offset += length; // Skip chunk data - return { success: true, newOffset: offset }; + return { success: false, newOffset: offset - 4 }; } const chunkCoordsByte = readUInt8(tileData, offset); @@ -223,9 +217,9 @@ function processPixelData( return { success: false, newOffset: offset }; } - // Skip if beyond target tick + // Break early if this record is beyond our target tick (append-only optimization) if (maxTick !== undefined && tick > maxTick) { - return { success: true, newOffset: offset + expectedDataLength }; + return { success: false, newOffset: offset - 4 }; } for (let i = 0; i < pixelCount; i++) {