From 5d5f620fec12e319e9658d1fd34de2324bb5016d Mon Sep 17 00:00:00 2001 From: modeco80 Date: Tue, 9 Jul 2024 19:29:44 -0400 Subject: [PATCH] clean up structures --- msagent.js/src/structs/core.ts | 30 ++++++++++++++---------------- msagent.js/src/structs/image.ts | 29 ----------------------------- 2 files changed, 14 insertions(+), 45 deletions(-) diff --git a/msagent.js/src/structs/core.ts b/msagent.js/src/structs/core.ts index 9c833de..2d474bc 100644 --- a/msagent.js/src/structs/core.ts +++ b/msagent.js/src/structs/core.ts @@ -29,8 +29,7 @@ export class RGNDATAHEADER { let hdr = new RGNDATAHEADER(); hdr.size = buffer.readU32LE(); - if(hdr.size != 0x20) - throw new Error("Invalid RGNDATAHEADER!"); + if (hdr.size != 0x20) throw new Error('Invalid RGNDATAHEADER!'); hdr.type = buffer.readU32LE(); if (hdr.type != 1) throw new Error('Invalid RGNDATAHEADER type (only rectangles are supported)!'); @@ -117,22 +116,21 @@ export class RGBAColor { } export class COMPRESSED_DATABLOCK { - data: Uint8Array = new Uint8Array(); + data: Uint8Array = new Uint8Array(); - static read(buffer: BufferStream) { - let compressed = new COMPRESSED_DATABLOCK(); + static read(buffer: BufferStream) { + let compressed = new COMPRESSED_DATABLOCK(); - let compressedSize = buffer.readU32LE(); - let uncompressedSize = buffer.readU32LE(); + let compressedSize = buffer.readU32LE(); + let uncompressedSize = buffer.readU32LE(); - if(compressedSize == 0) - compressed.data = buffer.subBuffer(uncompressedSize).raw(); - else { - let data = buffer.subBuffer(compressedSize).raw(); - compressed.data = new Uint8Array(uncompressedSize); - compressDecompress(data, compressed.data); + if (compressedSize == 0) compressed.data = buffer.subBuffer(uncompressedSize).raw(); + else { + let data = buffer.subBuffer(compressedSize).raw(); + compressed.data = new Uint8Array(uncompressedSize); + compressDecompress(data, compressed.data); + } + + return compressed; } - - return compressed; - } } diff --git a/msagent.js/src/structs/image.ts b/msagent.js/src/structs/image.ts index a193b90..9f1253c 100644 --- a/msagent.js/src/structs/image.ts +++ b/msagent.js/src/structs/image.ts @@ -1,29 +1,3 @@ -/* -struct AcsImageInfo { - u8 unkStart; - u16 width; - u16 height; - bool isCompressed; - - // This algorithm is the size used for allocating - // the decompression buffer. - // ((Width + 3) & 0xFC) * Height) - - // Data - DATABLOCK imageData; - - // The data here is a Win32 RGNDATA - COMPRESSED regionData; -}; - -struct AcsImageInfoPointer { - LOCATION imageInfoLocation; - u32 checksumMaybe; - - AcsImageInfo imageInfo @ imageInfoLocation.offset; -}; -*/ - import { BufferStream } from '../buffer'; import { compressDecompress } from '../decompress'; import { COMPRESSED_DATABLOCK, LOCATION, RGNDATA } from './core'; @@ -55,9 +29,6 @@ export class AcsImage { image.data = data; } - - - // this will be a rgndata (TODO) read this let temp = COMPRESSED_DATABLOCK.read(buffer); let tempBuffer = new BufferStream(temp.data);