#parser #format #quake #id #utilities #entities #map

qentities

Utilities related to the q-entities format

4 releases

0.2.2 Aug 8, 2023
0.2.1 Aug 8, 2023
0.2.0 Aug 4, 2023
0.1.0 Aug 2, 2023

#2581 in Parser implementations

MPL-2.0 license

84KB
1.5K SLoC

q-entities

Crates.io Crates.io docs.rs

A Rust crate featuring utilities related to the q-entities format.

The q-entities Format

The q-entities format is the unofficial name which this crate gives to the otherwise unnamed format used by id Software's Quake and its derivative titles to store a map's entities.

There exists no formal specification for this format and derivative titles have on occasion been known to modify how it is parsed which makes defining a complete specification that works under all titles unfeasible. This crate attempts to solve this problem by defining a baseline for parsing the format which can be further modified using a simple builder pattern.

Basic Usage

The crate's top level module features types used to store and access a q-entities collection (most notably QEntities).

The parse module features types used to parse a q-entities file into a q-entities collection (most notably QEntitiesParseOptions).

Minimal Example

use qentities::parse::QEntitiesParseOptions;

const FILE_DATA: &'static [u8] = br#"
{
"classname" "worldspawn"
"wad" "mywad.wad"
}
{
"classname" "light"
"origin" "0 0 32"
}
{
"classname" "info_player_start"
"origin" "0 0 0"
}
"#;

fn main() {
    let entities = QEntitiesParseOptions::new().parse(&FILE_DATA[..]).unwrap();
    for entity in entities.iter() {
        println!("{{");
        for kv in entity.iter() {
            let key = String::from_utf8_lossy(kv.key());
            let value = String::from_utf8_lossy(kv.value());

            println!("{key:?} {value:?}");
        }
        println!("}}");
    }
}

Dependencies

~2.5MB
~38K SLoC