Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save WhyIsEvery4thYearAlwaysBad/40646b480680ff31be12f88ff178f808 to your computer and use it in GitHub Desktop.

Select an option

Save WhyIsEvery4thYearAlwaysBad/40646b480680ff31be12f88ff178f808 to your computer and use it in GitHub Desktop.
The Valve Binary Space Partition file format in Kaitai Struct.
meta:
id: vbsp
title: "Valve Binary Space Partition"
tags: [ "vbsp", "bsp", "source", "valve" ]
file-extension: bsp
endian: le
doc: |
Valve Binary Space Partition, or VBSP, is a file format for levels; it is a variant of the Binary Space Partition level format used by Quake.
VBSP are primarily created through the `vbsp` executable, made by Valve that is packaged in the Source Engine.
**TODO: Handle LZMA data.**
doc-ref: https://developer.valvesoftware.com/wiki/VBSP
seq:
- id: signature
contents: "VBSP"
doc: "The format signature to identify VBSP files."
- id: version
type: u4
doc: |
File format version.
- id: lump_header_array
type: lump_header
repeat: expr
repeat-expr: 64
doc: |
64-dimension array of lump metadata.
- id: map_revision_number
type: u4
doc: |
An integer that stores the map's iteration and version.
types:
lump_header:
seq:
- id: file_offset
type: u4
doc: |
Location of the data lump.
- id: byte_length
type: u4
doc: |
Byte length of the data lump.
- id: version
type: u4
doc: |
Format version of the data lump.
- id: identifier
size: 4
doc: |
4th-dimensional byte array to identify the data lump.
instances:
lump:
pos: file_offset
size: byte_length
doc: The data stored by the lump.
# SUGGESTION: Should I add preset lump types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment