RuneWiki Old Engine/File Archive

Old Engine/File Archive

From RuneWiki

This file format was used by RS2 and RSC. Files are compressed using BZip2.

The BZip2 signature (4 bytes) is intentionally left out to save space, and it must be prepended before decompressing.

File Header
Purpose Data Type
Unpacked size SWord
Packed size SWord

If the unpacked size and the packed size do not match, decompress the archive now.

Archive Header
Purpose Data Type
File count Word
... for N files: ...
File hash DWord
File uncompressed size SWord
File compressed size SWord

When reading the file, if the archive was not decompressed before, decompress the file once it's read.


this.unpackedSize = readSWord(src);
this.packedSize = readSWord(src);

if (this.packedSize != this.unpackedSize) {
	let data = bz2.decompress(concatenate(Uint8Array, BZ2_HEADER, src.buffer.slice(src.offset)));
	src = { buffer: data, offset: 0, length: data.length };
} = src;

this.fileCount = readWord(src);
this.fileHash = [];
this.fileSizeInflated = [];
this.fileSizeDeflated = [];
this.fileOffset = [];

let offset = src.offset + (this.fileCount * 10);
for (let file = 0; file < this.fileCount; file++) {
	this.fileHash[file] = readDWord(src);
	this.fileSizeInflated[file] = readSWord(src);
	this.fileSizeDeflated[file] = readSWord(src);
	this.fileOffset[file] = offset;
	offset += this.fileSizeDeflated[file];