Skip to content

DexalGT/TS-RitoFile

Repository files navigation

ts-ritofile

Status: experimental / work-in-progress. A TypeScript port of the Python pyritofile library for reading and writing League of Legends game file formats. Byte-exact round-trip is the goal for each format, proven by tests against real files where fixtures are available — but it is not yet a guarantee for every format/version (see BUGS.md).

License: MIT

This library is an unofficial community tool. It is not affiliated with or endorsed by Riot Games, and it ships no game data.

What it does

Read and write the binary formats used by League of Legends, with an API that mirrors pyritofile:

import { BIN, WAD, SKN } from "ts-ritofile";

const bin = new BIN();
bin.read("path/to/file.bin");
for (const entry of bin.entries) {
  console.log(entry.type, entry.hash, entry.data.length);
}

// Get a buffer instead of writing to disk
const buffer = bin.write(undefined, true);

Supported formats

Support reflects what is implemented and, where a fixture exists, covered by a round-trip or read-correctness test. "⚠️" marks code paths that exist but are not yet validated against real files.

Format Read Write Notes
BIN (PROP/PTCH, v1–3) Byte-exact round-trip verified on real .bin files
WAD (RW v1–3) Chunk-table read/write verified; subchunk count/type nibble fixed. Multi-subchunk extraction needs the .subchunktoc (helper provided)
SKN (skinned mesh)
SKL (skeleton)
ANM (r3d2anmd / r3d2canm) Compressed quaternion (smallest-three) verified
MAPGEO (OEGM, v5–17) ⚠️ Vertex formats incl. packed float16 fixed; byte-exact write still open (see BUGS.md); v18 unsupported
TEX
BNK / WPK (Wwise) Container level (extract/repack .wem)
RST (stringtable) v5
SCO / SCB (static mesh)
RMAN (.manifest) Reader only (zstd body + FlatBuffer tables); rewritten from scratch
PRELOAD / INIBIN / TROY ⚠️ Legacy formats; no Python reference (see BUGS.md)

Installation

npm install ts-ritofile

Optional native dependencies

xxhash-wasm and zstd-napi are used for hashing and Zstandard compression. They are optional accelerators; install them for native speed:

npm install xxhash-wasm zstd-napi

Hashing

The library implements the hashes League uses:

  • FNV1a-32 for .bin field/class names (name_to_hash, bin_hash).
  • XXH64 (seed 0, lowercased) for WAD path hashes.
  • xxh3-64 for WAD checksums and RST keys.

Known answer vectors are pinned in the test suite (e.g. FNV1a("mName") === 0x19efbfdb).

Development

npm install
npm run build      # tsc -> dist/
npm test           # jest
npm run lint
npm run format

Tests and fixtures

Tests that need real game files look for them via the RITO_SAMPLE_DIR environment variable (falling back to a sibling RitoShark-Crates/Sample-Files directory in the dev workspace). When the files are absent those tests skip, so the suite stays green without shipping copyrighted assets. Never commit game data.

Correctness

This port was audited against pyritofile (the reference it mirrors) and the Rust RitoShark / league-toolkit crates. A number of correctness bugs were fixed — see CHANGELOG.md — and the remaining known issues are tracked in BUGS.md. When the Python reference and the binary format disagreed (e.g. WAD subchunk handling), correctness was preferred over copying the reference's behavior.

Provenance

ts-ritofile is a TypeScript port of pyritofile, informed by the C# LeagueToolkit and the Rust RitoShark crates. Format documentation comes from the League modding community.

License

MIT © SirDexal

About

A TypeScript library for reading and manipulating League of Legends game files.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors