#!/usr/bin/env python3 ## # Extract LEGO Stunt Rally RFD/RFH archives. # # https://github.com/vs49688/scripts/ # Zane van Iperen # # SPDX-License-Identifier: CC0-1.0 # # Usage: stuntxtract.py [out-path] ## import struct import collections import os.path import subprocess import zlib import json import sys ARCHIVES = [ 'ART0001', 'CITY0001', 'DESERT0001', 'ICE0001', 'JUNGLE0001', 'SPEECH0001', 'TEXT0001', ] SRIndexEntry = collections.namedtuple('SRIndexEntry', [ 'unk1', 'unk2', 'unk3', 'size', 'offset', 'path' ]) if len(sys.argv) == 2: gamedir = sys.argv[1] outdir = '.' elif len(sys.argv) == 3: gamedir = sys.argv[1] outdir = sys.argv[2] else: print(f'Usage: {sys.argv[0]} [out-path]') exit(2) index = {} for a in ARCHIVES: rfh = os.path.join(gamedir, 'res', f'{a}.RFH') with open(rfh, 'rb') as f: data = f.read() entries = [] while len(data) > 0: fields = data[:20] data = data[20:] idx = data.index(b'\0') unk1, unk2, unk3, size, offset = struct.unpack('