Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ xcl shaders D:\data\shaders.rpf --top 50 # pack statistics; --recomp / --compi
xcl rpf D:\data\shaders.rpf --extract NAME --out folder
```

- `xcl rpf` scans plain-name RPF9 records without decrypting the table of contents;
even a compact final record needs no trailing padding.

- **Without a command line** (xcl.exe opened from Explorer) XCL shows a small menu: *Choose a
game…* (pick its exe or `MicrosoftGame.config`) or *Run again* (the last one). On an error the
window stays open until Enter.
Expand Down
18 changes: 17 additions & 1 deletion crates/xcl/src/gpu/pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ fn rd32(b: &[u8], o: usize) -> u32 {
pub fn scan(d: &[u8], from: usize) -> Vec<Record> {
let mut out = Vec::new();
let mut i = from;
while i < d.len().saturating_sub(32) {
// Minimum: length byte + three name bytes + 18 header bytes + nonempty payload.
while i < d.len().saturating_sub(1 + 3 + 18) {
let len = d[i] as usize;
let Some(p) = i.checked_add(len) else { break };
let Some(header_end) = p.checked_add(18) else { break };
Expand Down Expand Up @@ -131,6 +132,21 @@ mod tests {
assert_eq!(name_stage("ptfx_x"), None);
}

#[test]
fn short_records_do_not_need_trailing_padding() {
for name in ["PS_", "PS_ABCD"] {
for prefix in [0, 0x40] {
let mut bytes = vec![0xAA; prefix];
bytes.extend(record(name, b"DXBC"));
let records = scan(&bytes, prefix);
let [r] = records.as_slice() else { panic!("missing short record {name} at {prefix}") };
assert_eq!(r.name, name);
assert_eq!(r.offset, prefix);
assert_eq!(inflate(&bytes, r).as_deref(), Some(b"DXBC".as_slice()));
}
}
}

/// An effect-qualified name is one record under its full name, also when the `:` byte
/// equals the length of the rest of the name (which makes the tail look like a record).
#[test]
Expand Down
Loading