mappy 1.0.0

A parser for Quake .map files and their descendent formats
Documentation
  • Coverage
  • 34.01%
    50 out of 147 items documented1 out of 6 items with examples
  • Size
  • Source code size: 195.57 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 8.08 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 46s Average build duration of successful builds.
  • all releases: 46s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • chaynabors

mappy

A parser for Quake .map files and their descendent formats.

Format Description
Quake .map Standard and Valve 220 texture coordinate variants, including Quake II surface flags
Valve .vmf Full fidelity, including displacements, I/O connections, visgroups, cameras, and cordons

Usage

[dependencies]

mappy = "1"

Parse a .map file:

use mappy::{EntityProperties, Map};

let map: Map = include_str!("assets/start.map").parse()?;

for entity in &map.entities {
    let classname: String = entity.get("classname")?;
    println!("{classname}");
}

Parse a .vmf file:

use mappy::{EntityProperties, Vmf};

let vmf: Vmf = include_str!("assets/start.vmf").parse()?;

for entity in &vmf.entities {
    let classname: String = entity.get("classname")?;
    println!("{classname}");
}

Convert entities to typed game objects with [FromEntity]:

use mappy::{Entity, FromEntity};

struct PlayerStart {
    origin: String,
}

impl FromEntity for PlayerStart {
    type Error = String;

    fn from_entity(entity: &Entity) -> Result<Self, Self::Error> {
        if entity.properties.get("classname").map(String::as_str) != Some("info_player_start") {
            return Err("not a player start".into());
        }
        Ok(PlayerStart {
            origin: entity.properties.get("origin").cloned().unwrap_or_default(),
        })
    }
}

Features

Feature Description
serde Derive Serialize/Deserialize for all public types

License

MIT OR Apache-2.0