Level Dump CLI

Level files (.xgeo, .xent, .xlvw, .xcam) are binary for size and load time. Every record in them is defined by a Schema (assets/src/schema.rs): one declaration generates the binary reader, binary writer, and field table, and assets/src/schema_dump.rs serializes and deserializes JSON directly from that table with no duplicate specification to maintain.

Field Table Types

  • Scalars: u8, u16, u32, u64, i32, f32, f64, bool, string, bytes
  • Vectors: vec2, vec3, vec4 (f32 components)
  • Composites: T[N] (fixed array), [T] (u32 count + items; [T]@A aligns items to A bytes), ?T (bool + optional T, JSON null when absent), (A, B) (tuple)
  • Named records & block — A registered record name, or a block whose bytes decode as the registered record named by the preceding string field (falling back to hex when unregistered)

Lossless JSON Round-Trip

A file's layout is a FileSchema (signature, version, and ordered parts or section table), registered by the owning crate (engine_scene::level_schema, engine_scene_world::level_schema).

  • Integers are exact; floats use the shortest decimal reproducing identical bits (non-finite floats serialize as "f32:7fc00000"); raw bytes serialize as arrays of 32-byte hex strings.
  • Malformed bytes, unknown records, or mismatched types return errors naming the exact field path.
  • Loading a dump back produces the exact original bytes, byte for byte.
  • dump_file(schema, bytes, skip) emits "unchanged" for skipped sections, and load_file(schema, value, base) copies those sections verbatim from base, allowing editors to modify small sections without holding huge geometry buffers in JSON.

CLI Usage (xodo)

sh
xodo level dump FILE [--skip SECTION,...]
xodo level load JSON FILE [--base FILE]   # atomic write via temp file + rename
xodo level schema [NAME]                  # list formats or inspect one record

The xodo binary (cli/) registers the engine's built-in records. A host with custom component schemas builds its own CLI calling engine_cli::run(arguments, register).

Git Diffs (textconv)

Configure Git to diff binary level files as readable JSON:

sh
git config diff.level.textconv "xodo level dump"
cat <<&#39;EOF' >> .gitattributes
*.xent diff=level
*.xlvw diff=level
*.xgeo diff=level
*.xcam diff=level
EOF

Hosts with custom schemas substitute their own CLI binary name for xodo.